@nocobase/plugin-field-sort 2.1.0-alpha.46 → 2.1.0-alpha.47
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 +8 -8
- package/dist/server/sort-field.js +30 -23
- package/package.json +2 -2
package/dist/externalVersion.js
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.1.0-alpha.
|
|
12
|
-
"@nocobase/client-v2": "2.1.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.1.0-alpha.47",
|
|
12
|
+
"@nocobase/client-v2": "2.1.0-alpha.47",
|
|
13
13
|
"antd": "5.24.2",
|
|
14
14
|
"react": "18.2.0",
|
|
15
|
-
"@nocobase/flow-engine": "2.1.0-alpha.
|
|
15
|
+
"@nocobase/flow-engine": "2.1.0-alpha.47",
|
|
16
16
|
"lodash": "4.18.1",
|
|
17
|
-
"@nocobase/database": "2.1.0-alpha.
|
|
18
|
-
"@nocobase/actions": "2.1.0-alpha.
|
|
19
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
20
|
-
"@nocobase/data-source-manager": "2.1.0-alpha.
|
|
17
|
+
"@nocobase/database": "2.1.0-alpha.47",
|
|
18
|
+
"@nocobase/actions": "2.1.0-alpha.47",
|
|
19
|
+
"@nocobase/server": "2.1.0-alpha.47",
|
|
20
|
+
"@nocobase/data-source-manager": "2.1.0-alpha.47",
|
|
21
21
|
"sequelize": "6.35.2",
|
|
22
|
-
"@nocobase/lock-manager": "2.1.0-alpha.
|
|
22
|
+
"@nocobase/lock-manager": "2.1.0-alpha.47"
|
|
23
23
|
};
|
|
@@ -41,30 +41,37 @@ class SortField extends import_database.Field {
|
|
|
41
41
|
const { name, scopeKey } = this.options;
|
|
42
42
|
const { model } = this.context.collection;
|
|
43
43
|
instances = Array.isArray(instances) ? instances : [instances];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
where
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
await this.constructor.lockManager.runExclusive(
|
|
45
|
+
this.context.collection.name,
|
|
46
|
+
async () => {
|
|
47
|
+
const maxCache = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const instance of instances) {
|
|
49
|
+
if (from == "create" && (0, import_lodash.isNumber)(instance.get(name))) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if ((0, import_lodash.isNumber)(instance.get(name)) && instance._previousDataValues[scopeKey] == instance[scopeKey]) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const where = {};
|
|
56
|
+
let cacheKey = "__default__";
|
|
57
|
+
if (scopeKey) {
|
|
58
|
+
const value = instance.get(scopeKey);
|
|
59
|
+
if (value !== void 0 && value !== null) {
|
|
60
|
+
where[scopeKey] = value;
|
|
61
|
+
cacheKey = `${typeof value}:${String(value)}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!maxCache.has(cacheKey)) {
|
|
65
|
+
const max = await model.max(name, { ...options, where });
|
|
66
|
+
maxCache.set(cacheKey, max || 0);
|
|
67
|
+
}
|
|
68
|
+
const newValue = (maxCache.get(cacheKey) ?? 0) + 1;
|
|
69
|
+
maxCache.set(cacheKey, newValue);
|
|
63
70
|
instance.set(name, newValue);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
2e3
|
|
74
|
+
);
|
|
68
75
|
};
|
|
69
76
|
onScopeChange = async (instance, options) => {
|
|
70
77
|
const { scopeKey } = this.options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-field-sort",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.47",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"displayName": "Collection field: Sort",
|
|
6
6
|
"displayName.ru-RU": "Поле коллекции: Сортировка",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"keywords": [
|
|
25
25
|
"Collection fields"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "66196b57f9043ea0ac6ebdafbc732bfb98af1396"
|
|
28
28
|
}
|