@nocobase/plugin-collection-tree 2.0.0-alpha.53 → 2.0.0-alpha.54
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 +5 -5
- package/dist/server/plugin.js +13 -3
- package/package.json +2 -2
package/dist/externalVersion.js
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.0.0-alpha.
|
|
12
|
-
"@nocobase/database": "2.0.0-alpha.
|
|
13
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.0.0-alpha.54",
|
|
12
|
+
"@nocobase/database": "2.0.0-alpha.54",
|
|
13
|
+
"@nocobase/utils": "2.0.0-alpha.54",
|
|
14
14
|
"lodash": "4.17.21",
|
|
15
|
-
"@nocobase/data-source-manager": "2.0.0-alpha.
|
|
16
|
-
"@nocobase/server": "2.0.0-alpha.
|
|
15
|
+
"@nocobase/data-source-manager": "2.0.0-alpha.54",
|
|
16
|
+
"@nocobase/server": "2.0.0-alpha.54",
|
|
17
17
|
"sequelize": "6.35.2"
|
|
18
18
|
};
|
package/dist/server/plugin.js
CHANGED
|
@@ -54,7 +54,7 @@ class PluginCollectionTreeServer extends import_server.Plugin {
|
|
|
54
54
|
this.app.dataSourceManager.afterAddDataSource((dataSource) => {
|
|
55
55
|
const collectionManager = dataSource.collectionManager;
|
|
56
56
|
if (collectionManager instanceof import_data_source_manager.SequelizeCollectionManager) {
|
|
57
|
-
collectionManager.db.on("afterDefineCollection", (collection) => {
|
|
57
|
+
collectionManager.db.on("afterDefineCollection", (collection, eventOptions) => {
|
|
58
58
|
if (!condition(collection.options)) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
@@ -64,6 +64,9 @@ class PluginCollectionTreeServer extends import_server.Plugin {
|
|
|
64
64
|
if (collection.options.schema) {
|
|
65
65
|
options["schema"] = collection.options.schema;
|
|
66
66
|
}
|
|
67
|
+
if (eventOptions.fieldModels) {
|
|
68
|
+
options["fieldModels"] = eventOptions.fieldModels;
|
|
69
|
+
}
|
|
67
70
|
this.defineTreePathCollection(name, options);
|
|
68
71
|
collectionManager.db.on(`${collection.name}.afterSync`, async ({ transaction }) => {
|
|
69
72
|
await this.db.getCollection(name).sync({ transaction });
|
|
@@ -146,14 +149,21 @@ class PluginCollectionTreeServer extends import_server.Plugin {
|
|
|
146
149
|
});
|
|
147
150
|
}
|
|
148
151
|
async defineTreePathCollection(name, options) {
|
|
152
|
+
let nodePkType = "bigInt";
|
|
153
|
+
if (options.fieldModels) {
|
|
154
|
+
const pk = options.fieldModels.find((x) => x.options.primaryKey === true);
|
|
155
|
+
if (pk) {
|
|
156
|
+
nodePkType = pk.type;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
149
159
|
this.db.collection({
|
|
150
160
|
name,
|
|
151
161
|
autoGenId: false,
|
|
152
162
|
timestamps: false,
|
|
153
163
|
fields: [
|
|
154
|
-
{ type:
|
|
164
|
+
{ type: nodePkType, name: "nodePk" },
|
|
155
165
|
{ type: "string", name: "path", length: 1024 },
|
|
156
|
-
{ type:
|
|
166
|
+
{ type: nodePkType, name: "rootPk" }
|
|
157
167
|
],
|
|
158
168
|
indexes: [
|
|
159
169
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-collection-tree",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.54",
|
|
4
4
|
"displayName": "Collection: Tree",
|
|
5
5
|
"displayName.ru-RU": "Древовидная Коллекция",
|
|
6
6
|
"displayName.zh-CN": "数据表:树",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"@nocobase/server": "2.x",
|
|
17
17
|
"@nocobase/test": "2.x"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "68c84deaabba0ebec7407bf7245376b8d843449c"
|
|
20
20
|
}
|