@nocobase/plugin-field-sort 1.9.0-beta.3 → 1.9.0-beta.5
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,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.9.0-beta.
|
|
11
|
+
"@nocobase/client": "1.9.0-beta.5",
|
|
12
12
|
"lodash": "4.17.21",
|
|
13
|
-
"@nocobase/database": "1.9.0-beta.
|
|
14
|
-
"@nocobase/actions": "1.9.0-beta.
|
|
15
|
-
"@nocobase/server": "1.9.0-beta.
|
|
16
|
-
"@nocobase/data-source-manager": "1.9.0-beta.
|
|
13
|
+
"@nocobase/database": "1.9.0-beta.5",
|
|
14
|
+
"@nocobase/actions": "1.9.0-beta.5",
|
|
15
|
+
"@nocobase/server": "1.9.0-beta.5",
|
|
16
|
+
"@nocobase/data-source-manager": "1.9.0-beta.5",
|
|
17
17
|
"sequelize": "6.35.2",
|
|
18
|
-
"@nocobase/lock-manager": "1.9.0-beta.
|
|
18
|
+
"@nocobase/lock-manager": "1.9.0-beta.5"
|
|
19
19
|
};
|
|
@@ -12,9 +12,10 @@ import { LockManager } from '@nocobase/lock-manager';
|
|
|
12
12
|
export declare class SortField extends Field {
|
|
13
13
|
static lockManager: LockManager;
|
|
14
14
|
get dataType(): DataTypes.BigIntDataTypeConstructor;
|
|
15
|
-
setSortValue: (instances: any, options: any) => Promise<void>;
|
|
15
|
+
setSortValue: (instances: any, options: any, from: 'create' | 'update') => Promise<void>;
|
|
16
16
|
onScopeChange: (instance: any, options: any) => Promise<void>;
|
|
17
17
|
initRecordsSortValue: (options: any) => Promise<void>;
|
|
18
|
+
setSortValueListener: (instances: any, options: any) => Promise<void>;
|
|
18
19
|
bind(): void;
|
|
19
20
|
unbind(): void;
|
|
20
21
|
}
|
|
@@ -37,11 +37,14 @@ class SortField extends import_database.Field {
|
|
|
37
37
|
get dataType() {
|
|
38
38
|
return import_sequelize.DataTypes.BIGINT;
|
|
39
39
|
}
|
|
40
|
-
setSortValue = async (instances, options) => {
|
|
40
|
+
setSortValue = async (instances, options, from) => {
|
|
41
41
|
const { name, scopeKey } = this.options;
|
|
42
42
|
const { model } = this.context.collection;
|
|
43
43
|
instances = Array.isArray(instances) ? instances : [instances];
|
|
44
44
|
for (const instance of instances) {
|
|
45
|
+
if (from == "create" && (0, import_lodash.isNumber)(instance.get(name))) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
45
48
|
if ((0, import_lodash.isNumber)(instance.get(name)) && instance._previousDataValues[scopeKey] == instance[scopeKey]) {
|
|
46
49
|
continue;
|
|
47
50
|
}
|
|
@@ -66,7 +69,7 @@ class SortField extends import_database.Field {
|
|
|
66
69
|
onScopeChange = async (instance, options) => {
|
|
67
70
|
const { scopeKey } = this.options;
|
|
68
71
|
if (scopeKey && !instance.isNewRecord && instance._previousDataValues[scopeKey] != instance[scopeKey]) {
|
|
69
|
-
await this.setSortValue(instance, options);
|
|
72
|
+
await this.setSortValue(instance, options, "update");
|
|
70
73
|
}
|
|
71
74
|
};
|
|
72
75
|
initRecordsSortValue = async (options) => {
|
|
@@ -184,19 +187,20 @@ class SortField extends import_database.Field {
|
|
|
184
187
|
await doInit();
|
|
185
188
|
}
|
|
186
189
|
};
|
|
190
|
+
setSortValueListener = async (instances, options) => await this.setSortValue(instances, options, "create");
|
|
187
191
|
bind() {
|
|
188
192
|
super.bind();
|
|
189
193
|
this.on("afterSync", this.initRecordsSortValue);
|
|
190
194
|
this.on("beforeUpdate", this.onScopeChange);
|
|
191
|
-
this.on("beforeCreate", this.
|
|
192
|
-
this.on("beforeBulkCreate", this.
|
|
195
|
+
this.on("beforeCreate", this.setSortValueListener);
|
|
196
|
+
this.on("beforeBulkCreate", this.setSortValueListener);
|
|
193
197
|
}
|
|
194
198
|
unbind() {
|
|
195
199
|
super.unbind();
|
|
196
200
|
this.off("beforeUpdate", this.onScopeChange);
|
|
197
|
-
this.off("beforeCreate", this.
|
|
201
|
+
this.off("beforeCreate", this.setSortValueListener);
|
|
198
202
|
this.off("afterSync", this.initRecordsSortValue);
|
|
199
|
-
this.off("beforeBulkCreate", this.
|
|
203
|
+
this.off("beforeBulkCreate", this.setSortValueListener);
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-field-sort",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.5",
|
|
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": "
|
|
23
|
+
"gitHead": "9a61c60dd3db5af64244e82447309b0cb17aabb6"
|
|
24
24
|
}
|