@nocobase/plugin-field-sort 1.5.0-beta.9 → 1.5.1

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 6, 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
 
@@ -95,7 +95,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
95
95
  6.9 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
96
96
 
97
97
  ====================================
98
- 7. Obligations of Commercial License
98
+ 1. Obligations of Commercial License
99
99
  ====================================
100
100
 
101
101
  7.1 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
@@ -108,11 +108,13 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
108
108
 
109
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.
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 a Professional or 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,7 +122,7 @@ 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
 
@@ -8,12 +8,12 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.5.0-beta.9",
12
- "@nocobase/database": "1.5.0-beta.9",
13
- "@nocobase/actions": "1.5.0-beta.9",
14
- "@nocobase/server": "1.5.0-beta.9",
15
- "@nocobase/data-source-manager": "1.5.0-beta.9",
11
+ "@nocobase/client": "1.5.1",
16
12
  "lodash": "4.17.21",
13
+ "@nocobase/database": "1.5.1",
14
+ "@nocobase/actions": "1.5.1",
15
+ "@nocobase/server": "1.5.1",
16
+ "@nocobase/data-source-manager": "1.5.1",
17
17
  "sequelize": "6.35.2",
18
- "@nocobase/lock-manager": "1.5.0-beta.9"
18
+ "@nocobase/lock-manager": "1.5.1"
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:
@@ -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.5.0-beta.9",
3
+ "version": "1.5.1",
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": "fef0bcb5f95705cd83607f03a6c911550016281b"
23
+ "gitHead": "b16a0ff226482d0de847656ea26fd621b1d685cf"
24
24
  }