@fibery/views 25.0.0 → 25.1.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/field-utils/back-references.d.ts +11 -10
- package/lib/field-utils/reference.d.ts +3 -3
- package/lib/field-utils/rich-text.d.ts +1 -1
- package/lib/field-utils/workflow.d.ts +3 -3
- package/lib/index.d.ts +7 -7
- package/lib/index.js +5 -3
- package/lib/private/board.d.ts +9 -9
- package/lib/private/board.js +56 -34
- package/lib/private/calendar.d.ts +8 -8
- package/lib/private/calendar.js +30 -21
- package/lib/private/feed.d.ts +8 -8
- package/lib/private/feed.js +29 -20
- package/lib/private/form.d.ts +3 -22
- package/lib/private/map.d.ts +8 -8
- package/lib/private/map.js +29 -20
- package/lib/private/smart-folder.d.ts +8 -8
- package/lib/private/smart-folder.js +64 -43
- package/lib/private/timeline.d.ts +8 -8
- package/lib/private/timeline.js +67 -51
- package/lib/unit-definitions/back-references-list.js +1 -1
- package/lib/unit-definitions/bool-checkbox.js +1 -1
- package/lib/unit-definitions/bool.js +1 -1
- package/lib/unit-definitions/color-input.js +1 -1
- package/lib/unit-definitions/comments-list.js +1 -1
- package/lib/unit-definitions/date-range-combobox.js +1 -1
- package/lib/unit-definitions/date-range.js +1 -1
- package/lib/unit-definitions/date-time-combobox.js +1 -1
- package/lib/unit-definitions/date.js +1 -1
- package/lib/unit-definitions/file-collection-count.js +1 -1
- package/lib/unit-definitions/file-compact-collection.js +1 -1
- package/lib/unit-definitions/file-reference.js +1 -1
- package/lib/unit-definitions/files-gallery.js +1 -1
- package/lib/unit-definitions/files-l-list-item.js +1 -1
- package/lib/unit-definitions/files-l-list.js +1 -1
- package/lib/unit-definitions/files-list-item.js +1 -1
- package/lib/unit-definitions/files-list.js +1 -1
- package/lib/unit-definitions/icon-button.js +1 -1
- package/lib/unit-definitions/index.js +2 -2
- package/lib/unit-definitions/json-input.js +1 -1
- package/lib/unit-definitions/number-input.js +1 -1
- package/lib/unit-definitions/reference-collection-combobox.js +1 -1
- package/lib/unit-definitions/reference-collection-list.js +1 -1
- package/lib/unit-definitions/reference-collection-view.js +1 -1
- package/lib/unit-definitions/reference-collection.js +1 -1
- package/lib/unit-definitions/reference-combobox.js +1 -1
- package/lib/unit-definitions/rich-text-document.js +1 -1
- package/lib/unit-definitions/text-input.js +1 -1
- package/lib/unit-definitions/text.js +1 -1
- package/lib/unit-definitions/user-role.js +1 -1
- package/lib/unit-utils/enums.d.ts +2 -2
- package/lib/unit-utils/get-export-value.d.ts +4 -4
- package/lib/units/board.d.ts +1 -1
- package/lib/units/canvas/all-units-data-definitions.js +1 -1
- package/lib/units/canvas/index.d.ts +1 -1
- package/lib/units/default.d.ts +1 -1
- package/lib/units/gantt.d.ts +1 -1
- package/lib/units/grid.d.ts +1 -1
- package/lib/units/grid.js +3 -3
- package/lib/units/list.d.ts +1 -1
- package/lib/units/make-factory.d.ts +1 -1
- package/package.json +8 -9
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { FieldObject, TypeObject } from "@fibery/schema";
|
|
1
|
+
import { EntityId, FieldObject, TypeId, TypeObject } from "@fibery/schema";
|
|
2
|
+
import { FiberyObject, Projection } from "@fibery/expression-utils/src/types";
|
|
2
3
|
//#region src/field-utils/back-references.d.ts
|
|
3
4
|
declare const isReferenceExtensionField: (fieldObject: FieldObject) => boolean;
|
|
4
|
-
|
|
5
|
-
"fibery/id": "fibery/id";
|
|
5
|
+
type EntityLinkProjection = FiberyObject & {
|
|
6
6
|
"fibery/creation-date": string;
|
|
7
7
|
"Collaboration~Documents/ParagraphSecret": string;
|
|
8
|
-
"Collaboration~Documents/FromTypeId":
|
|
9
|
-
"Collaboration~Documents/FromEntityId":
|
|
8
|
+
"Collaboration~Documents/FromTypeId": TypeId;
|
|
9
|
+
"Collaboration~Documents/FromEntityId": EntityId;
|
|
10
10
|
"Collaboration~Documents/FromEntityField": {
|
|
11
|
-
"fibery/id": string
|
|
12
|
-
};
|
|
11
|
+
"fibery/id": string;
|
|
12
|
+
} | null;
|
|
13
13
|
"fibery/created-by": {
|
|
14
|
-
"fibery/id": string
|
|
15
|
-
};
|
|
14
|
+
"fibery/id": string;
|
|
15
|
+
} | null;
|
|
16
16
|
};
|
|
17
|
+
declare const getEntityLinksListSelect: (typeObject: TypeObject) => Projection<EntityLinkProjection>;
|
|
17
18
|
//#endregion
|
|
18
|
-
export { getEntityLinksListSelect, isReferenceExtensionField };
|
|
19
|
+
export { EntityLinkProjection, getEntityLinksListSelect, isReferenceExtensionField };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FieldObject, TypeObject } from "@fibery/schema";
|
|
2
|
-
import { FieldExpression } from "@fibery/expression-utils";
|
|
3
2
|
import { Select } from "@fibery/expression-utils/src/types";
|
|
3
|
+
import { FieldExpression as FieldExpression$1 } from "@fibery/expression-utils";
|
|
4
4
|
//#region src/field-utils/reference.d.ts
|
|
5
5
|
declare const getReferenceTypeSelectClause: ({ typeObject }: {
|
|
6
6
|
typeObject: TypeObject;
|
|
7
|
-
}, contextPath: FieldExpression) => Select;
|
|
8
|
-
declare const getReferenceFieldNormalizedSelectClause: (fieldObject: FieldObject, contextPath: FieldExpression) => any;
|
|
7
|
+
}, contextPath: FieldExpression$1) => Select;
|
|
8
|
+
declare const getReferenceFieldNormalizedSelectClause: (fieldObject: FieldObject, contextPath: FieldExpression$1) => any;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { getReferenceFieldNormalizedSelectClause, getReferenceTypeSelectClause };
|
|
@@ -11,6 +11,6 @@ declare function getRichTextQuerySelect({ typeObject, unit: { expression }, incl
|
|
|
11
11
|
typeObject: TypeObject;
|
|
12
12
|
unit: FieldUnit;
|
|
13
13
|
includeSnippet?: boolean;
|
|
14
|
-
}):
|
|
14
|
+
}): import("@fibery/expression-utils").Select;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { getHasAccessToSecret, getHasAccessToSecretExpr, getRichTextQuerySelect, hasAccessToSecretKey };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TypeObject } from "@fibery/schema";
|
|
2
|
-
import { FieldExpression } from "@fibery/expression-utils";
|
|
3
2
|
import { FiberyObject } from "@fibery/expression-utils/src/types";
|
|
3
|
+
import { FieldExpression as FieldExpression$1 } from "@fibery/expression-utils";
|
|
4
4
|
//#region src/field-utils/workflow.d.ts
|
|
5
5
|
declare function isWorkflowType(typeObject: TypeObject): boolean;
|
|
6
6
|
declare const getWorkflowFieldObject: (typeObject: TypeObject) => import("@fibery/schema").FieldObject | undefined;
|
|
7
7
|
declare const getIsFinalStateSelect: ({ typeObject, contextPath }: {
|
|
8
8
|
typeObject: TypeObject;
|
|
9
|
-
contextPath?: FieldExpression;
|
|
9
|
+
contextPath?: FieldExpression$1;
|
|
10
10
|
}) => {
|
|
11
11
|
[x: string]: (string | (string | import("@fibery/expression-utils").MultiFieldAccess)[])[];
|
|
12
12
|
} | null;
|
|
@@ -14,7 +14,7 @@ declare const getIsFinalStateSelect: ({ typeObject, contextPath }: {
|
|
|
14
14
|
declare const getIsInFinalState: ({ typeObject, object, contextPath }: {
|
|
15
15
|
typeObject: TypeObject;
|
|
16
16
|
object: FiberyObject;
|
|
17
|
-
contextPath?: FieldExpression;
|
|
17
|
+
contextPath?: FieldExpression$1;
|
|
18
18
|
}) => boolean | null | undefined;
|
|
19
19
|
declare function getWorkflowTypeSelect(typeObject: TypeObject): {
|
|
20
20
|
"workflow/Type": string[];
|
package/lib/index.d.ts
CHANGED
|
@@ -6,19 +6,19 @@ import { assertMetaValid, isMetaValid } from "./meta-validation.js";
|
|
|
6
6
|
import { FieldObject, Schema } from "@fibery/schema";
|
|
7
7
|
import { Expression } from "@fibery/expression-utils/src/types";
|
|
8
8
|
//#region src/index.d.ts
|
|
9
|
-
declare const deleteExpressionWithNotFoundFieldsOrTypesInView: (schema: Schema, view:
|
|
10
|
-
declare const fixUserSelectedUnits: (schema: Schema, view:
|
|
9
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInView: <V extends ViewRecord>(schema: Schema, view: V, ensureAxisInvariant?: boolean) => V;
|
|
10
|
+
declare const fixUserSelectedUnits: <V extends ViewRecord>(schema: Schema, view: V, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
11
11
|
unitDefinitions: UnitDefinitions;
|
|
12
12
|
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
13
|
-
}) =>
|
|
14
|
-
declare const fixContextExpressionWithBrokenPath: (schema: Schema, view:
|
|
13
|
+
}) => V;
|
|
14
|
+
declare const fixContextExpressionWithBrokenPath: <V extends ViewRecord>(schema: Schema, view: V, defaultContextExpression: Expression) => V;
|
|
15
15
|
/**
|
|
16
16
|
* Removes garbage from view's meta to reduce the size.
|
|
17
17
|
*/
|
|
18
18
|
type CollectGarbageSchema = unknown;
|
|
19
19
|
declare const collectGarbage: (_schema: CollectGarbageSchema, view: ViewRecord) => unknown;
|
|
20
|
-
declare const replaceNamesWithIdsInView: (schema: Schema, view:
|
|
21
|
-
declare const replaceIdsWithNamesInView: (schema: Schema, view:
|
|
20
|
+
declare const replaceNamesWithIdsInView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
21
|
+
declare const replaceIdsWithNamesInView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
22
22
|
type ViewMeta = {
|
|
23
23
|
items: {
|
|
24
24
|
query: {
|
|
@@ -29,6 +29,6 @@ type ViewMeta = {
|
|
|
29
29
|
declare const getViewCardTypes: ({ "fibery/meta": { items } }: {
|
|
30
30
|
"fibery/meta": ViewMeta;
|
|
31
31
|
}) => string[];
|
|
32
|
-
declare const migrateHideWhenEmptyToUnitsLevel: (view:
|
|
32
|
+
declare const migrateHideWhenEmptyToUnitsLevel: <V extends ViewRecord>(view: V) => V;
|
|
33
33
|
//#endregion
|
|
34
34
|
export { CollectGarbageSchema, InvalidMetaError, assertMetaValid, collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInSmartFolder, deleteExpressionWithNotFoundFieldsOrTypesInView, fixContextExpressionWithBrokenPath, fixUserSelectedUnits, getViewCardTypes, isMetaValid, migrateHideWhenEmptyToUnitsLevel, replaceIdsWithNamesInSmartFolder, replaceIdsWithNamesInView, replaceNamesWithIdsInSmartFolder, replaceNamesWithIdsInView };
|
package/lib/index.js
CHANGED
|
@@ -9,9 +9,7 @@ import { collectGarbage as collectGarbage$5, deleteExpressionWithNotFoundFieldsO
|
|
|
9
9
|
import { collectGarbage as collectGarbage$6, deleteExpressionWithNotFoundFieldsOrTypesInTimelineView, enableHideWhenEmptyForCheckedEditableUnits as enableHideWhenEmptyForCheckedEditableUnits$1, fixContextExpressionWithBrokenPath as fixContextExpressionWithBrokenPath$6, fixUserSelectedUnitsInTimelineView, replaceIdsWithNamesInTimelineView, replaceNamesWithIdsInTimelineView } from "./private/timeline.js";
|
|
10
10
|
import { assertMetaValid, isMetaValid } from "./meta-validation.js";
|
|
11
11
|
import { isRecord } from "@fibery/helpers/src/_";
|
|
12
|
-
import immutableUpdate from "immutability-helper";
|
|
13
12
|
import get from "lodash/get.js";
|
|
14
|
-
import omit from "lodash/omit.js";
|
|
15
13
|
//#region src/index.ts
|
|
16
14
|
const deleteExpressionWithNotFoundFieldsOrTypesInView = (schema, view, ensureAxisInvariant = true) => {
|
|
17
15
|
switch (view["fibery/type"]) {
|
|
@@ -149,7 +147,11 @@ const migrateHideWhenEmptyToUnitsLevel = (view) => {
|
|
|
149
147
|
if (!viewTypesToTransform.includes(viewType)) return view;
|
|
150
148
|
const showEmptyUnitValues = get(view, ["fibery/meta", "showEmptyUnitValues"]);
|
|
151
149
|
if (showEmptyUnitValues === void 0) return view;
|
|
152
|
-
|
|
150
|
+
const { showEmptyUnitValues: previous, ...meta } = view["fibery/meta"];
|
|
151
|
+
let result = {
|
|
152
|
+
...view,
|
|
153
|
+
"fibery/meta": meta
|
|
154
|
+
};
|
|
153
155
|
if (showEmptyUnitValues === true) return result;
|
|
154
156
|
switch (result["fibery/type"]) {
|
|
155
157
|
case "board":
|
package/lib/private/board.d.ts
CHANGED
|
@@ -3,16 +3,16 @@ import { FieldObject, Schema } from "@fibery/schema";
|
|
|
3
3
|
import { Expression } from "@fibery/expression-utils/src/types";
|
|
4
4
|
import { Unit } from "@fibery/views/src/units/types";
|
|
5
5
|
//#region src/private/board.d.ts
|
|
6
|
-
declare const replaceIdsWithNamesInBoardView: (schema: Schema, view:
|
|
7
|
-
declare const replaceNamesWithIdsInBoardView: (schema: Schema, view:
|
|
8
|
-
declare const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView: (schema: Schema, view:
|
|
9
|
-
declare const fixUserSelectedUnitsInBoardView: (schema: Schema, view:
|
|
6
|
+
declare const replaceIdsWithNamesInBoardView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
7
|
+
declare const replaceNamesWithIdsInBoardView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
8
|
+
declare const deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView: <V extends ViewRecord>(schema: Schema, view: V, ensureAxisInvariant?: boolean) => V;
|
|
9
|
+
declare const fixUserSelectedUnitsInBoardView: <V extends ViewRecord>(schema: Schema, view: V, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
10
10
|
unitDefinitions: UnitDefinitions;
|
|
11
11
|
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
12
|
-
}) =>
|
|
13
|
-
declare const fixContextExpressionWithBrokenPath: (schema: Schema, view:
|
|
14
|
-
declare const collectGarbage: (view:
|
|
15
|
-
declare const enableHideWhenEmptyForCovers: (view:
|
|
16
|
-
declare const enableHideWhenEmptyForCheckedEditableUnits: (view:
|
|
12
|
+
}) => V;
|
|
13
|
+
declare const fixContextExpressionWithBrokenPath: <V extends ViewRecord>(schema: Schema, view: V, defaultContextExpression: Expression) => V;
|
|
14
|
+
declare const collectGarbage: <V extends ViewRecord>(view: V) => V;
|
|
15
|
+
declare const enableHideWhenEmptyForCovers: <V extends ViewRecord>(view: V) => V;
|
|
16
|
+
declare const enableHideWhenEmptyForCheckedEditableUnits: <V extends ViewRecord>(view: V) => V;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { collectGarbage, deleteExpressionWithNotFoundOrInvalidFieldsOrTypesInBoardView, enableHideWhenEmptyForCheckedEditableUnits, enableHideWhenEmptyForCovers, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInBoardView, replaceIdsWithNamesInBoardView, replaceNamesWithIdsInBoardView };
|
package/lib/private/board.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, resetContextExpressionIfBroken, skipRemove, visitContextExpression, visitViewUnit } from "./utils.js";
|
|
2
2
|
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
3
|
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
-
import immutableUpdate from "immutability-helper";
|
|
5
4
|
import get from "lodash/get.js";
|
|
6
5
|
import { isFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
7
6
|
import entries from "lodash/entries.js";
|
|
@@ -29,10 +28,13 @@ const visitQueryExpressionHolder = (queryHolder, visitor) => {
|
|
|
29
28
|
return queryHolder;
|
|
30
29
|
};
|
|
31
30
|
const visitAxisUnits = (axis, fromType, visitor) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
if (!fromType) return axis;
|
|
32
|
+
const nextAxis = {
|
|
33
|
+
...axis,
|
|
34
|
+
contextExpression: visitContextExpression(fromType, axis.contextExpression, visitor),
|
|
35
|
+
units: axis.units ? axis.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter(skipRemove) : void 0
|
|
36
|
+
};
|
|
37
|
+
return Object.entries(nextAxis).every(([key, value]) => Object.hasOwn(axis, key) && axis[key] === value) ? axis : nextAxis;
|
|
36
38
|
};
|
|
37
39
|
const visitAxis = (axis, visitor) => {
|
|
38
40
|
if (axis && Object.hasOwn(axis, "query")) {
|
|
@@ -42,7 +44,11 @@ const visitAxis = (axis, visitor) => {
|
|
|
42
44
|
return axisWithVisitedQuery;
|
|
43
45
|
}
|
|
44
46
|
if (axis && Object.hasOwn(axis, "enums")) {
|
|
45
|
-
const
|
|
47
|
+
const enumsNew = visitor.visitEnums(axis.enums);
|
|
48
|
+
const axisNew = enumsNew === axis.enums ? axis : {
|
|
49
|
+
...axis,
|
|
50
|
+
enums: enumsNew
|
|
51
|
+
};
|
|
46
52
|
const { enums } = axisNew;
|
|
47
53
|
return enums ? axisNew : null;
|
|
48
54
|
}
|
|
@@ -87,34 +93,43 @@ const ensureAxisAndItemExpressionInvariant = (view) => {
|
|
|
87
93
|
actions.forEach((action) => action());
|
|
88
94
|
return view;
|
|
89
95
|
};
|
|
90
|
-
const visitView = (view, visitor) =>
|
|
91
|
-
|
|
92
|
-
y: { $apply: (y) => visitAxis(y, visitor) },
|
|
93
|
-
items: { $apply: (items) => {
|
|
96
|
+
const visitView = (view, visitor) => {
|
|
97
|
+
const updateItems = (items) => {
|
|
94
98
|
if (!items) return [];
|
|
95
99
|
return items.map((item) => {
|
|
96
100
|
const fromType = get(item, ["query", "q/from"]);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
}
|
|
101
|
+
if (!fromType) return item;
|
|
102
|
+
const nextItem = {
|
|
103
|
+
...item,
|
|
104
|
+
coverExpression: item.coverExpression ? visitor.visitExpression(fromType, item.coverExpression) : item.coverExpression,
|
|
105
|
+
xExpression: item.xExpression ? visitor.visitExpression(fromType, item.xExpression) : item.xExpression,
|
|
106
|
+
yExpression: item.yExpression ? visitor.visitExpression(fromType, item.yExpression) : item.yExpression,
|
|
107
|
+
contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
|
|
108
|
+
query: item.query ? visitor.visitQueryExpression(item.query) : null,
|
|
109
|
+
filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
|
|
110
|
+
units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
|
|
111
|
+
colorCoding: item.colorCoding ? item.colorCoding.map((colorCoding) => ({
|
|
112
|
+
...colorCoding,
|
|
113
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
114
|
+
})).filter((colorCoding) => colorCoding.expression !== null) : void 0
|
|
115
|
+
};
|
|
116
|
+
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
112
117
|
}).filter((item) => {
|
|
113
118
|
const { query } = item;
|
|
114
119
|
return query ? item : null;
|
|
115
120
|
});
|
|
116
|
-
}
|
|
117
|
-
|
|
121
|
+
};
|
|
122
|
+
const meta = view["fibery/meta"];
|
|
123
|
+
return {
|
|
124
|
+
...view,
|
|
125
|
+
"fibery/meta": {
|
|
126
|
+
...meta,
|
|
127
|
+
x: visitAxis(meta.x, visitor),
|
|
128
|
+
y: visitAxis(meta.y, visitor),
|
|
129
|
+
items: updateItems(meta.items)
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
118
133
|
const replaceNamesWithIdsViewVisitor = (schema) => {
|
|
119
134
|
const visitor = {
|
|
120
135
|
visitQueryExpression: (queryExpression) => replaceNamesWithIdsInQueryExpression(schema, queryExpression),
|
|
@@ -214,13 +229,20 @@ const collectGarbage = (view) => {
|
|
|
214
229
|
});
|
|
215
230
|
};
|
|
216
231
|
const enableHideWhenEmptyForCovers = (view) => {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
const meta = view["fibery/meta"];
|
|
233
|
+
return {
|
|
234
|
+
...view,
|
|
235
|
+
"fibery/meta": {
|
|
236
|
+
...meta,
|
|
237
|
+
items: meta.items.map((item) => {
|
|
238
|
+
if (!item.coverExpression) return item;
|
|
239
|
+
return {
|
|
240
|
+
...item,
|
|
241
|
+
coverHideWhenEmpty: true
|
|
242
|
+
};
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
};
|
|
224
246
|
};
|
|
225
247
|
const enableHideWhenEmptyForCheckedEditableUnits = (view) => {
|
|
226
248
|
return visitView(view, {
|
|
@@ -3,15 +3,15 @@ import { FieldObject, Schema } from "@fibery/schema";
|
|
|
3
3
|
import { Expression } from "@fibery/expression-utils/src/types";
|
|
4
4
|
import { Unit } from "@fibery/views/src/units/types";
|
|
5
5
|
//#region src/private/calendar.d.ts
|
|
6
|
-
declare const replaceNamesWithIdsInCalendarView: (schema: Schema, view:
|
|
7
|
-
declare const replaceIdsWithNamesInCalendarView: (schema: Schema, view:
|
|
8
|
-
declare const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView: (schema: Schema, view:
|
|
9
|
-
declare const fixUserSelectedUnitsInCalendarView: (schema: Schema, view:
|
|
6
|
+
declare const replaceNamesWithIdsInCalendarView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
7
|
+
declare const replaceIdsWithNamesInCalendarView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
8
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInCalendarView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
9
|
+
declare const fixUserSelectedUnitsInCalendarView: <V extends ViewRecord>(schema: Schema, view: V, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
10
10
|
unitDefinitions: UnitDefinitions;
|
|
11
11
|
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
12
|
-
}) =>
|
|
13
|
-
declare const fixContextExpressionWithBrokenPath: (schema: Schema, view:
|
|
14
|
-
declare const collectGarbage: (view:
|
|
15
|
-
declare const enableHideWhenEmptyForCheckedUnits: (view:
|
|
12
|
+
}) => V;
|
|
13
|
+
declare const fixContextExpressionWithBrokenPath: <V extends ViewRecord>(schema: Schema, view: V, defaultContextExpression: Expression) => V;
|
|
14
|
+
declare const collectGarbage: <V extends ViewRecord>(view: V) => V;
|
|
15
|
+
declare const enableHideWhenEmptyForCheckedUnits: <V extends ViewRecord>(view: V) => V;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInCalendarView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInCalendarView, replaceIdsWithNamesInCalendarView, replaceNamesWithIdsInCalendarView };
|
package/lib/private/calendar.js
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, resetContextExpressionIfBroken, visitContextExpression, visitViewUnit } from "./utils.js";
|
|
2
2
|
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
3
|
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
-
import immutableUpdate from "immutability-helper";
|
|
5
4
|
import get from "lodash/get.js";
|
|
6
5
|
//#region src/private/calendar.ts
|
|
7
|
-
const visitView = (view, visitor) =>
|
|
8
|
-
const
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
const visitView = (view, visitor) => {
|
|
7
|
+
const meta = view["fibery/meta"];
|
|
8
|
+
return {
|
|
9
|
+
...view,
|
|
10
|
+
"fibery/meta": {
|
|
11
|
+
...meta,
|
|
12
|
+
items: meta.items.map((item) => {
|
|
13
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
14
|
+
if (!fromType) return item;
|
|
15
|
+
const nextItem = {
|
|
16
|
+
...item,
|
|
17
|
+
startExpression: item.startExpression ? visitor.visitExpression(fromType, item.startExpression) : item.startExpression,
|
|
18
|
+
endExpression: item.endExpression ? visitor.visitExpression(fromType, item.endExpression) : item.endExpression,
|
|
19
|
+
contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
|
|
20
|
+
query: item.query ? visitor.visitQueryExpression(item.query) : null,
|
|
21
|
+
filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
|
|
22
|
+
units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
|
|
23
|
+
colorCoding: item.colorCoding && item.colorCoding.map((colorCoding) => ({
|
|
24
|
+
...colorCoding,
|
|
25
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
26
|
+
})).filter((colorCoding) => colorCoding.expression !== null)
|
|
27
|
+
};
|
|
28
|
+
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
29
|
+
}).filter((item) => {
|
|
30
|
+
const { query } = item;
|
|
31
|
+
return query ? item : null;
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
27
36
|
const replaceNamesWithIdsInCalendarView = (schema, view) => {
|
|
28
37
|
return visitView(view, {
|
|
29
38
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
package/lib/private/feed.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import { FieldObject, Schema } from "@fibery/schema";
|
|
|
3
3
|
import { Expression } from "@fibery/expression-utils/src/types";
|
|
4
4
|
import { Unit } from "@fibery/views/src/units/types";
|
|
5
5
|
//#region src/private/feed.d.ts
|
|
6
|
-
declare const replaceNamesWithIdsInFeedView: (schema: Schema, view:
|
|
7
|
-
declare const replaceIdsWithNamesInFeedView: (schema: Schema, view:
|
|
8
|
-
declare const deleteExpressionWithNotFoundFieldsOrTypesInFeedView: (schema: Schema, view:
|
|
9
|
-
declare const fixUserSelectedUnitsInFeedView: (schema: Schema, view:
|
|
6
|
+
declare const replaceNamesWithIdsInFeedView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
7
|
+
declare const replaceIdsWithNamesInFeedView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
8
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInFeedView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
9
|
+
declare const fixUserSelectedUnitsInFeedView: <V extends ViewRecord>(schema: Schema, view: V, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
10
10
|
unitDefinitions: UnitDefinitions;
|
|
11
11
|
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
12
|
-
}) =>
|
|
13
|
-
declare const fixContextExpressionWithBrokenPath: (schema: Schema, view:
|
|
14
|
-
declare const collectGarbage: (view:
|
|
15
|
-
declare const enableHideWhenEmptyForCheckedUnits: (view:
|
|
12
|
+
}) => V;
|
|
13
|
+
declare const fixContextExpressionWithBrokenPath: <V extends ViewRecord>(schema: Schema, view: V, defaultContextExpression: Expression) => V;
|
|
14
|
+
declare const collectGarbage: <V extends ViewRecord>(view: V) => V;
|
|
15
|
+
declare const enableHideWhenEmptyForCheckedUnits: <V extends ViewRecord>(view: V) => V;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInFeedView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInFeedView, replaceIdsWithNamesInFeedView, replaceNamesWithIdsInFeedView };
|
package/lib/private/feed.js
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, resetContextExpressionIfBroken, visitContextExpression, visitViewUnit } from "./utils.js";
|
|
2
2
|
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
3
|
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
-
import immutableUpdate from "immutability-helper";
|
|
5
4
|
import get from "lodash/get.js";
|
|
6
5
|
//#region src/private/feed.ts
|
|
7
|
-
const visitView = (view, visitor) =>
|
|
8
|
-
const
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
const visitView = (view, visitor) => {
|
|
7
|
+
const meta = view["fibery/meta"];
|
|
8
|
+
return {
|
|
9
|
+
...view,
|
|
10
|
+
"fibery/meta": {
|
|
11
|
+
...meta,
|
|
12
|
+
items: meta.items.map((item) => {
|
|
13
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
14
|
+
if (!fromType) return item;
|
|
15
|
+
const nextItem = {
|
|
16
|
+
...item,
|
|
17
|
+
postExpression: item.postExpression ? visitor.visitExpression(fromType, item.postExpression) : item.postExpression,
|
|
18
|
+
contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
|
|
19
|
+
query: item.query ? visitor.visitQueryExpression(item.query) : null,
|
|
20
|
+
filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
|
|
21
|
+
units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
|
|
22
|
+
colorCoding: item.colorCoding && item.colorCoding.map((colorCoding) => ({
|
|
23
|
+
...colorCoding,
|
|
24
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
25
|
+
})).filter((colorCoding) => colorCoding.expression !== null)
|
|
26
|
+
};
|
|
27
|
+
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
28
|
+
}).filter((item) => {
|
|
29
|
+
const { query } = item;
|
|
30
|
+
return query ? item : null;
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
26
35
|
const replaceNamesWithIdsInFeedView = (schema, view) => {
|
|
27
36
|
return visitView(view, {
|
|
28
37
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
package/lib/private/form.d.ts
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
import { ViewRecord } from "./utils.js";
|
|
2
2
|
import { Schema } from "@fibery/schema";
|
|
3
3
|
//#region src/private/form.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
declare const replaceNamesWithIdsInFormView: (schema: Schema, view: ViewRecord) => {
|
|
9
|
-
"fibery/meta": {
|
|
10
|
-
typeId: string | undefined;
|
|
11
|
-
fields: FormField[] | undefined;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
declare const replaceIdsWithNamesInFormView: (schema: Schema, view: ViewRecord) => {
|
|
15
|
-
"fibery/meta": {
|
|
16
|
-
typeId: string | undefined;
|
|
17
|
-
fields: FormField[] | undefined;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
declare const deleteExpressionWithNotFoundFieldsOrTypesInFormView: (schema: Schema, view: ViewRecord) => {
|
|
21
|
-
"fibery/meta": {
|
|
22
|
-
typeId: string | undefined;
|
|
23
|
-
fields: FormField[] | undefined;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
4
|
+
declare const replaceNamesWithIdsInFormView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
5
|
+
declare const replaceIdsWithNamesInFormView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
6
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInFormView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
26
7
|
//#endregion
|
|
27
8
|
export { deleteExpressionWithNotFoundFieldsOrTypesInFormView, replaceIdsWithNamesInFormView, replaceNamesWithIdsInFormView };
|
package/lib/private/map.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import { FieldObject, Schema } from "@fibery/schema";
|
|
|
3
3
|
import { Expression } from "@fibery/expression-utils/src/types";
|
|
4
4
|
import { Unit } from "@fibery/views/src/units/types";
|
|
5
5
|
//#region src/private/map.d.ts
|
|
6
|
-
declare const replaceNamesWithIdsInMapView: (schema: Schema, view:
|
|
7
|
-
declare const replaceIdsWithNamesInMapView: (schema: Schema, view:
|
|
8
|
-
declare const deleteExpressionWithNotFoundFieldsOrTypesInMapView: (schema: Schema, view:
|
|
9
|
-
declare const fixUserSelectedUnitsInMapView: (schema: Schema, view:
|
|
6
|
+
declare const replaceNamesWithIdsInMapView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
7
|
+
declare const replaceIdsWithNamesInMapView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
8
|
+
declare const deleteExpressionWithNotFoundFieldsOrTypesInMapView: <V extends ViewRecord>(schema: Schema, view: V) => V;
|
|
9
|
+
declare const fixUserSelectedUnitsInMapView: <V extends ViewRecord>(schema: Schema, view: V, { unitDefinitions, getDefaultUnitTypeForField }: {
|
|
10
10
|
unitDefinitions: UnitDefinitions;
|
|
11
11
|
getDefaultUnitTypeForField: (fieldObject: FieldObject, allowedUnits: Unit[]) => string | undefined;
|
|
12
|
-
}) =>
|
|
13
|
-
declare const fixContextExpressionWithBrokenPath: (schema: Schema, view:
|
|
14
|
-
declare const collectGarbage: (view:
|
|
15
|
-
declare const enableHideWhenEmptyForCheckedUnits: (view:
|
|
12
|
+
}) => V;
|
|
13
|
+
declare const fixContextExpressionWithBrokenPath: <V extends ViewRecord>(schema: Schema, view: V, defaultContextExpression: Expression) => V;
|
|
14
|
+
declare const collectGarbage: <V extends ViewRecord>(view: V) => V;
|
|
15
|
+
declare const enableHideWhenEmptyForCheckedUnits: <V extends ViewRecord>(view: V) => V;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { collectGarbage, deleteExpressionWithNotFoundFieldsOrTypesInMapView, enableHideWhenEmptyForCheckedUnits, fixContextExpressionWithBrokenPath, fixUserSelectedUnitsInMapView, replaceIdsWithNamesInMapView, replaceNamesWithIdsInMapView };
|
package/lib/private/map.js
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
import { REMOVE, deleteExpressionWithNotFoundFieldsOrTypesInExpression, deleteExpressionWithNotFoundFieldsOrTypesInFilter, deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression, isUnitExpressionValid, replaceIdsWithNamesInExpression, replaceIdsWithNamesInFilter, replaceIdsWithNamesInQueryExpression, replaceNamesWithIdsInExpression, replaceNamesWithIdsInFilter, replaceNamesWithIdsInQueryExpression, resetContextExpressionIfBroken, visitContextExpression, visitViewUnit } from "./utils.js";
|
|
2
2
|
import { enableHideWhenEmptyForCheckedEditableUnit, fixViewUnit } from "./units.js";
|
|
3
3
|
import { truthy } from "@fibery/helpers/src/_";
|
|
4
|
-
import immutableUpdate from "immutability-helper";
|
|
5
4
|
import get from "lodash/get.js";
|
|
6
5
|
//#region src/private/map.ts
|
|
7
|
-
const visitView = (view, visitor) =>
|
|
8
|
-
const
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
const visitView = (view, visitor) => {
|
|
7
|
+
const meta = view["fibery/meta"];
|
|
8
|
+
return {
|
|
9
|
+
...view,
|
|
10
|
+
"fibery/meta": {
|
|
11
|
+
...meta,
|
|
12
|
+
items: meta.items.map((item) => {
|
|
13
|
+
const fromType = get(item, ["query", "q/from"]);
|
|
14
|
+
if (!fromType) return item;
|
|
15
|
+
const nextItem = {
|
|
16
|
+
...item,
|
|
17
|
+
locationExpression: item.locationExpression ? visitor.visitExpression(fromType, item.locationExpression) : item.locationExpression,
|
|
18
|
+
contextExpression: visitContextExpression(fromType, item.contextExpression, visitor),
|
|
19
|
+
query: item.query ? visitor.visitQueryExpression(item.query) : null,
|
|
20
|
+
filter: item.filter ? visitor.visitFilter(fromType, item.filter) : null,
|
|
21
|
+
units: item.units ? item.units.filter(truthy).map((unit) => visitViewUnit(fromType, unit, visitor)).filter(isUnitExpressionValid).map((unit, idx, units) => visitor.visitViewUnit ? visitor.visitViewUnit(fromType, unit, units) : unit).filter((unit) => unit !== REMOVE) : void 0,
|
|
22
|
+
colorCoding: item.colorCoding && item.colorCoding.map((colorCoding) => ({
|
|
23
|
+
...colorCoding,
|
|
24
|
+
expression: visitor.visitExpression(fromType, colorCoding.expression)
|
|
25
|
+
})).filter((colorCoding) => colorCoding.expression !== null)
|
|
26
|
+
};
|
|
27
|
+
return Object.entries(nextItem).every(([key, value]) => Object.hasOwn(item, key) && item[key] === value) ? item : nextItem;
|
|
28
|
+
}).filter((item) => {
|
|
29
|
+
const { query } = item;
|
|
30
|
+
return query ? item : null;
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
26
35
|
const replaceNamesWithIdsInMapView = (schema, view) => {
|
|
27
36
|
return visitView(view, {
|
|
28
37
|
visitQueryExpression: (query) => replaceNamesWithIdsInQueryExpression(schema, query),
|