@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 CHANGED
@@ -1,4 +1,4 @@
1
- Updated Date: February 20, 2025
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 an Enterprise Edition License can sell Upper Layer Application to their clients.
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 an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license.
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 an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license with access to further development and configuration.
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
 
@@ -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}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};r.r(o),r.d(o,{PluginFieldSortClient:function(){return O},default:function(){return x}});var i=r("772");function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=function(e){function t(){var e,n,r,o,a,f;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=c(r),u(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,l()?Reflect.construct(r,o||[],c(n).constructor):r.apply(n,o)),"name","sort"),u(e,"type","object"),u(e,"group","advanced"),u(e,"order",1),u(e,"title",'{{t("Sort")}}'),u(e,"sortable",!0),u(e,"titleUsable",!0),u(e,"description",'{{t("Used for drag and drop sorting scenarios, supporting grouping sorting")}}'),u(e,"default",{type:"sort",uiSchema:{type:"number","x-component":"InputNumber","x-component-props":{stringMode:!0,step:"1"},"x-validator":"integer"}}),u(e,"availableTypes",["sort"]),u(e,"hasDefaultValue",!1),u(e,"properties",(a=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){u(e,t,n[t])})}return e}({},i.defaultProps),f=(f={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.')}}"}},f),Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(f)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(f)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(f,e))}),a)),u(e,"filterable",{operators:i.operators.number}),u(e,"validateSchema",function(e){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(i.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(i.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:"/"}}}}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(t,e),t}(i.CollectionFieldInterface);function p(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){p(i,r,o,u,c,"next",e)}function c(e){p(i,r,o,u,c,"throw",e)}u(void 0)})}}function b(e,t,n){return(b=g()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&m(o,n.prototype),o}).apply(null,arguments)}function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e){var t="function"==typeof Map?new Map:void 0;return(v=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).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 b(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),m(r,e)})(e)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}function h(e,t){var n,r,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){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var O=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=d(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,g()?Reflect.construct(t,n||[],d(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return s(function(){return h(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return s(function(){return h(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return s(function(){return h(this,function(t){return e.app.addFieldInterfaces([f]),[2]})})()}}],y(t.prototype,n),o}(v(i.Plugin)),x=O;return o}()});
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}()});
@@ -8,12 +8,12 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.7.0-beta.8",
11
+ "@nocobase/client": "1.7.0",
12
12
  "lodash": "4.17.21",
13
- "@nocobase/database": "1.7.0-beta.8",
14
- "@nocobase/actions": "1.7.0-beta.8",
15
- "@nocobase/server": "1.7.0-beta.8",
16
- "@nocobase/data-source-manager": "1.7.0-beta.8",
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-beta.8"
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: (instance: any, options: any) => Promise<void>;
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 (instance, options) => {
40
+ setSortValue = async (instances, options) => {
41
41
  const { name, scopeKey } = this.options;
42
42
  const { model } = this.context.collection;
43
- if ((0, import_lodash.isNumber)(instance.get(name)) && instance._previousDataValues[scopeKey] == instance[scopeKey]) {
44
- return;
45
- }
46
- const where = {};
47
- if (scopeKey) {
48
- const value = instance.get(scopeKey);
49
- if (value !== void 0 && value !== null) {
50
- where[scopeKey] = value;
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-beta.8",
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": "9ad35ee90db98d95dfa660645d155f4f4e81b47c"
23
+ "gitHead": "767ae089e404a104d718962272289c0bec01803a"
24
24
  }