@fibery/views 25.1.4 → 26.0.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/errors.d.ts +2 -3
- package/lib/field-utils/avatar.d.ts +8 -9
- package/lib/field-utils/back-references.d.ts +4 -5
- package/lib/field-utils/comments.d.ts +5 -6
- package/lib/field-utils/date-time.d.ts +7 -8
- package/lib/field-utils/enum-value.d.ts +6 -7
- package/lib/field-utils/file.d.ts +3 -4
- package/lib/field-utils/icon.d.ts +6 -7
- package/lib/field-utils/number.d.ts +11 -12
- package/lib/field-utils/reference-collection.d.ts +6 -7
- package/lib/field-utils/reference.d.ts +3 -4
- package/lib/field-utils/relation-view.d.ts +2 -3
- package/lib/field-utils/rich-text.d.ts +9 -10
- package/lib/field-utils/text.d.ts +9 -10
- package/lib/field-utils/user-active.d.ts +3 -4
- package/lib/field-utils/user-role.d.ts +3 -4
- package/lib/field-utils/workflow.d.ts +9 -10
- package/lib/filter.d.ts +29 -0
- package/lib/filter.js +0 -0
- package/lib/index.d.ts +57 -21
- package/lib/index.js +101 -94
- package/lib/meta-validation.d.ts +3 -4
- package/lib/private/board.d.ts +218 -14
- package/lib/private/board.js +138 -231
- package/lib/private/calendar.d.ts +213 -13
- package/lib/private/calendar.js +35 -81
- package/lib/private/feed.d.ts +211 -13
- package/lib/private/feed.js +34 -80
- package/lib/private/form.d.ts +52 -7
- package/lib/private/form.js +41 -48
- package/lib/private/map.d.ts +211 -13
- package/lib/private/map.js +34 -80
- package/lib/private/smart-folder.d.ts +118 -29
- package/lib/private/smart-folder.js +70 -148
- package/lib/private/timeline.d.ts +535 -31
- package/lib/private/timeline.js +158 -219
- package/lib/private/units.d.ts +3 -4
- package/lib/private/utils.d.ts +63 -57
- package/lib/private/utils.js +71 -49
- package/lib/refs.d.ts +19 -0
- package/lib/refs.js +0 -0
- package/lib/unit-definitions/avatar-collection.d.ts +29 -4
- package/lib/unit-definitions/avatar-collection.js +1 -1
- package/lib/unit-definitions/avatar-input.d.ts +49 -4
- package/lib/unit-definitions/avatar.d.ts +54 -4
- package/lib/unit-definitions/avatar.js +1 -1
- package/lib/unit-definitions/back-references-list.d.ts +31 -4
- package/lib/unit-definitions/back-references-list.js +1 -1
- package/lib/unit-definitions/bool-checkbox.d.ts +23 -4
- package/lib/unit-definitions/bool-checkbox.js +1 -1
- package/lib/unit-definitions/bool.d.ts +23 -4
- package/lib/unit-definitions/bool.js +1 -1
- package/lib/unit-definitions/collection-count.d.ts +31 -4
- package/lib/unit-definitions/color-input.d.ts +22 -4
- package/lib/unit-definitions/color-input.js +1 -1
- package/lib/unit-definitions/comments-list.d.ts +63 -4
- package/lib/unit-definitions/comments-list.js +1 -1
- package/lib/unit-definitions/date-range-combobox.d.ts +23 -4
- package/lib/unit-definitions/date-range-combobox.js +1 -1
- package/lib/unit-definitions/date-range.d.ts +23 -4
- package/lib/unit-definitions/date-range.js +1 -1
- package/lib/unit-definitions/date-time-combobox.d.ts +23 -4
- package/lib/unit-definitions/date-time-combobox.js +1 -1
- package/lib/unit-definitions/date.d.ts +23 -4
- package/lib/unit-definitions/date.js +1 -1
- package/lib/unit-definitions/email-input.d.ts +23 -4
- package/lib/unit-definitions/email.d.ts +23 -4
- package/lib/unit-definitions/emoji.d.ts +23 -4
- package/lib/unit-definitions/file-collection-count.d.ts +23 -4
- package/lib/unit-definitions/file-collection-count.js +1 -1
- package/lib/unit-definitions/file-compact-collection.d.ts +23 -4
- package/lib/unit-definitions/file-compact-collection.js +1 -1
- package/lib/unit-definitions/file-compact-reference.d.ts +27 -4
- package/lib/unit-definitions/file-reference.d.ts +23 -4
- package/lib/unit-definitions/file-reference.js +1 -1
- package/lib/unit-definitions/files-gallery.d.ts +23 -4
- package/lib/unit-definitions/files-gallery.js +1 -1
- package/lib/unit-definitions/files-l-list-item.d.ts +23 -4
- package/lib/unit-definitions/files-l-list-item.js +1 -1
- package/lib/unit-definitions/files-l-list.d.ts +23 -4
- package/lib/unit-definitions/files-l-list.js +1 -1
- package/lib/unit-definitions/files-list-item.d.ts +23 -4
- package/lib/unit-definitions/files-list-item.js +1 -1
- package/lib/unit-definitions/files-list.d.ts +23 -4
- package/lib/unit-definitions/files-list.js +1 -1
- package/lib/unit-definitions/geometry-preview.d.ts +23 -4
- package/lib/unit-definitions/icon-button.d.ts +28 -4
- package/lib/unit-definitions/icon-button.js +1 -1
- package/lib/unit-definitions/icon-input.d.ts +23 -4
- package/lib/unit-definitions/id.d.ts +32 -4
- package/lib/unit-definitions/index.js +2 -2
- package/lib/unit-definitions/json-input.d.ts +22 -4
- package/lib/unit-definitions/json-input.js +1 -1
- package/lib/unit-definitions/location-input.d.ts +23 -4
- package/lib/unit-definitions/location.d.ts +23 -4
- package/lib/unit-definitions/not-found.d.ts +6 -4
- package/lib/unit-definitions/number-input.d.ts +23 -4
- package/lib/unit-definitions/number-input.js +1 -1
- package/lib/unit-definitions/number.d.ts +27 -4
- package/lib/unit-definitions/phone-input.d.ts +23 -4
- package/lib/unit-definitions/phone.d.ts +23 -4
- package/lib/unit-definitions/progress-bar.d.ts +26 -4
- package/lib/unit-definitions/reference-collection-combobox.d.ts +19 -4
- package/lib/unit-definitions/reference-collection-combobox.js +1 -1
- package/lib/unit-definitions/reference-collection-list.d.ts +19 -4
- package/lib/unit-definitions/reference-collection-list.js +1 -1
- package/lib/unit-definitions/reference-collection-view.d.ts +19 -4
- package/lib/unit-definitions/reference-collection-view.js +1 -1
- package/lib/unit-definitions/reference-collection.d.ts +23 -4
- package/lib/unit-definitions/reference-collection.js +1 -1
- package/lib/unit-definitions/reference-combobox.d.ts +19 -4
- package/lib/unit-definitions/reference-combobox.js +1 -1
- package/lib/unit-definitions/reference-icon.d.ts +27 -4
- package/lib/unit-definitions/reference.d.ts +27 -4
- package/lib/unit-definitions/rich-text-document.d.ts +23 -4
- package/lib/unit-definitions/rich-text-document.js +1 -1
- package/lib/unit-definitions/rich-text-snippet.d.ts +25 -5
- package/lib/unit-definitions/single-location-preview.d.ts +23 -4
- package/lib/unit-definitions/text-input.d.ts +23 -4
- package/lib/unit-definitions/text-input.js +1 -1
- package/lib/unit-definitions/text.d.ts +23 -4
- package/lib/unit-definitions/text.js +1 -1
- package/lib/unit-definitions/title-input.d.ts +24 -4
- package/lib/unit-definitions/title.d.ts +27 -4
- package/lib/unit-definitions/type-badge-abbr.d.ts +15 -4
- package/lib/unit-definitions/type-badge.d.ts +15 -4
- package/lib/unit-definitions/type-icon.d.ts +15 -4
- package/lib/unit-definitions/url-input.d.ts +23 -4
- package/lib/unit-definitions/url.d.ts +23 -4
- package/lib/unit-definitions/user-button.d.ts +13 -4
- package/lib/unit-definitions/user-role-input.d.ts +26 -4
- package/lib/unit-definitions/user-role.d.ts +27 -4
- package/lib/unit-definitions/user-role.js +1 -1
- package/lib/unit-utils/access.d.ts +4 -5
- package/lib/unit-utils/can-edit-field.d.ts +4 -5
- package/lib/unit-utils/common.d.ts +16 -11
- package/lib/unit-utils/decimal.js +4 -4
- package/lib/unit-utils/dynamic-keys.d.ts +8 -9
- package/lib/unit-utils/enums.d.ts +4 -5
- package/lib/unit-utils/formatters.d.ts +15 -16
- package/lib/unit-utils/get-export-value.d.ts +18 -19
- package/lib/unit-utils/get-field-label.d.ts +4 -5
- package/lib/unit-utils/get-unmatched-unit-label.d.ts +2 -3
- package/lib/unit-utils/wrap-normalized-in-expression.d.ts +2 -3
- package/lib/units/board.d.ts +22 -25
- package/lib/units/board.js +2 -1
- package/lib/units/canvas/all-units-data-definitions.js +1 -1
- package/lib/units/canvas/index.d.ts +19 -24
- package/lib/units/canvas/type-badge-abbr.d.ts +13 -35
- package/lib/units/canvas/type-badge.d.ts +13 -35
- package/lib/units/default.d.ts +21 -22
- package/lib/units/default.js +2 -1
- package/lib/units/gallery.d.ts +5 -3
- package/lib/units/gantt.d.ts +23 -24
- package/lib/units/gantt.js +3 -2
- package/lib/units/get-unit-definitions-for-view-type.d.ts +4 -4
- package/lib/units/grid.d.ts +14 -25
- package/lib/units/grid.js +5 -4
- package/lib/units/list.d.ts +17 -26
- package/lib/units/list.js +2 -1
- package/lib/units/make-factory.d.ts +25 -27
- package/lib/units/types.d.ts +19 -13
- package/package.json +10 -10
|
@@ -1,186 +1,108 @@
|
|
|
1
|
-
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression,
|
|
1
|
+
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteNotFoundViewVisitor, getFieldObjectsById, identityViewVisitor, replaceIdsWithNamesInUnitGroupKey, replaceIdsWithNamesViewVisitor, replaceNamesWithIdsInUnitGroupKey, replaceNamesWithIdsViewVisitor, resetContextExpressionIfBroken, reuseIfUnchanged, visitColorCoding, visitContextExpression, visitUnits } from "./utils.js";
|
|
2
2
|
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
3
|
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
-
import get from "lodash/get.js";
|
|
5
4
|
import { replaceIdsWithNamesVisitor, replaceNamesWithIdsVisitor } from "@fibery/expression-utils/src/visitors";
|
|
6
5
|
import { deepEqual } from "@fibery/helpers/src/equal";
|
|
7
6
|
//#region src/private/smart-folder.ts
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!groupBy) return null;
|
|
30
|
-
const removedItemsBeforeTargetLengths = Object.keys(groupBy).map((key) => parseInt(key)).map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
31
|
-
return visitor.visitGroupByExpression(groupBy, fromType, removedItemsBeforeTargetLengths);
|
|
32
|
-
};
|
|
33
|
-
if (!Object.hasOwn(item, "groupBy")) return item;
|
|
34
|
-
const nextItem = {
|
|
35
|
-
...item,
|
|
36
|
-
groupBy: updateGroupBy(item.groupBy)
|
|
37
|
-
};
|
|
38
|
-
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
39
|
-
}).map((item) => {
|
|
40
|
-
const fromType = get(item, ["query", "q/from"]);
|
|
41
|
-
if (!fromType) return item;
|
|
42
|
-
const updateGroupingExpression = (groupingExpression) => {
|
|
43
|
-
if (!groupingExpression) return null;
|
|
44
|
-
const removedItemsBeforeTargetLengths = Object.keys(groupingExpression).map((key) => parseInt(key)).map((groupByIndex) => removedItemsIndexes.filter((n) => n < groupByIndex).length);
|
|
45
|
-
return visitor.visitGroupByExpression(groupingExpression, fromType, removedItemsBeforeTargetLengths);
|
|
46
|
-
};
|
|
47
|
-
if (Array.isArray(item.groupingExpression) || !Object.hasOwn(item, "groupBy") && !item.groupingExpression) return item;
|
|
48
|
-
const nextItem = {
|
|
49
|
-
...item,
|
|
50
|
-
groupingExpression: updateGroupingExpression(item.groupingExpression)
|
|
51
|
-
};
|
|
52
|
-
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
53
|
-
}).map((item) => {
|
|
54
|
-
const fromType = get(item, ["query", "q/from"]);
|
|
55
|
-
if (!fromType) return item;
|
|
56
|
-
const updateQuery = (query) => {
|
|
57
|
-
const visitedQuery = visitor.visitQueryExpression(query);
|
|
58
|
-
return query ? visitedQuery : null;
|
|
59
|
-
};
|
|
60
|
-
const nextItem = {
|
|
61
|
-
...item,
|
|
62
|
-
filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
|
|
63
|
-
query: updateQuery(item.query),
|
|
64
|
-
units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, index, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
|
|
65
|
-
contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
|
|
66
|
-
colorCoding: item.colorCoding ? item.colorCoding.map((colorCoding) => ({
|
|
67
|
-
...colorCoding,
|
|
68
|
-
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
69
|
-
})).filter((colorCoding) => colorCoding.expression !== null) : void 0
|
|
70
|
-
};
|
|
71
|
-
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
72
|
-
}).filter((item) => {
|
|
73
|
-
const { query } = item;
|
|
74
|
-
return query ? item : null;
|
|
7
|
+
function visitItems(items, visitor) {
|
|
8
|
+
const removedItemsIndexes = items.flatMap((item, index) => item.query && visitor.visitQueryExpression(item.query) ? [] : [index]);
|
|
9
|
+
const removedBefore = (groupBy) => Object.keys(groupBy).map((key) => removedItemsIndexes.filter((n) => n < parseInt(key)).length);
|
|
10
|
+
const visitGroupBy = (groupBy, fromType) => groupBy && visitor.visitGroupByExpression ? visitor.visitGroupByExpression(groupBy, fromType, removedBefore(groupBy)) : null;
|
|
11
|
+
return items.map((item) => {
|
|
12
|
+
const { query, filter, contextExpression, units, groupBy, groupingExpression, colorCoding, ...rest } = item;
|
|
13
|
+
const fromType = query?.["q/from"];
|
|
14
|
+
if (!fromType) return query ? item : null;
|
|
15
|
+
const visitedQuery = visitor.visitQueryExpression(query);
|
|
16
|
+
if (!visitedQuery) return null;
|
|
17
|
+
const hasGroupBy = Object.hasOwn(item, "groupBy");
|
|
18
|
+
const keepsGroupingExpression = Array.isArray(groupingExpression) || !hasGroupBy && !groupingExpression;
|
|
19
|
+
return reuseIfUnchanged(item, {
|
|
20
|
+
...rest,
|
|
21
|
+
...hasGroupBy ? { groupBy: visitGroupBy(groupBy, fromType) } : {},
|
|
22
|
+
...keepsGroupingExpression ? Object.hasOwn(item, "groupingExpression") ? { groupingExpression } : {} : { groupingExpression: visitGroupBy(groupingExpression, fromType) },
|
|
23
|
+
filter: filter ? visitor.visitFilter(fromType, filter) : null,
|
|
24
|
+
query: visitedQuery,
|
|
25
|
+
units: units ? visitUnits(fromType, units.filter(truthy), visitor) : void 0,
|
|
26
|
+
contextExpression: visitContextExpression(fromType, contextExpression, visitor),
|
|
27
|
+
colorCoding: colorCoding ? visitColorCoding(fromType, colorCoding, visitor) : void 0
|
|
75
28
|
});
|
|
76
|
-
};
|
|
77
|
-
|
|
29
|
+
}).filter(truthy);
|
|
30
|
+
}
|
|
31
|
+
const visitSmartFolder = (smartFolder, visitor) => {
|
|
32
|
+
const { "fibery/meta": meta, ...rest } = smartFolder;
|
|
33
|
+
const { items = [], columnOrderWithIds, pinnedColumnsWithIds, columnAggFunc, ...metaRest } = meta;
|
|
34
|
+
const visitKey = visitor.visitUnitGroupKey;
|
|
78
35
|
return {
|
|
79
|
-
...
|
|
36
|
+
...rest,
|
|
80
37
|
"fibery/meta": {
|
|
81
|
-
...
|
|
82
|
-
items:
|
|
83
|
-
columnOrderWithIds:
|
|
84
|
-
pinnedColumnsWithIds:
|
|
85
|
-
columnAggFunc:
|
|
38
|
+
...metaRest,
|
|
39
|
+
items: visitItems(items, visitor),
|
|
40
|
+
columnOrderWithIds: visitKey && columnOrderWithIds ? columnOrderWithIds.map(visitKey) : columnOrderWithIds,
|
|
41
|
+
pinnedColumnsWithIds: visitKey && pinnedColumnsWithIds ? pinnedColumnsWithIds.map(visitKey) : pinnedColumnsWithIds,
|
|
42
|
+
columnAggFunc: visitKey && columnAggFunc ? Object.fromEntries(Object.entries(columnAggFunc).map(([key, value]) => [visitKey(key), value])) : columnAggFunc
|
|
86
43
|
}
|
|
87
44
|
};
|
|
88
45
|
};
|
|
89
46
|
const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, groupByExpression, fromType, removedItems) => {
|
|
90
47
|
if (!groupByExpression) return null;
|
|
91
|
-
const entries = Object.entries(groupByExpression).
|
|
48
|
+
const entries = Object.entries(groupByExpression).flatMap(([index, { expression }], groupByIndex) => {
|
|
92
49
|
const visitedExpression = deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}).filter(truthy);
|
|
50
|
+
return visitedExpression ? [[`${parseInt(index) - removedItems[groupByIndex]}`, { expression: visitedExpression }]] : [];
|
|
51
|
+
});
|
|
96
52
|
return entries.length > 0 ? Object.fromEntries(entries) : null;
|
|
97
53
|
};
|
|
54
|
+
const mapGroupByExpressions = (groupByExpression, visitExpression) => Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => [index, { expression: visitExpression(expression) }]));
|
|
98
55
|
const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
99
56
|
if (!groupByExpression) return null;
|
|
100
57
|
const typeObject = schema.getTypeObjectById(fromType);
|
|
101
|
-
if (!typeObject) return
|
|
58
|
+
if (!typeObject) return mapGroupByExpressions(groupByExpression, (expression) => expression);
|
|
102
59
|
const visitor = replaceIdsWithNamesVisitor(typeObject);
|
|
103
|
-
return
|
|
60
|
+
return mapGroupByExpressions(groupByExpression, (expression) => visitor.visitExpression(expression));
|
|
104
61
|
};
|
|
105
62
|
const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
106
63
|
if (!groupByExpression) return null;
|
|
107
64
|
const typeObject = schema.getTypeObjectByName(fromType);
|
|
108
|
-
if (!typeObject) return
|
|
65
|
+
if (!typeObject) return mapGroupByExpressions(groupByExpression, (expression) => expression);
|
|
109
66
|
const visitor = replaceNamesWithIdsVisitor(typeObject);
|
|
110
|
-
return
|
|
111
|
-
};
|
|
112
|
-
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => {
|
|
113
|
-
return visitSmartFolder(smartFolder, {
|
|
114
|
-
visitQueryExpression: (query) => replaceNamesWithIdsInQueryExpression(schema, query),
|
|
115
|
-
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
116
|
-
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType),
|
|
117
|
-
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
118
|
-
visitUnitGroupKey: (unitGroupKey) => replaceNamesWithIdsInUnitGroupKey(unitGroupKey, schema)
|
|
119
|
-
});
|
|
67
|
+
return mapGroupByExpressions(groupByExpression, (expression) => visitor.visitExpression(expression));
|
|
120
68
|
};
|
|
69
|
+
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
70
|
+
...replaceNamesWithIdsViewVisitor(schema),
|
|
71
|
+
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType),
|
|
72
|
+
visitUnitGroupKey: (unitGroupKey) => replaceNamesWithIdsInUnitGroupKey(unitGroupKey, schema)
|
|
73
|
+
});
|
|
121
74
|
const replaceIdsWithNamesInSmartFolder = (schema, smartFolder) => {
|
|
75
|
+
const fieldObjectsById = getFieldObjectsById(smartFolder, schema);
|
|
122
76
|
return visitSmartFolder(smartFolder, {
|
|
123
|
-
|
|
124
|
-
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
77
|
+
...replaceIdsWithNamesViewVisitor(schema),
|
|
125
78
|
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType),
|
|
126
|
-
|
|
127
|
-
visitUnitGroupKey: (unitGroupKey) => replaceIdsWithNamesInUnitGroupKey(unitGroupKey, getFieldObjectsById(smartFolder, schema))
|
|
79
|
+
visitUnitGroupKey: (unitGroupKey) => replaceIdsWithNamesInUnitGroupKey(unitGroupKey, fieldObjectsById)
|
|
128
80
|
});
|
|
129
81
|
};
|
|
130
82
|
const deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
131
|
-
|
|
132
|
-
visitGroupByExpression: (groupBy, fromType, removedItems) => deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema, groupBy, fromType, removedItems)
|
|
133
|
-
visitFilter: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInFilter(schema, fromType, expression),
|
|
134
|
-
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression)
|
|
83
|
+
...deleteNotFoundViewVisitor(schema),
|
|
84
|
+
visitGroupByExpression: (groupBy, fromType, removedItems) => deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression(schema, groupBy, fromType, removedItems)
|
|
135
85
|
});
|
|
136
|
-
const
|
|
137
|
-
visitQueryExpression: (query) => query,
|
|
86
|
+
const identitySmartFolderVisitor = (overrides = {}) => identityViewVisitor({
|
|
138
87
|
visitGroupByExpression: (groupBy) => groupBy,
|
|
139
|
-
|
|
140
|
-
visitFilter: (_fromType, filter) => filter,
|
|
141
|
-
visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression)
|
|
88
|
+
...overrides
|
|
142
89
|
});
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (unit.kind !== "user-button") {
|
|
151
|
-
if (unit.type === "rich-text" && view?.["fibery/type"] === "grid") {
|
|
152
|
-
if (unit.checked) {
|
|
153
|
-
const snippetUnitForField = units.filter((x) => x.kind === "field" && x.type === "rich-text-snippet").find((x) => deepEqual(x.expression, unit.expression));
|
|
154
|
-
if (snippetUnitForField && !snippetUnitForField.checked) snippetUnitForField.checked = true;
|
|
155
|
-
}
|
|
156
|
-
return REMOVE;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return fixViewUnit(schema, fromType, unit, units, {
|
|
160
|
-
unitDefinitions,
|
|
161
|
-
getDefaultUnitTypeForField
|
|
162
|
-
});
|
|
90
|
+
const fixContextExpressionWithBrokenPath = (schema, view, defaultContextExpression) => visitSmartFolder(view, identitySmartFolderVisitor({ visitContextExpression: (fromType, expression) => resetContextExpressionIfBroken(schema, fromType, expression, defaultContextExpression) }));
|
|
91
|
+
const fixUserSelectedUnitsInSmartFolder = (schema, view, { unitDefinitions, getDefaultUnitTypeForField }) => visitSmartFolder(view, identitySmartFolderVisitor({ visitViewUnit: (fromType, unit, units) => {
|
|
92
|
+
const unitType = unit.type;
|
|
93
|
+
if (unit.kind !== "user-button" && unitType === "rich-text" && view["fibery/type"] === "grid") {
|
|
94
|
+
if (unit.checked) {
|
|
95
|
+
const snippetUnitForField = units.find((x) => x.kind === "field" && x.type === "rich-text-snippet" && deepEqual(x.expression, unit.expression));
|
|
96
|
+
if (snippetUnitForField && !snippetUnitForField.checked) snippetUnitForField.checked = true;
|
|
163
97
|
}
|
|
98
|
+
return REMOVE;
|
|
99
|
+
}
|
|
100
|
+
return fixViewUnit(schema, fromType, unit, units, {
|
|
101
|
+
unitDefinitions,
|
|
102
|
+
getDefaultUnitTypeForField
|
|
164
103
|
});
|
|
165
|
-
};
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
visitQueryExpression: (query) => query,
|
|
169
|
-
visitFilter: (_fromType, filter) => filter,
|
|
170
|
-
visitGroupByExpression: (groupBy) => groupBy,
|
|
171
|
-
visitExpression: (_fromType, expression) => expression,
|
|
172
|
-
visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
const enableHideWhenEmptyForCheckedUnits = (view) => {
|
|
176
|
-
return visitSmartFolder(view, {
|
|
177
|
-
visitQueryExpression: (queryExpression) => queryExpression,
|
|
178
|
-
visitGroupByExpression: (groupBy) => groupBy,
|
|
179
|
-
visitExpression: (_fromType, expression) => expression,
|
|
180
|
-
visitFilter: (_fromType, filter) => filter,
|
|
181
|
-
visitEnums: (enums) => enums,
|
|
182
|
-
visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit)
|
|
183
|
-
});
|
|
184
|
-
};
|
|
104
|
+
} }));
|
|
105
|
+
const enableHideWhenEmptyForCheckedUnits = (view) => visitSmartFolder(view, identitySmartFolderVisitor({ visitViewUnit: (_fromType, unit) => enableHideWhenEmptyForCheckedEditableUnit(unit) }));
|
|
106
|
+
const collectGarbage = (view) => visitSmartFolder(view, identitySmartFolderVisitor({ visitViewUnit: (_fromType, unit) => unit.checked ? unit : REMOVE }));
|
|
185
107
|
//#endregion
|
|
186
|
-
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression, deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInSmartFolder, replaceIdsWithNamesInGroupByExpression, replaceIdsWithNamesInSmartFolder, replaceNamesWithIdsInGroupByExpression, replaceNamesWithIdsInSmartFolder };
|
|
108
|
+
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression, deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInSmartFolder, replaceIdsWithNamesInGroupByExpression, replaceIdsWithNamesInSmartFolder, replaceNamesWithIdsInGroupByExpression, replaceNamesWithIdsInSmartFolder, visitSmartFolder };
|