@nocobase/plugin-field-sort 1.6.0-alpha.3 → 1.6.0-alpha.30

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/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Updated Date: October 15, 2024
1
+ Updated Date: February 20, 2025
2
2
 
3
3
  NocoBase License Agreement
4
4
 
@@ -78,7 +78,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
78
78
 
79
79
  6.1 Obtain a permanent commercial license of the Software.
80
80
 
81
- 6.2 Get 12 months of upgrade and exclusive technical support.
81
+ 6.2 Get software upgrades and exclusive technical support during the upgrade validity period.
82
82
 
83
83
  6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
84
84
 
@@ -88,7 +88,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
88
88
 
89
89
  6.6 Can sell plugins developed for Software in the Marketplace.
90
90
 
91
- 6.7 The User with a Professional or Enterprise Edition License can sell Upper Layer Application to their clients.
91
+ 6.7 The User with an Enterprise Edition License can sell Upper Layer Application to their clients.
92
92
 
93
93
  6.8 Not restricted by the AGPL-3.0 agreement.
94
94
 
@@ -106,13 +106,15 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
106
106
 
107
107
  7.4 It is not allowed to provide any form of no-code, zero-code, low-code platform SaaS products to the public using the original or modified Software.
108
108
 
109
- 7.5 It is not allowed for the User with a Standard Edition license to sell Upper Layer Application to clients without a Commercial license.
109
+ 7.5 It is not allowed for the User withot an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license.
110
110
 
111
- 7.6 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
111
+ 7.6 It is not allowed for the User with an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license with access to further development and configuration.
112
112
 
113
- 7.7 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
113
+ 7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
114
114
 
115
- 7.8 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
115
+ 7.8 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
116
+
117
+ 7.9 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
116
118
 
117
119
  ======================================
118
120
  8. Rights of Commercial Plugin License
@@ -120,11 +122,11 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
120
122
 
121
123
  8.1 Obtain a permanent Commercial Plugin License for the Commercial Plugin.
122
124
 
123
- 8.2 Receive 12 months of upgrades and exclusive technical support.
125
+ 8.2 Get plugins upgrades and exclusive technical support during the upgrade validity period.
124
126
 
125
127
  8.3 Can be used for commercial purposes without restrictions on the number of applications or users.
126
128
 
127
- 8.4 The User with a Professional or Enterprise Edition License can use the Commercial Plugin in Upper Layer Applications sold to their customers.
129
+ 8.4 The User with an Enterprise Edition License can use the Commercial Plugin in Upper Layer Applications sold to their customers.
128
130
 
129
131
  8.5 Not restricted by the AGPL-3.0 agreement.
130
132
 
@@ -8,12 +8,12 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.6.0-alpha.3",
12
- "@nocobase/database": "1.6.0-alpha.3",
13
- "@nocobase/actions": "1.6.0-alpha.3",
14
- "@nocobase/server": "1.6.0-alpha.3",
15
- "@nocobase/data-source-manager": "1.6.0-alpha.3",
11
+ "@nocobase/client": "1.6.0-alpha.30",
16
12
  "lodash": "4.17.21",
13
+ "@nocobase/database": "1.6.0-alpha.30",
14
+ "@nocobase/actions": "1.6.0-alpha.30",
15
+ "@nocobase/server": "1.6.0-alpha.30",
16
+ "@nocobase/data-source-manager": "1.6.0-alpha.30",
17
17
  "sequelize": "6.35.2",
18
- "@nocobase/lock-manager": "1.6.0-alpha.3"
18
+ "@nocobase/lock-manager": "1.6.0-alpha.30"
19
19
  };
@@ -30,6 +30,7 @@ __export(action_exports, {
30
30
  move: () => move
31
31
  });
32
32
  module.exports = __toCommonJS(action_exports);
33
+ var import_lodash = require("lodash");
33
34
  var import_database = require("@nocobase/database");
34
35
  var import_sort_field = require("./sort-field");
