@nocobase/plugin-field-sort 1.7.0-beta.8 → 1.7.0
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 +4 -4
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/server/sort-field.d.ts +1 -1
- package/dist/server/sort-field.js +23 -18
- package/package.json +2 -2
package/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Updated Date:
|
|
1
|
+
Updated Date: April 1, 2025
|
|
2
2
|
|
|
3
3
|
NocoBase License Agreement
|
|
4
4
|
|
|
@@ -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
|
|
91
|
+
6.7 The User with a Professional or 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,9 +106,9 @@ 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 withot
|
|
109
|
+
7.5 It is not allowed for the User withot a Professional or Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license.
|
|
110
110
|
|
|
111
|
-
7.6 It is not allowed for the User with
|
|
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
113
|
7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
|
|
114
114
|
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-sort",["@nocobase/client"],t):"object"==typeof exports?exports["@nocobase/plugin-field-sort"]=t(require("@nocobase/client")):e["@nocobase/plugin-field-sort"]=t(e["@nocobase/client"])}(self,function(e){return function(){"use strict";var t={772:function(t){t.exports=e}},
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-sort",["@nocobase/client"],t):"object"==typeof exports?exports["@nocobase/plugin-field-sort"]=t(require("@nocobase/client")):e["@nocobase/plugin-field-sort"]=t(e["@nocobase/client"])}(self,function(e){return function(){"use strict";var t={772:function(t){t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return!function(){n.r(o),n.d(o,{PluginFieldSortClient:function(){return m},default:function(){return v}});var e=n(772);function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var c=function(n){if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");function o(){var n,i,c,a,l;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return i=o,c=arguments,i=r(i),t(n=function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,u()?Reflect.construct(i,c||[],r(this).constructor):i.apply(this,c)),"name","sort"),t(n,"type","object"),t(n,"group","advanced"),t(n,"order",1),t(n,"title",'{{t("Sort")}}'),t(n,"sortable",!0),t(n,"titleUsable",!0),t(n,"description",'{{t("Used for drag and drop sorting scenarios, supporting grouping sorting")}}'),t(n,"default",{type:"sort",uiSchema:{type:"number","x-component":"InputNumber","x-component-props":{stringMode:!0,step:"1"},"x-validator":"integer"}}),t(n,"availableTypes",["sort"]),t(n,"hasDefaultValue",!1),t(n,"properties",(a=function(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(r){t(e,r,n[r])})}return e}({},e.defaultProps),l=l={scopeKey:{type:"string",title:'{{t("Grouped sorting")}}',"x-disabled":"{{ !editMainOnly}}","x-decorator":"FormItem","x-component":"Select",enum:"{{scopeKeyOptions}}",description:"{{t('When a field is selected for grouping, it will be grouped first before sorting.')}}"}},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(l)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(l)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(l,e))}),a)),t(n,"filterable",{operators:e.operators.number}),t(n,"validateSchema",function(t){return{maximum:{type:"number",title:'{{ t("Maximum") }}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":"{{(field) => {\n const targetValue = field.query('.minimum').value();\n field.selfErrors =\n !!targetValue && !!field.value && targetValue > field.value ? '".concat(e.i18n.t("Maximum must greater than minimum"),"' : ''\n }}}")},minimum:{type:"number",title:'{{ t("Minimum") }}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":{dependencies:[".maximum"],fulfill:{state:{selfErrors:"{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '".concat(e.i18n.t("Minimum must less than maximum"),"' : ''}}")}}}},format:{type:"string",title:'{{ t("Format") }}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{allowClear:!0},enum:[{label:'{{ t("Odd") }}',value:"odd"},{label:'{{ t("Even") }}',value:"even"}]},pattern:{type:"string",title:'{{ t("Regular expression") }}',"x-decorator":"FormItem","x-component":"Input","x-component-props":{prefix:"/",suffix:"/"}}}}),n}return o.prototype=Object.create(n&&n.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),n&&i(o,n),o}(e.CollectionFieldInterface);function a(e,t,r,n,o,i,u){try{var c=e[i](u),a=c.value}catch(e){r(e);return}c.done?t(a):Promise.resolve(a).then(n,o)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)})}}function f(e,t,r){return(f=y()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(e){var t="function"==typeof Map?new Map:void 0;return(b=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return f(e,arguments,p(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(y=function(){return!!e})()}function d(e,t){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(r)throw TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,n=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var m=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=p(e),function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,y()?Reflect.construct(e,t||[],p(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&s(r,e),t=[{key:"afterAdd",value:function(){return l(function(){return d(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return l(function(){return d(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return l(function(){return d(this,function(t){return e.app.addFieldInterfaces([c]),[2]})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(b(e.Plugin)),v=m}(),o}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.7.0
|
|
11
|
+
"@nocobase/client": "1.7.0",
|
|
12
12
|
"lodash": "4.17.21",
|
|
13
|
-
"@nocobase/database": "1.7.0
|
|
14
|
-
"@nocobase/actions": "1.7.0
|
|
15
|
-
"@nocobase/server": "1.7.0
|
|
16
|
-
"@nocobase/data-source-manager": "1.7.0
|
|
13
|
+
"@nocobase/database": "1.7.0",
|
|
14
|
+
"@nocobase/actions": "1.7.0",
|
|
15
|
+
"@nocobase/server": "1.7.0",
|
|
16
|
+
"@nocobase/data-source-manager": "1.7.0",
|
|
17
17
|
"sequelize": "6.35.2",
|
|
18
|
-
"@nocobase/lock-manager": "1.7.0
|
|
18
|
+
"@nocobase/lock-manager": "1.7.0"
|
|
19
19
|
};
|
|
@@ -12,7 +12,7 @@ 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: (
|
|
15
|
+
setSortValue: (instances: any, options: any) => Promise<void>;
|
|
16
16
|
onScopeChange: (instance: any, options: any) => Promise<void>;
|
|
17
17
|
initRecordsSortValue: (options: any) => Promise<void>;
|
|
18
18
|
bind(): void;
|
|
@@ -37,28 +37,31 @@ class SortField extends import_database.Field {
|
|
|
37
37
|
get dataType() {
|
|
38
38
|
return import_sequelize.DataTypes.BIGINT;
|
|
39
39
|
}
|
|
40
|
-
setSortValue = async (
|
|
40
|
+
setSortValue = async (instances, options) => {
|
|
41
41
|
const { name, scopeKey } = this.options;
|
|
42
42
|
const { model } = this.context.collection;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
|
|
43
|
+
instances = Array.isArray(instances) ? instances : [instances];
|
|
44
|
+
for (const instance of instances) {
|
|
45
|
+
if ((0, import_lodash.isNumber)(instance.get(name)) && instance._previousDataValues[scopeKey] == instance[scopeKey]) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const where = {};
|
|
49
|
+
if (scopeKey) {
|
|
50
|
+
const value = instance.get(scopeKey);
|
|
51
|
+
if (value !== void 0 && value !== null) {
|
|
52
|
+
where[scopeKey] = value;
|
|
53
|
+
}
|
|
51
54
|
}
|
|
55
|
+
await this.constructor.lockManager.runExclusive(
|
|
56
|
+
this.context.collection.name,
|
|
57
|
+
async () => {
|
|
58
|
+
const max = await model.max(name, { ...options, where });
|
|
59
|
+
const newValue = (max || 0) + 1;
|
|
60
|
+
instance.set(name, newValue);
|
|
61
|
+
},
|
|
62
|
+
2e3
|
|
63
|
+
);
|
|
52
64
|
}
|
|
53
|
-
await this.constructor.lockManager.runExclusive(
|
|
54
|
-
this.context.collection.name,
|
|
55
|
-
async () => {
|
|
56
|
-
const max = await model.max(name, { ...options, where });
|
|
57
|
-
const newValue = (max || 0) + 1;
|
|
58
|
-
instance.set(name, newValue);
|
|
59
|
-
},
|
|
60
|
-
2e3
|
|
61
|
-
);
|
|
62
65
|
};
|
|
63
66
|
onScopeChange = async (instance, options) => {
|
|
64
67
|
const { scopeKey } = this.options;
|
|
@@ -186,12 +189,14 @@ class SortField extends import_database.Field {
|
|
|
186
189
|
this.on("afterSync", this.initRecordsSortValue);
|
|
187
190
|
this.on("beforeUpdate", this.onScopeChange);
|
|
188
191
|
this.on("beforeCreate", this.setSortValue);
|
|
192
|
+
this.on("beforeBulkCreate", this.setSortValue);
|
|
189
193
|
}
|
|
190
194
|
unbind() {
|
|
191
195
|
super.unbind();
|
|
192
196
|
this.off("beforeUpdate", this.onScopeChange);
|
|
193
197
|
this.off("beforeCreate", this.setSortValue);
|
|
194
198
|
this.off("afterSync", this.initRecordsSortValue);
|
|
199
|
+
this.off("beforeBulkCreate", this.setSortValue);
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
202
|
// 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.7.0
|
|
3
|
+
"version": "1.7.0",
|
|
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": "767ae089e404a104d718962272289c0bec01803a"
|
|
24
24
|
}
|