@nocobase/plugin-collection-tree 1.9.0-beta.5 → 1.9.0-beta.7
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
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.9.0-beta.
|
|
12
|
-
"@nocobase/database": "1.9.0-beta.
|
|
13
|
-
"@nocobase/utils": "1.9.0-beta.
|
|
11
|
+
"@nocobase/client": "1.9.0-beta.7",
|
|
12
|
+
"@nocobase/database": "1.9.0-beta.7",
|
|
13
|
+
"@nocobase/utils": "1.9.0-beta.7",
|
|
14
14
|
"lodash": "4.17.21",
|
|
15
|
-
"@nocobase/data-source-manager": "1.9.0-beta.
|
|
16
|
-
"@nocobase/server": "1.9.0-beta.
|
|
15
|
+
"@nocobase/data-source-manager": "1.9.0-beta.7",
|
|
16
|
+
"@nocobase/server": "1.9.0-beta.7",
|
|
17
17
|
"sequelize": "6.35.2"
|
|
18
18
|
};
|
|
@@ -7,4 +7,6 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Application } from '@nocobase/server';
|
|
10
|
+
import { Database, Model, Transaction } from '@nocobase/database';
|
|
11
|
+
export declare function getTreePath(db: Database, model: Model, path: string, collection: string, pathCollectionName: string, transaction?: Transaction): Promise<string>;
|
|
10
12
|
export default function (app: Application): void;
|
|
@@ -36,7 +36,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
var sync_path_exports = {};
|
|
38
38
|
__export(sync_path_exports, {
|
|
39
|
-
default: () => sync_path_default
|
|
39
|
+
default: () => sync_path_default,
|
|
40
|
+
getTreePath: () => getTreePath
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(sync_path_exports);
|
|
42
43
|
var import_lodash = __toESM(require("lodash"));
|
|
@@ -47,7 +48,6 @@ async function getTreePath(db, model, path, collection, pathCollectionName, tran
|
|
|
47
48
|
transaction
|
|
48
49
|
});
|
|
49
50
|
if (parent && parent.get("parentId") !== model.get("id")) {
|
|
50
|
-
path = `/${parent.get("id")}${path}`;
|
|
51
51
|
const collectionTreePath = db.getCollection(pathCollectionName);
|
|
52
52
|
const nodePkColumnName = collectionTreePath.getField("nodePk").columnName();
|
|
53
53
|
const parentPathData = await db.getRepository(pathCollectionName).findOne({
|
|
@@ -56,7 +56,15 @@ async function getTreePath(db, model, path, collection, pathCollectionName, tran
|
|
|
56
56
|
});
|
|
57
57
|
const parentPath = import_lodash.default.get(parentPathData, "path", null);
|
|
58
58
|
if (parentPath == null) {
|
|
59
|
-
|
|
59
|
+
const parentFullPath = await getTreePath(
|
|
60
|
+
db,
|
|
61
|
+
parent,
|
|
62
|
+
`/${parent.get("id")}`,
|
|
63
|
+
collection,
|
|
64
|
+
pathCollectionName,
|
|
65
|
+
transaction
|
|
66
|
+
);
|
|
67
|
+
path = `${parentFullPath}/${model.get("id")}`;
|
|
60
68
|
} else {
|
|
61
69
|
path = `${parentPath}/${model.get("id")}`;
|
|
62
70
|
}
|
|
@@ -114,3 +122,7 @@ function sync_path_default(app) {
|
|
|
114
122
|
});
|
|
115
123
|
});
|
|
116
124
|
}
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
getTreePath
|
|
128
|
+
});
|
package/dist/server/plugin.js
CHANGED
|
@@ -123,19 +123,25 @@ class PluginCollectionTreeServer extends import_server.Plugin {
|
|
|
123
123
|
throw new Error("Cannot set itself as the parent node");
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
+
this.db.on("collections.afterDestroy", async (collection2, { transaction }) => {
|
|
127
|
+
const name2 = `main_${collection2.get("name")}_path`;
|
|
128
|
+
if (!condition(collection2.options)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const collectionTree = this.db.getCollection(name2);
|
|
132
|
+
if (collectionTree) {
|
|
133
|
+
await this.db.getCollection(name2).removeFromDb({ transaction });
|
|
134
|
+
collectionManager.db.removeAllListeners(`${collection2.name}.afterSync`);
|
|
135
|
+
this.db.removeAllListeners(`${collection2.name}.afterCreate`);
|
|
136
|
+
this.db.removeAllListeners(`${collection2.name}.afterUpdate`);
|
|
137
|
+
this.db.removeAllListeners(`${collection2.name}.afterBulkUpdate`);
|
|
138
|
+
this.db.removeAllListeners(`${collection2.name}.afterDestroy`);
|
|
139
|
+
this.db.removeAllListeners(`${collection2.name}.beforeSave`);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
126
142
|
});
|
|
127
143
|
}
|
|
128
144
|
});
|
|
129
|
-
this.db.on("collections.afterDestroy", async (collection, { transaction }) => {
|
|
130
|
-
const name = `main_${collection.get("name")}_path`;
|
|
131
|
-
if (!condition(collection.options)) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const collectionTree = this.db.getCollection(name);
|
|
135
|
-
if (collectionTree) {
|
|
136
|
-
await this.db.getCollection(name).removeFromDb({ transaction });
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
145
|
}
|
|
140
146
|
async defineTreePathCollection(name, options) {
|
|
141
147
|
this.db.collection({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-collection-tree",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.7",
|
|
4
4
|
"displayName": "Collection: Tree",
|
|
5
5
|
"displayName.zh-CN": "数据表:树",
|
|
6
6
|
"description": "Provides tree collection template",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"@nocobase/server": "1.x",
|
|
15
15
|
"@nocobase/test": "1.x"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "4a5055c973b51611d5db1604aaaf6c1b73b4733c"
|
|
18
18
|
}
|