@fibery/views 10.4.0 → 10.5.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 +86 -12
- package/package.json +1 -1
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,61 @@ 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
|
+
const fieldObject = schema.typeObjectsByName[type].fieldObjectsByName[field];
|
|
1028
|
+
if (!fieldObject) {
|
|
1029
|
+
return null;
|
|
1030
|
+
}
|
|
1031
|
+
return `${unitType}_${fieldObject.id}`;
|
|
1032
|
+
}).filter(Boolean).join("|");
|
|
1033
|
+
}
|
|
989
1034
|
});
|
|
990
1035
|
const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
991
1036
|
visitQueryExpression: query => replaceIdsWithNamesInQueryExpression(schema, query),
|
|
992
|
-
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType),
|
|
993
|
-
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression)
|
|
1037
|
+
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType, Object.keys(groupBy).map(() => 0)),
|
|
1038
|
+
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
1039
|
+
visitUnitGroupKey: unitGroupKey => {
|
|
1040
|
+
const types = smartFolder["fibery/meta"].items.map(item => item.query["q/from"]);
|
|
1041
|
+
const fieldObjectsById = types.reduce((acc, type) => {
|
|
1042
|
+
if (!(type in schema.typeObjectsById)) {
|
|
1043
|
+
return acc;
|
|
1044
|
+
}
|
|
1045
|
+
const fieldObjects = schema.typeObjectsById[type].fieldObjectsById;
|
|
1046
|
+
return {
|
|
1047
|
+
...acc,
|
|
1048
|
+
...fieldObjects
|
|
1049
|
+
};
|
|
1050
|
+
}, {});
|
|
1051
|
+
const keyParts = unitGroupKey.split("|");
|
|
1052
|
+
return keyParts.map(keyPart => {
|
|
1053
|
+
const [unitType, ...rest] = keyPart.split("_");
|
|
1054
|
+
if (unitType === "user-button") {
|
|
1055
|
+
return keyPart;
|
|
1056
|
+
}
|
|
1057
|
+
const fieldId = rest.join("_");
|
|
1058
|
+
if (!fieldId) {
|
|
1059
|
+
return keyPart;
|
|
1060
|
+
}
|
|
1061
|
+
const fieldObject = fieldObjectsById[fieldId];
|
|
1062
|
+
if (!fieldObject) {
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
return `${unitType}_${fieldObject.holderType}:${fieldObject.name}`;
|
|
1066
|
+
}).filter(Boolean).join("|");
|
|
1067
|
+
}
|
|
994
1068
|
});
|
|
995
1069
|
const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
996
1070
|
visitQueryExpression: query => deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression(schema, query),
|