@fibery/views 20.0.3 → 22.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/field-utils/avatar.js +2 -2
- package/lib/field-utils/icon.js +2 -2
- package/lib/field-utils/workflow.d.ts +8 -1
- package/lib/field-utils/workflow.js +7 -1
- package/lib/private/board.js +20 -18
- package/lib/private/form.js +10 -8
- package/lib/private/smart-folder.js +8 -12
- package/lib/private/timeline.js +16 -13
- package/lib/private/units.js +15 -5
- package/lib/private/utils.js +52 -64
- 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.js +2 -2
- package/lib/units/canvas/all-units-data-definitions.js +1 -1
- package/lib/units/gantt.js +1 -1
- package/lib/units/grid.js +3 -3
- package/lib/units/make-factory.js +10 -4
- package/package.json +7 -7
- package/lib/unit-utils/schema.d.ts +0 -7
- package/lib/unit-utils/schema.js +0 -9
|
@@ -4,7 +4,7 @@ import { toSelectMapClause } from "@fibery/query-utils/src/select";
|
|
|
4
4
|
const AVATAR_MIXIN_NAME = "avatar/avatar-mixin";
|
|
5
5
|
const AVATAR_EXTENSION_FIELD = "avatar/avatars";
|
|
6
6
|
const isAvatarExtensionEnabledType = (typeObject) => {
|
|
7
|
-
return typeObject && typeObject.installedMixins.has("avatar/avatar-mixin") && isAvatarExtensionField(typeObject.
|
|
7
|
+
return typeObject && typeObject.installedMixins.has("avatar/avatar-mixin") && isAvatarExtensionField(typeObject.getFieldObjectByNameOrThrow("avatar/avatars"));
|
|
8
8
|
};
|
|
9
9
|
const isAvatarExtensionField = (fieldObject) => {
|
|
10
10
|
return fieldObject.name === "avatar/avatars" && fieldObject.type === "fibery/file";
|
|
@@ -17,7 +17,7 @@ const getAvatarSelect = (fieldObject) => toSelectMapClause([
|
|
|
17
17
|
].filter(truthy));
|
|
18
18
|
const getAvatarSelectQuery = ({ typeObject }) => {
|
|
19
19
|
if (isAvatarExtensionEnabledType(typeObject)) {
|
|
20
|
-
const fieldObject = typeObject.
|
|
20
|
+
const fieldObject = typeObject.getFieldObjectByNameOrThrow(AVATAR_EXTENSION_FIELD);
|
|
21
21
|
const idField = fieldObject.typeObject.idField;
|
|
22
22
|
const typeTitleField = typeObject.titleField;
|
|
23
23
|
return {
|
package/lib/field-utils/icon.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
const ICON_MIXIN_NAME = "icon/icon-mixin";
|
|
3
3
|
const ICON_EXTENSION_FIELD = "icon/icon";
|
|
4
4
|
const isIconExtensionEnabledType = (typeObject) => {
|
|
5
|
-
return typeObject.installedMixins.has("icon/icon-mixin") && isIconExtensionField(typeObject.
|
|
5
|
+
return typeObject.installedMixins.has("icon/icon-mixin") && isIconExtensionField(typeObject.getFieldObjectByNameOrThrow("icon/icon"));
|
|
6
6
|
};
|
|
7
7
|
const isIconExtensionField = (fieldObject) => {
|
|
8
8
|
return fieldObject.name === "icon/icon" && fieldObject.type === "fibery/emoji";
|
|
9
9
|
};
|
|
10
10
|
const getEntityIconSelect = ({ typeObject }) => {
|
|
11
11
|
if (isIconExtensionEnabledType(typeObject)) {
|
|
12
|
-
const fieldObject = typeObject.
|
|
12
|
+
const fieldObject = typeObject.getFieldObjectByNameOrThrow(ICON_EXTENSION_FIELD);
|
|
13
13
|
return { [fieldObject.name]: fieldObject.name };
|
|
14
14
|
} else return {};
|
|
15
15
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypeObject } from "@fibery/schema";
|
|
2
2
|
import { FieldExpression } from "@fibery/expression-utils";
|
|
3
|
+
import { FiberyObject } from "@fibery/expression-utils/src/types";
|
|
3
4
|
//#region src/field-utils/workflow.d.ts
|
|
4
5
|
declare function isWorkflowType(typeObject: TypeObject): boolean;
|
|
5
6
|
declare const getWorkflowFieldObject: (typeObject: TypeObject) => import("@fibery/schema").FieldObject | undefined;
|
|
@@ -9,10 +10,16 @@ declare const getIsFinalStateSelect: ({ typeObject, contextPath }: {
|
|
|
9
10
|
}) => {
|
|
10
11
|
[x: string]: (string | (string | import("@fibery/expression-utils").MultiFieldAccess)[])[];
|
|
11
12
|
} | null;
|
|
13
|
+
/** Reads the final-state flag off an already-fetched object, keyed the same way the select writes it. */
|
|
14
|
+
declare const getIsInFinalState: ({ typeObject, object, contextPath }: {
|
|
15
|
+
typeObject: TypeObject;
|
|
16
|
+
object: FiberyObject;
|
|
17
|
+
contextPath?: FieldExpression;
|
|
18
|
+
}) => boolean | null | undefined;
|
|
12
19
|
declare function getWorkflowTypeSelect(typeObject: TypeObject): {
|
|
13
20
|
"workflow/Type": string[];
|
|
14
21
|
} | {
|
|
15
22
|
"workflow/Type"?: undefined;
|
|
16
23
|
};
|
|
17
24
|
//#endregion
|
|
18
|
-
export { getIsFinalStateSelect, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
|
25
|
+
export { getIsFinalStateSelect, getIsInFinalState, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
|
@@ -37,9 +37,15 @@ const getIsFinalStateSelect = ({ typeObject, contextPath = [] }) => {
|
|
|
37
37
|
const isFinalStateQueryPredicate = getIsFinalStateQueryPredicate(typeObject)(contextPath);
|
|
38
38
|
return isFinalStateQueryPredicate ? { [isFinalStateQueryPredicate.key]: isFinalStateQueryPredicate.expression } : null;
|
|
39
39
|
};
|
|
40
|
+
/** Reads the final-state flag off an already-fetched object, keyed the same way the select writes it. */
|
|
41
|
+
const getIsInFinalState = ({ typeObject, object, contextPath = [] }) => {
|
|
42
|
+
const isFinalStateQueryPredicate = getIsFinalStateQueryPredicate(typeObject)(contextPath);
|
|
43
|
+
if (!isFinalStateQueryPredicate) return null;
|
|
44
|
+
return object[isFinalStateQueryPredicate.key];
|
|
45
|
+
};
|
|
40
46
|
function getWorkflowTypeSelect(typeObject) {
|
|
41
47
|
if (isWorkflowType(typeObject)) return { "workflow/Type": ["workflow/Type"] };
|
|
42
48
|
return {};
|
|
43
49
|
}
|
|
44
50
|
//#endregion
|
|
45
|
-
export { getIsFinalStateSelect, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
|
51
|
+
export { getIsFinalStateSelect, getIsInFinalState, getWorkflowFieldObject, getWorkflowTypeSelect, isWorkflowType };
|
package/lib/private/board.js
CHANGED
|
@@ -121,12 +121,14 @@ const replaceNamesWithIdsViewVisitor = (schema) => {
|
|
|
121
121
|
visitFilter: (fromType, filter) => replaceNamesWithIdsInFilter(schema, fromType, filter),
|
|
122
122
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
123
123
|
visitEnums: (enums) => entries(enums).reduce((result, [type, queryHolder]) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
const typeObject = schema.getTypeObjectByName(type);
|
|
125
|
+
if (!typeObject) {
|
|
126
|
+
result[type] = queryHolder;
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
const fromType = get(queryHolder, ["query", "q/from"]);
|
|
130
|
+
const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
|
|
131
|
+
result[typeObject.id] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
130
132
|
return result;
|
|
131
133
|
}, {})
|
|
132
134
|
};
|
|
@@ -140,12 +142,14 @@ const replaceIdsWithNamesViewVisitor = (schema) => {
|
|
|
140
142
|
},
|
|
141
143
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
142
144
|
visitEnums: (enums) => entries(enums).reduce((result, [typeId, queryHolder]) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
const typeObject = schema.getTypeObjectById(typeId);
|
|
146
|
+
if (!typeObject) {
|
|
147
|
+
result[typeId] = queryHolder;
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
const fromType = get(queryHolder, ["query", "q/from"]);
|
|
151
|
+
const axisWithVisitedQuery = visitQueryExpressionHolder(queryHolder, visitor);
|
|
152
|
+
result[typeObject.name] = visitAxisUnits(axisWithVisitedQuery, fromType, visitor);
|
|
149
153
|
return result;
|
|
150
154
|
}, {})
|
|
151
155
|
};
|
|
@@ -158,12 +162,10 @@ const deleteExpressionWithNotFoundFieldsOrTypesViewVisitor = (schema) => {
|
|
|
158
162
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression),
|
|
159
163
|
visitEnums: (enums) => {
|
|
160
164
|
const enumsNew = entries(enums).reduce((result, [type, queryHolder]) => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
165
|
+
const typeObject = schema.getTypeObjectByName(type);
|
|
166
|
+
if (!typeObject) return result;
|
|
167
|
+
const queryHolderResult = visitQueryExpressionHolder(queryHolder, visitor);
|
|
168
|
+
if (queryHolderResult) result[typeObject.name] = queryHolderResult;
|
|
167
169
|
return result;
|
|
168
170
|
}, {});
|
|
169
171
|
return isEmpty(enumsNew) ? null : enumsNew;
|
package/lib/private/form.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
//#region src/private/form.ts
|
|
2
2
|
const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
3
3
|
const typeId = view["fibery/meta"]?.typeId;
|
|
4
|
-
const typeObject = typeId
|
|
4
|
+
const typeObject = typeId ? schema.getTypeObjectByName(typeId) : null;
|
|
5
5
|
const fields = view["fibery/meta"]?.fields;
|
|
6
6
|
const fieldsInIdsTerms = fields && fields.map((field) => {
|
|
7
|
-
|
|
7
|
+
const fieldObject = typeObject?.getFieldObjectByName(field.id);
|
|
8
|
+
if (!fieldObject) return field;
|
|
8
9
|
return {
|
|
9
10
|
...field,
|
|
10
|
-
id:
|
|
11
|
+
id: fieldObject.id
|
|
11
12
|
};
|
|
12
13
|
});
|
|
13
14
|
return {
|
|
@@ -21,13 +22,14 @@ const replaceNamesWithIdsInFormView = (schema, view) => {
|
|
|
21
22
|
};
|
|
22
23
|
const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
23
24
|
const typeId = view["fibery/meta"]?.typeId;
|
|
24
|
-
const typeObject = typeId
|
|
25
|
+
const typeObject = typeId ? schema.getTypeObjectById(typeId) : null;
|
|
25
26
|
const fields = view["fibery/meta"]?.fields;
|
|
26
27
|
const fieldsInNameTerms = fields && fields.map((field) => {
|
|
27
|
-
|
|
28
|
+
const fieldObject = typeObject?.getFieldObjectById(field.id);
|
|
29
|
+
if (!fieldObject) return field;
|
|
28
30
|
return {
|
|
29
31
|
...field,
|
|
30
|
-
id:
|
|
32
|
+
id: fieldObject.name
|
|
31
33
|
};
|
|
32
34
|
});
|
|
33
35
|
return {
|
|
@@ -41,9 +43,9 @@ const replaceIdsWithNamesInFormView = (schema, view) => {
|
|
|
41
43
|
};
|
|
42
44
|
const deleteExpressionWithNotFoundFieldsOrTypesInFormView = (schema, view) => {
|
|
43
45
|
const typeName = view["fibery/meta"]?.typeId;
|
|
44
|
-
const typeObject = typeName
|
|
46
|
+
const typeObject = typeName ? schema.getTypeObjectByName(typeName) : null;
|
|
45
47
|
const fields = view["fibery/meta"]?.fields;
|
|
46
|
-
const existingFields = fields && fields.filter((field) => typeObject &&
|
|
48
|
+
const existingFields = fields && fields.filter((field) => typeObject && Boolean(typeObject.getFieldObjectByName(field.id)));
|
|
47
49
|
return {
|
|
48
50
|
...view,
|
|
49
51
|
"fibery/meta": {
|
|
@@ -76,21 +76,17 @@ const deleteExpressionWithNotFoundFieldsOrTypesInGroupByExpression = (schema, gr
|
|
|
76
76
|
};
|
|
77
77
|
const replaceIdsWithNamesInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
78
78
|
if (!groupByExpression) return null;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} else return [index, { expression }];
|
|
84
|
-
}));
|
|
79
|
+
const typeObject = schema.getTypeObjectById(fromType);
|
|
80
|
+
if (!typeObject) return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => [index, { expression }]));
|
|
81
|
+
const visitor = replaceIdsWithNamesVisitor(typeObject);
|
|
82
|
+
return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => [index, { expression: visitor.visitExpression(expression) }]));
|
|
85
83
|
};
|
|
86
84
|
const replaceNamesWithIdsInGroupByExpression = (schema, groupByExpression, fromType) => {
|
|
87
85
|
if (!groupByExpression) return null;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} else return [index, { expression }];
|
|
93
|
-
}));
|
|
86
|
+
const typeObject = schema.getTypeObjectByName(fromType);
|
|
87
|
+
if (!typeObject) return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => [index, { expression }]));
|
|
88
|
+
const visitor = replaceNamesWithIdsVisitor(typeObject);
|
|
89
|
+
return Object.fromEntries(Object.entries(groupByExpression).map(([index, { expression }]) => [index, { expression: visitor.visitExpression(expression) }]));
|
|
94
90
|
};
|
|
95
91
|
const replaceNamesWithIdsInSmartFolder = (schema, smartFolder) => visitSmartFolder(smartFolder, {
|
|
96
92
|
visitQueryExpression: (query) => replaceNamesWithIdsInQueryExpression(schema, query),
|
package/lib/private/timeline.js
CHANGED
|
@@ -100,10 +100,12 @@ const replaceNamesWithIdsInTimelineView = (schema, view) => {
|
|
|
100
100
|
visitFilter: (fromType, expression) => replaceNamesWithIdsInFilter(schema, fromType, expression),
|
|
101
101
|
visitExpression: (fromType, expression) => replaceNamesWithIdsInExpression(schema, fromType, expression),
|
|
102
102
|
visitEnums: (enums) => entries(enums).reduce((result, [type, axis]) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
result[
|
|
106
|
-
|
|
103
|
+
const typeObject = schema.getTypeObjectByName(type);
|
|
104
|
+
if (!typeObject) {
|
|
105
|
+
result[type] = axis;
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
result[typeObject.id] = visitAxisSingle(axis, visitor);
|
|
107
109
|
return result;
|
|
108
110
|
}, {}),
|
|
109
111
|
visitGroupByExpression: (groupBy, fromType) => replaceNamesWithIdsInGroupByExpression(schema, groupBy, fromType)
|
|
@@ -116,10 +118,12 @@ const replaceIdsWithNamesInTimelineView = (schema, view) => {
|
|
|
116
118
|
visitFilter: (fromType, expression) => replaceIdsWithNamesInFilter(schema, fromType, expression),
|
|
117
119
|
visitExpression: (fromType, expression) => replaceIdsWithNamesInExpression(schema, fromType, expression),
|
|
118
120
|
visitEnums: (enums) => entries(enums).reduce((result, [typeId, axis]) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
result[
|
|
122
|
-
|
|
121
|
+
const typeObject = schema.getTypeObjectById(typeId);
|
|
122
|
+
if (!typeObject) {
|
|
123
|
+
result[typeId] = axis;
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
result[typeObject.name] = visitAxisSingle(axis, visitor);
|
|
123
127
|
return result;
|
|
124
128
|
}, {}),
|
|
125
129
|
visitGroupByExpression: (groupBy, fromType) => replaceIdsWithNamesInGroupByExpression(schema, groupBy, fromType)
|
|
@@ -166,11 +170,10 @@ const deleteExpressionWithNotFoundFieldsOrTypesInTimelineView = (schema, view, e
|
|
|
166
170
|
visitExpression: (fromType, expression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression),
|
|
167
171
|
visitEnums: (enums) => {
|
|
168
172
|
const enumsNew = entries(enums).reduce((result, [type, axis]) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
173
|
+
const typeObject = schema.getTypeObjectByName(type);
|
|
174
|
+
if (!typeObject) return result;
|
|
175
|
+
const axisResult = visitAxisSingle(axis, visitor);
|
|
176
|
+
if (axisResult) result[typeObject.name] = axisResult;
|
|
174
177
|
return result;
|
|
175
178
|
}, {});
|
|
176
179
|
return isEmpty(enumsNew) ? null : enumsNew;
|
package/lib/private/units.js
CHANGED
|
@@ -2,12 +2,12 @@ import { AVATAR_EXTENSION_FIELD } from "../field-utils/avatar.js";
|
|
|
2
2
|
import { REMOVE } from "./utils.js";
|
|
3
3
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
4
4
|
//#region src/private/units.ts
|
|
5
|
-
const getField = (schema, fromType, field) =>
|
|
5
|
+
const getField = (schema, fromType, field) => schema.getTypeObjectByName(fromType)?.getFieldObjectByName(field) ?? null;
|
|
6
6
|
const getFieldType = (schema, fromType, field) => getField(schema, fromType, field)?.type;
|
|
7
7
|
const getFieldMeta = (schema, fromType, field) => getField(schema, fromType, field)?.rawMeta;
|
|
8
8
|
const getFieldByExpression = (schema, fromType, expression) => {
|
|
9
9
|
let currentType = fromType;
|
|
10
|
-
let fieldObject;
|
|
10
|
+
let fieldObject = null;
|
|
11
11
|
for (const part of expression) {
|
|
12
12
|
fieldObject = getField(schema, currentType, part);
|
|
13
13
|
if (!fieldObject) return null;
|
|
@@ -53,7 +53,7 @@ const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefaul
|
|
|
53
53
|
type: "email"
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
if (unit.type === "text" || unit.type === "email" || unit.type === "phone" || unit.type === "url") {
|
|
56
|
+
if ((unit.type === "text" || unit.type === "email" || unit.type === "phone" || unit.type === "url") && "expression" in unit && unit.expression) {
|
|
57
57
|
const [field] = unit.expression;
|
|
58
58
|
if (getFieldType(schema, fromType, field) === "fibery/text") return {
|
|
59
59
|
...unit,
|
|
@@ -61,6 +61,16 @@ const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefaul
|
|
|
61
61
|
type: getUnitTypeForTextField(getFieldMeta(schema, fromType, field))
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
if (unit.type === "icon-button" && "expression" in unit && unit.expression) {
|
|
65
|
+
const [field] = unit.expression;
|
|
66
|
+
if (getFieldType(schema, fromType, field) === "fibery/text") {
|
|
67
|
+
if (getUnitTypeForTextField(getFieldMeta(schema, fromType, field)) === "text") return {
|
|
68
|
+
...unit,
|
|
69
|
+
kind: unit.kind || "field",
|
|
70
|
+
type: "text"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
64
74
|
if (unit.type === "files-collection") {
|
|
65
75
|
const [field] = unit.expression;
|
|
66
76
|
if (getFieldType(schema, fromType, field) === "fibery/file") return {
|
|
@@ -71,7 +81,7 @@ const migrateUnit = (schema, fromType, unit, units, opts = migrateUnitOptsDefaul
|
|
|
71
81
|
}
|
|
72
82
|
if (unit.type === "avatar") {
|
|
73
83
|
if (unit.kind === "db" || !unit.expression) {
|
|
74
|
-
const isAvatarExntensionEnabled = schema.
|
|
84
|
+
const isAvatarExntensionEnabled = schema.getTypeObjectByName(fromType)?.installedMixins.has("avatar/avatar-mixin");
|
|
75
85
|
const hasAvatarExntensionField = getFieldType(schema, fromType, AVATAR_EXTENSION_FIELD) === "fibery/file";
|
|
76
86
|
if (isAvatarExntensionEnabled && hasAvatarExntensionField) return {
|
|
77
87
|
...unit,
|
|
@@ -100,7 +110,7 @@ const fixViewUnit = (schema, fromType, unit, units, { unitDefinitions, getDefaul
|
|
|
100
110
|
const expression = expressionFrom(unit) ?? [];
|
|
101
111
|
const fieldObject = getFieldByExpression(schema, fromType, expression);
|
|
102
112
|
if (fieldObject) {
|
|
103
|
-
const typeObject = schema.
|
|
113
|
+
const typeObject = schema.getTypeObjectByName(fromType);
|
|
104
114
|
const parentFieldObjects = typeObject && expression.length > 1 ? getFieldObjectsByFieldExpression({
|
|
105
115
|
typeObject,
|
|
106
116
|
expression
|
package/lib/private/utils.js
CHANGED
|
@@ -30,29 +30,24 @@ const deleteExpressionWithNotFoundFieldsOrTypesInFilter = (schema, fromType, fil
|
|
|
30
30
|
};
|
|
31
31
|
const deleteExpressionWithNotFoundFieldsOrTypesInQueryExpression = (schema, queryExpression) => {
|
|
32
32
|
const { "q/from": fromExpression, "q/where": whereExpression, "q/order-by": orderByExpression } = queryExpression;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
33
|
+
const typeObject = schema.getTypeObjectByName(fromExpression);
|
|
34
|
+
if (!typeObject) return null;
|
|
35
|
+
const visitor = deleteExpressionsWithNotFoundFieldsVisitor(typeObject);
|
|
36
|
+
return pickBy({
|
|
37
|
+
...queryExpression,
|
|
38
|
+
...whereExpression ? { "q/where": visitor.visitExpression(whereExpression) } : null,
|
|
39
|
+
...orderByExpression ? { "q/order-by": visitor.visitOrderByExpression(orderByExpression) } : null
|
|
40
|
+
});
|
|
42
41
|
};
|
|
43
42
|
const replaceNamesWithIdsInExpression = (schema, fromType, expression) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
return expression;
|
|
43
|
+
const typeObject = schema.getTypeObjectByName(fromType);
|
|
44
|
+
if (!typeObject) return expression;
|
|
45
|
+
return replaceNamesWithIdsVisitor(typeObject).visitExpression(expression);
|
|
49
46
|
};
|
|
50
47
|
const replaceIdsWithNamesInExpression = (schema, fromTypeId, expression) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
return expression;
|
|
48
|
+
const typeObject = schema.getTypeObjectById(fromTypeId);
|
|
49
|
+
if (!typeObject) return expression;
|
|
50
|
+
return replaceIdsWithNamesVisitor(typeObject).visitExpression(expression);
|
|
56
51
|
};
|
|
57
52
|
const visitViewUnit = (fromType, unit, visitor) => {
|
|
58
53
|
if (unit.kind === "user-button") return unit;
|
|
@@ -69,16 +64,15 @@ const visitContextExpression = (fromType, contextExpression, visitor) => {
|
|
|
69
64
|
};
|
|
70
65
|
const replaceIdsWithNamesInQueryExpression = (schema, queryExpression) => {
|
|
71
66
|
const { "q/from": fromExpression, "q/where": whereExpression, "q/order-by": orderByExpression } = queryExpression;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return queryExpression;
|
|
67
|
+
const typeObject = schema.getTypeObjectById(fromExpression);
|
|
68
|
+
if (!typeObject) return queryExpression;
|
|
69
|
+
const visitor = replaceIdsWithNamesVisitor(typeObject);
|
|
70
|
+
return {
|
|
71
|
+
...queryExpression,
|
|
72
|
+
"q/from": typeObject.name,
|
|
73
|
+
...whereExpression ? { "q/where": visitor.visitExpression(whereExpression) } : null,
|
|
74
|
+
...orderByExpression ? { "q/order-by": visitor.visitOrderByExpression(orderByExpression) } : null
|
|
75
|
+
};
|
|
82
76
|
};
|
|
83
77
|
function visitFilterGroup(filter, visitExpression, _type) {
|
|
84
78
|
if (filter.kind !== "group") return null;
|
|
@@ -99,38 +93,33 @@ function visitFilterGroup(filter, visitExpression, _type) {
|
|
|
99
93
|
};
|
|
100
94
|
}
|
|
101
95
|
const replaceIdsWithNamesInFilter = (schema, fromType, filter) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return filter;
|
|
96
|
+
const typeObject = schema.getTypeObjectById(fromType);
|
|
97
|
+
if (!typeObject) return filter;
|
|
98
|
+
const visitor = replaceIdsWithNamesVisitor(typeObject);
|
|
99
|
+
return filter ? visitFilterGroup(filter, (expression) => visitor.visitExpression(expression), "ids") : null;
|
|
107
100
|
};
|
|
108
101
|
const replaceNamesWithIdsInFilter = (schema, fromType, filter) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return filter;
|
|
102
|
+
const typeObject = schema.getTypeObjectByName(fromType);
|
|
103
|
+
if (!typeObject) return filter;
|
|
104
|
+
const visitor = replaceNamesWithIdsVisitor(typeObject);
|
|
105
|
+
return filter ? visitFilterGroup(filter, (expression) => visitor.visitExpression(expression), "names") : null;
|
|
114
106
|
};
|
|
115
107
|
const replaceNamesWithIdsInQueryExpression = (schema, queryExpression) => {
|
|
116
108
|
const { "q/from": fromExpression, "q/where": whereExpression, "q/order-by": orderByExpression } = queryExpression;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return queryExpression;
|
|
109
|
+
const typeObject = schema.getTypeObjectByName(fromExpression);
|
|
110
|
+
if (!typeObject) return queryExpression;
|
|
111
|
+
const visitor = replaceNamesWithIdsVisitor(typeObject);
|
|
112
|
+
return {
|
|
113
|
+
...queryExpression,
|
|
114
|
+
"q/from": typeObject.id,
|
|
115
|
+
...whereExpression ? { "q/where": visitor.visitExpression(whereExpression) } : null,
|
|
116
|
+
...orderByExpression ? { "q/order-by": visitor.visitOrderByExpression(orderByExpression) } : null
|
|
117
|
+
};
|
|
127
118
|
};
|
|
128
119
|
const deleteExpressionWithNotFoundFieldsOrTypesInExpression = (schema, fromType, expression) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
120
|
+
const typeObject = schema.getTypeObjectByName(fromType);
|
|
121
|
+
if (!typeObject) return null;
|
|
122
|
+
return deleteExpressionsWithNotFoundFieldsVisitor(typeObject).visitExpression(expression);
|
|
134
123
|
};
|
|
135
124
|
const resetContextExpressionIfBroken = (schema, fromType, expression, defaultExpression) => deleteExpressionWithNotFoundFieldsOrTypesInExpression(schema, fromType, expression) || defaultExpression;
|
|
136
125
|
const isUnitExpressionValid = (unit) => {
|
|
@@ -142,12 +131,10 @@ const isUnitExpressionValid = (unit) => {
|
|
|
142
131
|
};
|
|
143
132
|
const getFieldObjectsById = (smartFolder, schema) => {
|
|
144
133
|
return smartFolder["fibery/meta"].items.map((item) => item.query["q/from"]).reduce((acc, type) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
...fieldObjects
|
|
150
|
-
};
|
|
134
|
+
const typeObject = schema.getTypeObjectById(type);
|
|
135
|
+
if (!typeObject) return acc;
|
|
136
|
+
for (const fieldObject of typeObject.fieldObjects) acc[fieldObject.id] = fieldObject;
|
|
137
|
+
return acc;
|
|
151
138
|
}, {});
|
|
152
139
|
};
|
|
153
140
|
const replaceIdsWithNamesInUnitGroupKey = (unitGroupKey, fieldObjectsById) => {
|
|
@@ -169,10 +156,11 @@ const replaceNamesWithIdsInUnitGroupKey = (unitGroupKey, schema) => {
|
|
|
169
156
|
if (!name) return keyPart;
|
|
170
157
|
const [type, field] = name.split(":");
|
|
171
158
|
if (!field) return keyPart;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return
|
|
159
|
+
const typeObject = schema.getTypeObjectByName(type);
|
|
160
|
+
if (!typeObject) return keyPart;
|
|
161
|
+
const fieldObject = typeObject.getFieldObjectByName(field);
|
|
162
|
+
if (!fieldObject) return keyPart;
|
|
163
|
+
return `${unitType}_${fieldObject.id}`;
|
|
176
164
|
}).filter(Boolean).join("|");
|
|
177
165
|
};
|
|
178
166
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getEntityLinksListSelect } from "../field-utils/back-references.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { getFieldObjectByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
7
7
|
import { calculateDefaultOrderBy } from "@fibery/query-utils/src/query";
|
|
8
8
|
//#region src/unit-definitions/back-references-list.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/bool-checkbox.ts
|
|
7
7
|
const type = "bool-checkbox";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/bool.ts
|
|
7
7
|
const type = "bool";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
-
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
3
2
|
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
|
+
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
4
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
5
5
|
//#region src/unit-definitions/color-input.ts
|
|
6
6
|
const type = "color-input";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getQuerySelect } from "../field-utils/comments.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { getFieldObjectByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
7
7
|
//#region src/unit-definitions/comments-list.ts
|
|
8
8
|
const type = "comments-list";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getDateRangeExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/date-range-combobox.ts
|
|
7
7
|
const type = "date-range-combobox";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getDateRangeExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/date-range.ts
|
|
7
7
|
const type = "date-range";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/date-time-combobox.ts
|
|
7
7
|
const type = "date-time-combobox";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/date.ts
|
|
7
7
|
const type = "date";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getFilesSelect } from "../field-utils/file.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { wrapNormalizedInExpression } from "../unit-utils/wrap-normalized-in-expression.js";
|
|
7
7
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
8
8
|
import { denormalizeSelect, normalizeSelect } from "@fibery/query-utils/src/select";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
-
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
3
2
|
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
|
+
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
4
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
5
5
|
//#region src/unit-definitions/icon-button.ts
|
|
6
6
|
const type = "icon-button";
|
|
@@ -3,12 +3,11 @@ import { AvatarCollection } from "./avatar-collection.js";
|
|
|
3
3
|
import { Avatar } from "./avatar.js";
|
|
4
4
|
import { Bool } from "./bool.js";
|
|
5
5
|
import { CollectionCount } from "./collection-count.js";
|
|
6
|
-
import { DateRange } from "./date-range.js";
|
|
7
6
|
import { Date } from "./date.js";
|
|
7
|
+
import { DateRange } from "./date-range.js";
|
|
8
8
|
import { Text } from "./text.js";
|
|
9
9
|
import { Email } from "./email.js";
|
|
10
10
|
import { Emoji } from "./emoji.js";
|
|
11
|
-
import { FileCollectionCount } from "./file-collection-count.js";
|
|
12
11
|
import { IconButton } from "./icon-button.js";
|
|
13
12
|
import { Id } from "./id.js";
|
|
14
13
|
import { Location } from "./location.js";
|
|
@@ -26,6 +25,7 @@ import { TypeIcon } from "./type-icon.js";
|
|
|
26
25
|
import { Url } from "./url.js";
|
|
27
26
|
import { UserButton } from "./user-button.js";
|
|
28
27
|
import { UserRole } from "./user-role.js";
|
|
28
|
+
import { FileCollectionCount } from "./file-collection-count.js";
|
|
29
29
|
//#region src/unit-definitions/index.ts
|
|
30
30
|
var unit_definitions_exports = /* @__PURE__ */ __exportAll({
|
|
31
31
|
Avatar: () => Avatar,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
-
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
3
2
|
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
|
+
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
4
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
5
5
|
//#region src/unit-definitions/json-input.ts
|
|
6
6
|
const type = "json-input";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getNumberExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/number-input.tsx
|
|
7
7
|
const type = "number-input";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
//#region src/unit-definitions/reference-collection-combobox.ts
|
|
6
6
|
const type = "reference-collection-combobox";
|
|
7
7
|
const ReferenceCollectionCombobox = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getReferenceCollectionExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
//#region src/unit-definitions/reference-collection-list.tsx
|
|
6
6
|
const type = "reference-collection-list";
|
|
7
7
|
const ReferenceCollectionList = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getReferenceCollectionExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
//#region src/unit-definitions/reference-collection-view.tsx
|
|
6
6
|
const type = "reference-collection-view";
|
|
7
7
|
const ReferenceCollectionView = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { REFERENCE_COLLECTION_LIMIT, calculateReferenceCollectionQuery } from "../field-utils/reference-collection.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getReferenceCollectionExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
import { getFieldObjectsByFieldExpression } from "@fibery/expression-utils/src/utils";
|
|
7
7
|
//#region src/unit-definitions/reference-collection.ts
|
|
8
8
|
const type = "reference-collection";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getReferenceExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
//#region src/unit-definitions/reference-combobox.ts
|
|
6
6
|
const type = "reference-combobox";
|
|
7
7
|
const ReferenceCombobox = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getRichTextQuerySelect } from "../field-utils/rich-text.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
3
4
|
import { getSnippetExportValue } from "../unit-utils/get-export-value.js";
|
|
4
5
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
5
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
6
6
|
//#region src/unit-definitions/rich-text-document.ts
|
|
7
7
|
const type = "rich-text-document";
|
|
8
8
|
const RichTextDocument = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/text-input.tsx
|
|
7
7
|
const type = "text-input";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
2
|
+
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
2
3
|
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
3
4
|
import { getFieldLabel } from "../unit-utils/get-field-label.js";
|
|
4
|
-
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/text.ts
|
|
7
7
|
const type = "text";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getUserRoleByKey } from "../field-utils/user-role.js";
|
|
2
2
|
import { calculateUnitExpressionErrors, makeUnitMethod } from "../unit-utils/common.js";
|
|
3
|
-
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
4
3
|
import { canEditField } from "../unit-utils/can-edit-field.js";
|
|
4
|
+
import { getExportValue } from "../unit-utils/get-export-value.js";
|
|
5
5
|
import { getQuerySelectForExpression } from "@fibery/query-utils/src/query";
|
|
6
6
|
//#region src/unit-definitions/user-role.ts
|
|
7
7
|
const type = "user-role";
|
package/lib/unit-utils/enums.js
CHANGED
|
@@ -12,8 +12,8 @@ const getWorkflowQuery = ({ typeObject }) => {
|
|
|
12
12
|
const getEnumIconColorQuery = ({ typeObject, contextPath = [] }) => {
|
|
13
13
|
if (!typeObject.isEnum) return {};
|
|
14
14
|
const select = { "?accessToIcon": ["q/access?", [...contextPath, "enum/icon"]] };
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
15
|
+
if (typeObject.getFieldObjectByName("enum/color")) select["enum/color"] = "enum/color";
|
|
16
|
+
if (typeObject.getFieldObjectByName("enum/icon")) select["enum/icon"] = "enum/icon";
|
|
17
17
|
return select;
|
|
18
18
|
};
|
|
19
19
|
const getEnumNumberFieldQuery = (typeObject) => {
|
|
@@ -2,8 +2,8 @@ import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { Avatar } from "../../unit-definitions/avatar.js";
|
|
3
3
|
import { Bool } from "../../unit-definitions/bool.js";
|
|
4
4
|
import { CollectionCount } from "../../unit-definitions/collection-count.js";
|
|
5
|
-
import { DateRange } from "../../unit-definitions/date-range.js";
|
|
6
5
|
import { Date } from "../../unit-definitions/date.js";
|
|
6
|
+
import { DateRange } from "../../unit-definitions/date-range.js";
|
|
7
7
|
import { Text } from "../../unit-definitions/text.js";
|
|
8
8
|
import { Email } from "../../unit-definitions/email.js";
|
|
9
9
|
import { Emoji } from "../../unit-definitions/emoji.js";
|
package/lib/units/gantt.js
CHANGED
|
@@ -22,7 +22,7 @@ const getDefaultUnits = () => {
|
|
|
22
22
|
};
|
|
23
23
|
const getDefaultLaneUnits = (typeObject) => {
|
|
24
24
|
const { Title, Avatar, Emoji, TypeBadgeAbbr } = unit_definitions_exports;
|
|
25
|
-
return [Title && Title.makeUnit(), typeObject && isAvatarExtensionEnabledType(typeObject) && Avatar && Avatar.makeUnit() || typeObject.isEnum &&
|
|
25
|
+
return [Title && Title.makeUnit(), typeObject && isAvatarExtensionEnabledType(typeObject) && Avatar && Avatar.makeUnit() || typeObject.isEnum && Boolean(typeObject.getFieldObjectByName("enum/icon")) && Emoji && Emoji.makeUnit({ expression: ["enum/icon"] }) || TypeBadgeAbbr && TypeBadgeAbbr.makeUnit()].filter(Boolean);
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
28
28
|
export { gantt_exports, getCardUnitsSelect, getDefaultLaneUnits, getDefaultUnits, getHardcodedUnitsForView, getTypeUnits, getUnitLabel, getUnitName, getUnitsForField, getUnitsForType, getUnitsForTypePerField };
|
package/lib/units/grid.js
CHANGED
|
@@ -3,13 +3,11 @@ import { AvatarCollection } from "../unit-definitions/avatar-collection.js";
|
|
|
3
3
|
import { Avatar } from "../unit-definitions/avatar.js";
|
|
4
4
|
import { Bool } from "../unit-definitions/bool.js";
|
|
5
5
|
import { CollectionCount } from "../unit-definitions/collection-count.js";
|
|
6
|
-
import { DateRange } from "../unit-definitions/date-range.js";
|
|
7
6
|
import { Date } from "../unit-definitions/date.js";
|
|
7
|
+
import { DateRange } from "../unit-definitions/date-range.js";
|
|
8
8
|
import { Text } from "../unit-definitions/text.js";
|
|
9
9
|
import { Email } from "../unit-definitions/email.js";
|
|
10
10
|
import { Emoji } from "../unit-definitions/emoji.js";
|
|
11
|
-
import { FileCollectionCount } from "../unit-definitions/file-collection-count.js";
|
|
12
|
-
import { FilesGallery } from "../unit-definitions/files-gallery.js";
|
|
13
11
|
import { IconButton } from "../unit-definitions/icon-button.js";
|
|
14
12
|
import { Id } from "../unit-definitions/id.js";
|
|
15
13
|
import { Location } from "../unit-definitions/location.js";
|
|
@@ -27,7 +25,9 @@ import { TypeIcon } from "../unit-definitions/type-icon.js";
|
|
|
27
25
|
import { Url } from "../unit-definitions/url.js";
|
|
28
26
|
import { UserButton } from "../unit-definitions/user-button.js";
|
|
29
27
|
import { UserRole } from "../unit-definitions/user-role.js";
|
|
28
|
+
import { FileCollectionCount } from "../unit-definitions/file-collection-count.js";
|
|
30
29
|
import { makeUnitDefinitionsFactory } from "./make-factory.js";
|
|
30
|
+
import { FilesGallery } from "../unit-definitions/files-gallery.js";
|
|
31
31
|
import { FileReference } from "@fibery/views/src/unit-definitions/file-reference";
|
|
32
32
|
//#region src/units/grid.ts
|
|
33
33
|
var grid_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -211,14 +211,20 @@ const makeUnitDefinitionsFactory = (allUnitDefinitions) => {
|
|
|
211
211
|
}).sort((a, b) => a - b)[0];
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
+
const hardcodedFieldNames = [
|
|
215
|
+
"fibery/creation-date",
|
|
216
|
+
"fibery/container-app",
|
|
217
|
+
"fibery/container-entity-id",
|
|
218
|
+
"fibery/container-entity-type"
|
|
219
|
+
];
|
|
214
220
|
const getHardcodedUnitsForView = (typeObject) => {
|
|
215
221
|
return [
|
|
216
222
|
TypeIcon && TypeIcon.makeUnit(),
|
|
217
223
|
Title && Title.makeUnit(),
|
|
218
|
-
...
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
...hardcodedFieldNames.flatMap((name) => {
|
|
225
|
+
const fieldObject = typeObject.getFieldObjectByName(name);
|
|
226
|
+
return fieldObject ? getUnitsForField(fieldObject) : [];
|
|
227
|
+
})
|
|
222
228
|
].filter(Boolean);
|
|
223
229
|
};
|
|
224
230
|
const unitDefinitionsByTypeLookup = mapValues(groupBy(allUnitDefinitions, (x) => x.type), (value) => single(value));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/views",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"description": "Operations on view objects",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Fibery",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"date-fns": "2.29.2",
|
|
34
34
|
"lodash": "4.17.21",
|
|
35
35
|
"moment": "2.29.4",
|
|
36
|
-
"@fibery/expression-utils": "
|
|
37
|
-
"@fibery/
|
|
38
|
-
"@fibery/
|
|
39
|
-
"@fibery/schema": "
|
|
36
|
+
"@fibery/expression-utils": "12.0.0",
|
|
37
|
+
"@fibery/helpers": "3.3.1",
|
|
38
|
+
"@fibery/query-utils": "4.0.0",
|
|
39
|
+
"@fibery/schema": "11.1.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@fibery/expression-utils": "^
|
|
43
|
-
"@fibery/schema": "^
|
|
42
|
+
"@fibery/expression-utils": "^12.0.0",
|
|
43
|
+
"@fibery/schema": "^11.1.0",
|
|
44
44
|
"immutability-helper": "^2.4.0",
|
|
45
45
|
"lodash": "4.17.21"
|
|
46
46
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Schema } from "@fibery/schema";
|
|
2
|
-
//#region src/unit-utils/schema.d.ts
|
|
3
|
-
declare const extractTypePart: (type: string) => string;
|
|
4
|
-
declare const extractTypeNamespacePart: (type: string) => string;
|
|
5
|
-
declare const getTypeById: (schema: Schema, id: string) => import("@fibery/schema").TypeObject | undefined;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { extractTypeNamespacePart, extractTypePart, getTypeById };
|
package/lib/unit-utils/schema.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { parseType } from "@fibery/schema";
|
|
2
|
-
//#region src/unit-utils/schema.ts
|
|
3
|
-
const extractTypePart = (type) => parseType(type).name;
|
|
4
|
-
const extractTypeNamespacePart = (type) => parseType(type).namespace;
|
|
5
|
-
const getTypeById = (schema, id) => {
|
|
6
|
-
return Object.hasOwn(schema.typeObjectsById, id) ? schema.typeObjectsById[id] : void 0;
|
|
7
|
-
};
|
|
8
|
-
//#endregion
|
|
9
|
-
export { extractTypeNamespacePart, extractTypePart, getTypeById };
|