@fibery/views 10.4.0 → 10.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/views.js +93 -12
- package/package.json +3 -3
package/lib/views.js
CHANGED
|
@@ -868,9 +868,9 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
868
868
|
if (!groupBy) {
|
|
869
869
|
return null;
|
|
870
870
|
}
|
|
871
|
-
const
|
|
872
|
-
const
|
|
873
|
-
return visitor.visitGroupByExpression(groupBy, fromType,
|
|
871
|
+
const groupByIndexes = Object.keys(groupBy).map(key => parseInt(key));
|
|
872
|
+
const removedItemsBeforeTargetLengths = groupByIndexes.map(groupByIndex => removedItemsIndexes.filter(n => n < groupByIndex).length);
|
|
873
|
+
return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTargetLengths);
|
|
874
874
|
}
|
|
875
875
|
}
|
|
876
876
|
}) : item;
|
|
@@ -885,9 +885,9 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
885
885
|
if (!groupingExpression) {
|
|
886
886
|
return null;
|
|
887
887
|
}
|
|
888
|
-
const
|
|
889
|
-
const
|
|
890
|
-
return visitor.visitGroupByExpression(groupingExpression, fromType,
|
|
888
|
+
const groupingExpressionIndexes = Object.keys(groupingExpression).map(key => parseInt(key));
|
|
889
|
+
const removedItemsBeforeTargetLengths = groupingExpressionIndexes.map(groupByIndex => removedItemsIndexes.filter(n => n < groupByIndex).length);
|
|
890
|
+
return visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeTargetLengths);
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
893
|
}) : item;
|
|
@@ -924,6 +924,32 @@ const visitSmartFolder = (smartFolder, visitor) => immutableUpdate__default["def
|
|
|
924
924
|
return query ? item : null;
|
|
925
925
|
});
|
|
926
926
|
}
|
|
927
|
+
},
|
|
928
|
+
columnOrderWithIds: {
|
|
929
|
+
$apply: columnOrderWithIds => {
|
|
930
|
+
if (!visitor.visitUnitGroupKey || !columnOrderWithIds) {
|
|
931
|
+
return columnOrderWithIds;
|
|
932
|
+
}
|
|
933
|
+
return columnOrderWithIds.map(key => visitor.visitUnitGroupKey(key));
|
|
934
|
+
}
|
|
935
|
+
},
|
|
936
|
+
pinnedColumnsWithIds: {
|
|
937
|
+
$apply: pinnedColumnsWithIds => {
|
|
938
|
+
if (!visitor.visitUnitGroupKey || !pinnedColumnsWithIds) {
|
|
939
|
+
return pinnedColumnsWithIds;
|
|
940
|
+
}
|
|
941
|
+
return pinnedColumnsWithIds.map(key => visitor.visitUnitGroupKey(key));
|
|
942
|
+
}
|
|
943
|
+
},
|
|
944
|
+
columnAggFunc: {
|
|
945
|
+
$apply: columnAggFunc => {
|
|
946
|
+
if (!visitor.visitUnitGroupKey || !columnAggFunc) {
|
|
947
|
+
return columnAggFunc;
|
|
948
|
+
}
|
|
949
|
+
return Object.fromEntries(Object.entries(columnAggFunc).map(([key, value]) => {
|
|
950
|
+
return [visitor.visitUnitGroupKey(key), value];
|
|
951
|
+
}));
|
|
952
|
+
}
|
|
927
953
|
}
|
|
928
954
|
}
|
|
929
955
|
});
|
|
@@ -933,10 +959,10 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
|
|
|
933
959
|
}
|
|
934
960
|
const entries = Object.entries(groupByExpression).map(([index, {
|
|
935
961
|
expression
|
|
936
|
-
}]) => {
|
|
962
|
+
}], groupByIndex) => {
|
|
937
963
|
const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
|
|
938
964
|
if (visitedExpression) {
|
|
939
|
-
return [`${parseInt(index) - removedItems}`, {
|
|
965
|
+
return [`${parseInt(index) - removedItems[groupByIndex]}`, {
|
|
940
966
|
expression: visitedExpression
|
|
941
967
|
}];
|
|
942
968
|
}
|
|
@@ -984,13 +1010,68 @@ const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromT
|
|
|
984
1010
|
};
|
|
985
1011
|
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
986
1012
|
visitQueryExpression: query => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
987
|
-
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType),
|
|
988
|
-
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression)
|
|
1013
|
+
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType, Object.keys(groupBy).map(() => 0)),
|
|
1014
|
+
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
1015
|
+
visitUnitGroupKey: unitGroupKey => {
|
|
1016
|
+
const keyParts = unitGroupKey.split("|");
|
|
1017
|
+
return keyParts.map(keyPart => {
|
|
1018
|
+
const [unitType, ...rest] = keyPart.split("_");
|
|
1019
|
+
if (unitType === "user-button") {
|
|
1020
|
+
return keyPart;
|
|
1021
|
+
}
|
|
1022
|
+
const name = rest.join("_");
|
|
1023
|
+
if (!name) {
|
|
1024
|
+
return keyPart;
|
|
1025
|
+
}
|
|
1026
|
+
const [type, field] = name.split(":");
|
|
1027
|
+
if (!field) {
|
|
1028
|
+
return keyPart;
|
|
1029
|
+
}
|
|
1030
|
+
if (!(type in schema.typeObjectsByName)) {
|
|
1031
|
+
return keyPart;
|
|
1032
|
+
}
|
|
1033
|
+
const typeObject = schema.typeObjectsByName[type];
|
|
1034
|
+
if (!(field in typeObject.fieldObjectsByName)) {
|
|
1035
|
+
return keyPart;
|
|
1036
|
+
}
|
|
1037
|
+
const fieldObject = typeObject.fieldObjectsByName[field];
|
|
1038
|
+
return `${unitType}_${fieldObject.id}`;
|
|
1039
|
+
}).filter(Boolean).join("|");
|
|
1040
|
+
}
|
|
989
1041
|
});
|
|
990
1042
|
const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
991
1043
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
992
|
-
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType),
|
|
993
|
-
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
1044
|
+
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType, Object.keys(groupBy).map(() => 0)),
|
|
1045
|
+
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
1046
|
+
visitUnitGroupKey: unitGroupKey => {
|
|
1047
|
+
const types = smartFolder["fibery/meta"].items.map(item => item.query["q/from"]);
|
|
1048
|
+
const fieldObjectsById = types.reduce((acc, type) => {
|
|
1049
|
+
if (!(type in schema.typeObjectsById)) {
|
|
1050
|
+
return acc;
|
|
1051
|
+
}
|
|
1052
|
+
const fieldObjects = schema.typeObjectsById[type].fieldObjectsById;
|
|
1053
|
+
return {
|
|
1054
|
+
...acc,
|
|
1055
|
+
...fieldObjects
|
|
1056
|
+
};
|
|
1057
|
+
}, {});
|
|
1058
|
+
const keyParts = unitGroupKey.split("|");
|
|
1059
|
+
return keyParts.map(keyPart => {
|
|
1060
|
+
const [unitType, ...rest] = keyPart.split("_");
|
|
1061
|
+
if (unitType === "user-button") {
|
|
1062
|
+
return keyPart;
|
|
1063
|
+
}
|
|
1064
|
+
const fieldId = rest.join("_");
|
|
1065
|
+
if (!fieldId) {
|
|
1066
|
+
return keyPart;
|
|
1067
|
+
}
|
|
1068
|
+
const fieldObject = fieldObjectsById[fieldId];
|
|
1069
|
+
if (!fieldObject) {
|
|
1070
|
+
return keyPart;
|
|
1071
|
+
}
|
|
1072
|
+
return `${unitType}_${fieldObject.holderType}:${fieldObject.name}`;
|
|
1073
|
+
}).filter(Boolean).join("|");
|
|
1074
|
+
}
|
|
994
1075
|
});
|
|
995
1076
|
const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
996
1077
|
visitQueryExpression: query => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, query),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"microbundle": "0.15.1",
|
|
21
21
|
"@fibery/babel-preset": "7.4.0",
|
|
22
22
|
"@fibery/eslint-config": "8.6.0",
|
|
23
|
-
"@fibery/
|
|
24
|
-
"@fibery/
|
|
23
|
+
"@fibery/schema": "10.2.1",
|
|
24
|
+
"@fibery/expression-utils": "9.0.5"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@fibery/expression-utils": "^9.0.5",
|