35
36
  async function move(ctx, next) {
@@ -78,42 +79,42 @@ class SortableCollection {
78
79
  }
79
80
  // insert source position to target position
80
81
  async move(sourceInstanceId, targetInstanceId, options = {}) {
81
- const sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
82
+ let sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
82
83
  const targetInstance = await this.collection.repository.findByTargetKey(targetInstanceId);
83
84
  if (this.scopeKey && sourceInstance.get(this.scopeKey) !== targetInstance.get(this.scopeKey)) {
84
- await sourceInstance.update({
85
- [this.scopeKey]: targetInstance.get(this.scopeKey)
85
+ [sourceInstance] = await this.collection.repository.update({
86
+ filterByTk: sourceInstanceId,
87
+ values: {
88
+ [this.scopeKey]: targetInstance.get(this.scopeKey)
89
+ }
86
90
  });
87
91
  }
88
92
  await this.sameScopeMove(sourceInstance, targetInstance, options);
89
93
  }
90
94
  async changeScope(sourceInstanceId, targetScope, method) {
91
- const sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
95
+ let sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
92
96
  const targetScopeValue = targetScope[this.scopeKey];
93
97
  if (targetScopeValue && sourceInstance.get(this.scopeKey) !== targetScopeValue) {
94
- await sourceInstance.update(
95
- {
98
+ [sourceInstance] = await this.collection.repository.update({
99
+ filterByTk: sourceInstanceId,
100
+ values: {
96
101
  [this.scopeKey]: targetScopeValue
97
102
  },
98
- {
99
- silent: false
100
- }
101
- );
103
+ silent: false
104
+ });
102
105
  if (method === "prepend") {
103
106
  await this.sticky(sourceInstanceId);
104
107
  }
105
108
  }
106
109
  }
107
110
  async sticky(sourceInstanceId) {
108
- const sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
109
- await sourceInstance.update(
110
- {
111
+ await this.collection.repository.update({
112
+ filterByTk: sourceInstanceId,
113
+ values: {
111
114
  [this.field.get("name")]: 0
112
115
  },
113
- {
114
- silent: true
115
- }
116
- );
116
+ silent: true
117
+ });
117
118
  }
118
119
  async sameScopeMove(sourceInstance, targetInstance, options) {
119
120
  const fieldName = this.field.get("name");
@@ -151,14 +152,13 @@ class SortableCollection {
151
152
  by: change,
152
153
  silent: true
153
154
  });
154
- await sourceInstance.update(
155
- {
155
+ await this.collection.repository.update({
156
+ filterByTk: this.collection.isMultiFilterTargetKey() ? (0, import_lodash.pick)(sourceInstance, this.collection.filterTargetKey) : sourceInstance.get(this.collection.filterTargetKey),
157
+ values: {
156
158
  [fieldName]: targetSort
157
159
  },
158
- {
159
- silent: true
160
- }
161
- );
160
+ silent: true
161
+ });
162
162
  }
163
163
  }
164
164
  // Annotate the CommonJS export names for ESM import in node:
@@ -42,11 +42,11 @@ class PluginFieldSortServer extends import_server.Plugin {
42
42
  class SortFieldClass extends import_sort_field.SortField {
43
43
  }
44
44
  SortFieldClass.lockManager = lockManager;
45
- this.app.db.registerFieldTypes({
46
- sort: SortFieldClass
47
- });
48
45
  this.app.dataSourceManager.beforeAddDataSource((dataSource) => {
49
46
  if (dataSource.collectionManager instanceof import_data_source_manager.SequelizeCollectionManager) {
47
+ dataSource.collectionManager.db.registerFieldTypes({
48
+ sort: SortFieldClass
49
+ });
50
50
  dataSource.resourceManager.registerActionHandlers({ move: import_action.move });
51
51
  }
52
52
  });
@@ -68,16 +68,6 @@ class SortField extends import_database.Field {
68
68
  };
69
69
  initRecordsSortValue = async (options) => {
70
70
  const { transaction } = options;
71
- const orderField = (() => {
72
- const model = this.collection.model;
73
- if (model.primaryKeyAttribute) {
74
- return model.primaryKeyAttribute;
75
- }
76
- if (model.rawAttributes["createdAt"]) {
77
- return model.rawAttributes["createdAt"].field;
78
- }
79
- throw new Error(`can not find order key for collection ${this.collection.name}`);
80
- })();
81
71
  const needInit = async (scopeKey2 = null, scopeValue = null) => {
82
72
  const filter = {};
83
73
  if (scopeKey2 && scopeValue) {
@@ -97,6 +87,19 @@ class SortField extends import_database.Field {
97
87
  return emptyCount === totalCount && emptyCount > 0;
98
88
  };
99
89
  const doInit = async (scopeKey2 = null, scopeValue = null) => {
90
+ const orderField = (() => {
91
+ const model = this.collection.model;
92
+ if (model.primaryKeyAttribute) {
93
+ const primaryKeyAttribute = model.rawAttributes[model.primaryKeyAttribute];
94
+ if (primaryKeyAttribute.autoIncrement) {
95
+ return primaryKeyAttribute.field;
96
+ }
97
+ }
98
+ if (model.rawAttributes["createdAt"]) {
99
+ return model.rawAttributes["createdAt"].field;
100
+ }
101
+ throw new Error(`can not find order key for collection ${this.collection.name}`);
102
+ })();
100
103
  const queryInterface = this.collection.db.sequelize.getQueryInterface();
101
104
  if (scopeKey2) {
102
105
  const scopeAttribute = this.collection.model.rawAttributes[scopeKey2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-field-sort",
3
- "version": "1.6.0-alpha.3",
3
+ "version": "1.6.0-alpha.30",
4
4
  "license": "AGPL-3.0",
5
5
  "displayName": "Collection field: Sort",
6
6
  "displayName.zh-CN": "数据表字段:排序",
@@ -20,5 +20,5 @@
20
20
  "keywords": [
21
21
  "Collection fields"
22
22
  ],
23
- "gitHead": "205b4aca5556d5af70679fa401394943a9e51670"
23
+ "gitHead": "4d092cae372fada3df9b57c55705ea3b7dfa6786"
24
24
  }