@tachybase/module-ui-schema 0.23.20 → 0.23.35
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/dist/externalVersion.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "0.23.
|
|
3
|
-
"@tachybase/database": "0.23.
|
|
4
|
-
"@tachybase/cache": "0.23.
|
|
5
|
-
"@tachybase/utils": "0.23.
|
|
2
|
+
"@tachybase/client": "0.23.35",
|
|
3
|
+
"@tachybase/database": "0.23.35",
|
|
4
|
+
"@tachybase/cache": "0.23.35",
|
|
5
|
+
"@tachybase/utils": "0.23.35",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
|
-
"@tachybase/server": "0.23.
|
|
8
|
-
"@tachybase/actions": "0.23.
|
|
9
|
-
"@tachybase/resourcer": "0.23.
|
|
7
|
+
"@tachybase/server": "0.23.35",
|
|
8
|
+
"@tachybase/actions": "0.23.35",
|
|
9
|
+
"@tachybase/resourcer": "0.23.35",
|
|
10
10
|
"sequelize": "6.37.5"
|
|
11
11
|
};
|
|
@@ -55,6 +55,8 @@ export declare class UiSchemaRepository extends Repository {
|
|
|
55
55
|
insert(schema: any, options?: Transactionable): Promise<any>;
|
|
56
56
|
insertNewSchema(schema: any, options?: Transactionable & {
|
|
57
57
|
returnNode?: boolean;
|
|
58
|
+
position?: string;
|
|
59
|
+
target?: string;
|
|
58
60
|
}): Promise<any>;
|
|
59
61
|
insertSingleNode(schema: SchemaNode, options: Transactionable & removeParentOptions): Promise<any>;
|
|
60
62
|
protected updateNode(uid: string, schema: any, transaction?: Transaction): Promise<void>;
|
|
@@ -235,12 +235,12 @@ const _UiSchemaRepository = class _UiSchemaRepository extends (_a = import_datab
|
|
|
235
235
|
return schema;
|
|
236
236
|
};
|
|
237
237
|
const buildTree = (rootNode) => {
|
|
238
|
-
const children = nodes.filter((node) => node.parent
|
|
238
|
+
const children = nodes.filter((node) => node.parent === rootNode["x-uid"]);
|
|
239
239
|
if (children.length > 0) {
|
|
240
240
|
const childrenGroupByType = import_lodash.default.groupBy(children, "type");
|
|
241
241
|
for (const childType of Object.keys(childrenGroupByType)) {
|
|
242
242
|
const properties = childrenGroupByType[childType].map((child) => buildTree(child)).sort((a, b) => a["x-index"] - b["x-index"]);
|
|
243
|
-
rootNode[childType] = childType
|
|
243
|
+
rootNode[childType] = childType === "items" ? properties.length === 1 ? properties[0] : properties : properties.reduce((carry, item) => {
|
|
244
244
|
carry[item.name] = item;
|
|
245
245
|
delete item["name"];
|
|
246
246
|
return carry;
|
|
@@ -249,7 +249,7 @@ const _UiSchemaRepository = class _UiSchemaRepository extends (_a = import_datab
|
|
|
249
249
|
}
|
|
250
250
|
return nodeAttributeSanitize(rootNode);
|
|
251
251
|
};
|
|
252
|
-
return buildTree(nodes.find((node) => node["x-uid"]
|
|
252
|
+
return buildTree(nodes.find((node) => node["x-uid"] === rootUid));
|
|
253
253
|
}
|
|
254
254
|
async clearAncestor(uid2, options) {
|
|
255
255
|
await this.clearXUidPathCache(uid2, options == null ? void 0 : options.transaction);
|
|
@@ -288,7 +288,7 @@ const _UiSchemaRepository = class _UiSchemaRepository extends (_a = import_datab
|
|
|
288
288
|
const oldTree = await this.getJsonSchema(rootUid, { transaction: transaction2 });
|
|
289
289
|
const traverSchemaTree = async (schema, path = []) => {
|
|
290
290
|
const node = schema;
|
|
291
|
-
const oldNode = path.length
|
|
291
|
+
const oldNode = path.length === 0 ? oldTree : import_lodash.default.get(oldTree, path);
|
|
292
292
|
const oldNodeUid = oldNode["x-uid"];
|
|
293
293
|
await this.updateNode(oldNodeUid, node, transaction2);
|
|
294
294
|
const properties = node.properties;
|
|
@@ -377,7 +377,9 @@ const _UiSchemaRepository = class _UiSchemaRepository extends (_a = import_datab
|
|
|
377
377
|
if (options.wrap) {
|
|
378
378
|
const wrapSchemaNodes = await this.insertNewSchema(options.wrap, {
|
|
379
379
|
transaction: transaction2,
|
|
380
|
-
returnNode: true
|
|
380
|
+
returnNode: true,
|
|
381
|
+
target,
|
|
382
|
+
position
|
|
381
383
|
});
|
|
382
384
|
const lastWrapNode = wrapSchemaNodes[wrapSchemaNodes.length - 1];
|
|
383
385
|
await this.insertAdjacent("afterBegin", lastWrapNode["x-uid"], schema, import_lodash.default.omit(options, "wrap"));
|
|
@@ -390,7 +392,9 @@ const _UiSchemaRepository = class _UiSchemaRepository extends (_a = import_datab
|
|
|
390
392
|
} else {
|
|
391
393
|
const insertedSchema = await this.insertNewSchema(schema, {
|
|
392
394
|
transaction: transaction2,
|
|
393
|
-
returnNode: true
|
|
395
|
+
returnNode: true,
|
|
396
|
+
position,
|
|
397
|
+
target
|
|
394
398
|
});
|
|
395
399
|
schema = insertedSchema[0]["x-uid"];
|
|
396
400
|
}
|
|
@@ -616,7 +620,7 @@ const _UiSchemaRepository = class _UiSchemaRepository extends (_a = import_datab
|
|
|
616
620
|
}
|
|
617
621
|
);
|
|
618
622
|
sort = targetSort[0].sort;
|
|
619
|
-
if (targetPosition.type
|
|
623
|
+
if (targetPosition.type === "after") {
|
|
620
624
|
sort += 1;
|
|
621
625
|
}
|
|
622
626
|
let updateSql2 = `UPDATE ${treeTable} as TreeTable
|
|
@@ -752,7 +756,7 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
|
|
|
752
756
|
return null;
|
|
753
757
|
}
|
|
754
758
|
const parentChildrenCount = await this.childrenCount(parent, transaction2);
|
|
755
|
-
if (parentChildrenCount
|
|
759
|
+
if (parentChildrenCount === 1) {
|
|
756
760
|
const schema = await db.getRepository("uiSchemas").findOne({
|
|
757
761
|
filter: {
|
|
758
762
|
"x-uid": parent
|
|
@@ -847,7 +851,7 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
|
|
|
847
851
|
},
|
|
848
852
|
transaction: transaction2
|
|
849
853
|
});
|
|
850
|
-
if (nodes[0].length
|
|
854
|
+
if (nodes[0].length === 0) {
|
|
851
855
|
return {};
|
|
852
856
|
}
|
|
853
857
|
const schema = this.nodesToSchema(nodes[0], uid2);
|
|
@@ -872,7 +876,7 @@ WHERE TreeTable.depth = 1 AND TreeTable.ancestor = :ancestor and TreeTable.sort
|
|
|
872
876
|
},
|
|
873
877
|
transaction: options == null ? void 0 : options.transaction
|
|
874
878
|
});
|
|
875
|
-
if (nodes[0].length
|
|
879
|
+
if (nodes[0].length === 0) {
|
|
876
880
|
return {};
|
|
877
881
|
}
|
|
878
882
|
return this.nodesToSchema(nodes[0], uid2);
|
|
@@ -21,15 +21,33 @@ __export(bind_menu_to_role_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(bind_menu_to_role_exports);
|
|
23
23
|
async function bindMenuToRole({ schemaInstance, db, options }) {
|
|
24
|
-
const { transaction } = options;
|
|
24
|
+
const { transaction, position, target } = options;
|
|
25
25
|
const addNewMenuRoles = await db.getRepository("roles").find({
|
|
26
26
|
filter: {
|
|
27
27
|
allowNewMenu: true
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
+
const uid = schemaInstance.get("x-uid");
|
|
31
|
+
let ancestorSet = /* @__PURE__ */ new Set();
|
|
32
|
+
ancestorSet.add(uid);
|
|
33
|
+
if (target) {
|
|
34
|
+
const ancestorList = await db.getRepository("uiSchemaTreePath").find({
|
|
35
|
+
fields: ["ancestor"],
|
|
36
|
+
filter: {
|
|
37
|
+
descendant: target
|
|
38
|
+
},
|
|
39
|
+
transaction
|
|
40
|
+
});
|
|
41
|
+
ancestorList.forEach((ancestor) => {
|
|
42
|
+
ancestorSet.add(ancestor.get("ancestor"));
|
|
43
|
+
});
|
|
44
|
+
if (position === "beforeBegin" || position === "afterEnd") {
|
|
45
|
+
ancestorSet.delete(target);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
30
48
|
for (const role of addNewMenuRoles) {
|
|
31
49
|
await db.getRepository("roles.menuUiSchemas", role.get("name")).add({
|
|
32
|
-
tk:
|
|
50
|
+
tk: [...ancestorSet],
|
|
33
51
|
transaction
|
|
34
52
|
});
|
|
35
53
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-ui-schema",
|
|
3
3
|
"displayName": "UI schema storage",
|
|
4
|
-
"version": "0.23.
|
|
4
|
+
"version": "0.23.35",
|
|
5
5
|
"description": "Provides centralized UI schema storage service.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"System & security"
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"sequelize": "6.37.5"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@tachybase/actions": "0.23.
|
|
18
|
-
"@tachybase/client": "0.23.
|
|
19
|
-
"@tachybase/cache": "0.23.
|
|
20
|
-
"@tachybase/database": "0.23.
|
|
21
|
-
"@tachybase/module-user": "0.23.
|
|
22
|
-
"@tachybase/module-error-handler": "0.23.
|
|
23
|
-
"@tachybase/resourcer": "0.23.
|
|
24
|
-
"@tachybase/server": "0.23.
|
|
25
|
-
"@tachybase/test": "0.23.
|
|
26
|
-
"@tachybase/utils": "0.23.
|
|
17
|
+
"@tachybase/actions": "0.23.35",
|
|
18
|
+
"@tachybase/client": "0.23.35",
|
|
19
|
+
"@tachybase/cache": "0.23.35",
|
|
20
|
+
"@tachybase/database": "0.23.35",
|
|
21
|
+
"@tachybase/module-user": "0.23.35",
|
|
22
|
+
"@tachybase/module-error-handler": "0.23.35",
|
|
23
|
+
"@tachybase/resourcer": "0.23.35",
|
|
24
|
+
"@tachybase/server": "0.23.35",
|
|
25
|
+
"@tachybase/test": "0.23.35",
|
|
26
|
+
"@tachybase/utils": "0.23.35"
|
|
27
27
|
},
|
|
28
28
|
"description.zh-CN": "提供中心化的 UI schema 存储服务。",
|
|
29
29
|
"displayName.zh-CN": "UI schema 存储服务",
|