@nocobase/plugin-collection-tree 2.0.0-alpha.48 → 2.0.0-alpha.49

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.
@@ -8,11 +8,11 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.0.0-alpha.48",
12
- "@nocobase/database": "2.0.0-alpha.48",
13
- "@nocobase/utils": "2.0.0-alpha.48",
11
+ "@nocobase/client": "2.0.0-alpha.49",
12
+ "@nocobase/database": "2.0.0-alpha.49",
13
+ "@nocobase/utils": "2.0.0-alpha.49",
14
14
  "lodash": "4.17.21",
15
- "@nocobase/data-source-manager": "2.0.0-alpha.48",
16
- "@nocobase/server": "2.0.0-alpha.48",
15
+ "@nocobase/data-source-manager": "2.0.0-alpha.49",
16
+ "@nocobase/server": "2.0.0-alpha.49",
17
17
  "sequelize": "6.35.2"
18
18
  };
@@ -55,12 +55,10 @@ class PluginCollectionTreeServer extends import_server.Plugin {
55
55
  const collectionManager = dataSource.collectionManager;
56
56
  if (collectionManager instanceof import_data_source_manager.SequelizeCollectionManager) {
57
57
  collectionManager.db.on("afterDefineCollection", (collection) => {
58
- var _a;
59
58
  if (!condition(collection.options)) {
60
59
  return;
61
60
  }
62
61
  const name = `${dataSource.name}_${collection.name}_path`;
63
- const parentForeignKey = ((_a = collection.treeParentField) == null ? void 0 : _a.foreignKey) || "parentId";
64
62
  const options = {};
65
63
  options["mainCollection"] = collection.name;
66
64
  if (collection.options.schema) {
@@ -86,7 +84,9 @@ class PluginCollectionTreeServer extends import_server.Plugin {
86
84
  });
87
85
  });
88
86
  this.db.on(`${collection.name}.afterUpdate`, async (model, options2) => {
87
+ var _a;
89
88
  const tk = collection.filterTargetKey;
89
+ const parentForeignKey = ((_a = collection.treeParentField) == null ? void 0 : _a.foreignKey) || "parentId";
90
90
  if (!(model._changed.has(tk) || model._changed.has(parentForeignKey))) {
91
91
  return;
92
92
  }
@@ -118,7 +118,9 @@ class PluginCollectionTreeServer extends import_server.Plugin {
118
118
  });
119
119
  });
120
120
  this.db.on(`${collection.name}.beforeSave`, async (model) => {
121
+ var _a;
121
122
  const tk = collection.filterTargetKey;
123
+ const parentForeignKey = ((_a = collection.treeParentField) == null ? void 0 : _a.foreignKey) || "parentId";
122
124
  if (model.get(tk) && model.get(parentForeignKey) === model.get(tk)) {
123
125
  throw new Error("Cannot set itself as the parent node");
124
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-collection-tree",
3
- "version": "2.0.0-alpha.48",
3
+ "version": "2.0.0-alpha.49",
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": "456be3a6e92f984fe283590c80d3ea9423695ba6"
19
+ "gitHead": "99f71bc8961da62a761630b3eae11092a4372e3e"
20
20
  }