@nocobase/plugin-action-bulk-update 0.21.0-alpha.1 → 0.21.0-alpha.2

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.
@@ -1 +1 @@
1
- (function(s,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("@formily/shared"),require("react-i18next"),require("@nocobase/utils/client"),require("antd"),require("react"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","@formily/shared","react-i18next","@nocobase/utils/client","antd","react","react-router-dom"],e):(s=typeof globalThis!="undefined"?globalThis:s||self,e(s["@nocobase/plugin-action-bulk-update"]={},s["@nocobase/client"],s.jsxRuntime,s["@formily/react"],s["@formily/shared"],s["react-i18next"],s["@nocobase/utils"],s.antd,s.react,s["react-router-dom"]))})(this,function(s,e,n,l,C,g,k,d,u,h){"use strict";var ne=Object.defineProperty,re=Object.defineProperties;var ce=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var H=(s,e,n)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n,T=(s,e)=>{for(var n in e||(e={}))le.call(e,n)&&H(s,n,e[n]);if($)for(var n of $(e))ue.call(e,n)&&H(s,n,e[n]);return s},B=(s,e)=>re(s,ce(e));var m=(s,e,n)=>new Promise((l,C)=>{var g=u=>{try{d(n.next(u))}catch(h){C(h)}},k=u=>{try{d(n.throw(u))}catch(h){C(h)}},d=u=>u.done?l(u.value):Promise.resolve(u.value).then(g,k);d((n=n.apply(s,e)).next())});function J(){var r;const{dn:i}=e.useDesignable(),{t:a}=g.useTranslation(),o=l.useFieldSchema();return n.jsx(e.SchemaSettingsSelectItem,{title:a("Data will be updated"),options:[{label:a("Selected"),value:"selected"},{label:a("All"),value:"all"}],value:(r=o==null?void 0:o["x-action-settings"])==null?void 0:r.updateMode,onChange:p=>{o["x-action-settings"].updateMode=p,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-action-settings":o["x-action-settings"]}}),i.refresh()}})}function Q(){var r;const{dn:i}=e.useDesignable(),{t:a}=g.useTranslation(),o=l.useFieldSchema();return n.jsx(e.SchemaSettingsModalItem,{title:a("After successful submission"),initialValues:(r=o==null?void 0:o["x-action-settings"])==null?void 0:r.onSuccess,schema:{type:"object",title:a("After successful submission"),properties:{successMessage:{title:a("Popup message"),"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}},manualClose:{title:a("Popup close method"),enum:[{label:a("Automatic close"),value:!1},{label:a("Manually close"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{}},redirecting:{title:a("Then"),enum:[{label:a("Stay on current page"),value:!1},{label:a("Redirect to"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{!!$self.value}}"}}}},redirectTo:{title:a("Link"),"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:p=>{o["x-action-settings"].onSuccess=p,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-action-settings":o["x-action-settings"]}})}})}const P=[{name:"editButton",Component:e.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:i}=e.useSchemaToolbar();return i}},{name:"updateMode",Component:J,useVisible(){const i=l.useFieldSchema();return["customize:bulkUpdate","customize:bulkEdit"].includes(i["x-action"])}},{name:"assignFieldValues",Component:e.AssignedFieldValues},{name:"afterSuccess",Component:Q,useVisible(){var a;const i=l.useFieldSchema();return C.isValid((a=i==null?void 0:i["x-action-settings"])==null?void 0:a.onSuccess)}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:i}=e.useSchemaToolbar();return i}}],W=new e.SchemaSettings({name:"ActionSettings:customize:bulkUpdate",items:P}),X=new e.SchemaSettings({name:"actionSettings:bulkUpdate",items:P}),Y=()=>{const i=e.useSchemaInitializerItem(),a={type:"void",title:'{{ t("Bulk update") }}',"x-component":"Action","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-action":"customize:bulkUpdate","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:bulkUpdate","x-action-settings":{assignedValues:{},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component-props":{icon:"EditOutlined",useProps:"{{ useCustomizeBulkUpdateActionProps }}"}};return n.jsx(e.BlockInitializer,B(T({},i),{schema:a,item:i}))},Z=()=>{const i=e.useSchemaInitializerItem();return n.jsx(e.BlockInitializer,B(T({},i),{item:i}))},ee="bulk-update";function te(){return g.useTranslation(ee,{nsMode:"fallback"})}const V=()=>{var R,D,E,L;const{field:i,resource:a,__parent:o,service:r}=e.useBlockRequestContext(),p=u.useContext(l.SchemaExpressionScopeContext),y=l.useFieldSchema(),F=e.useTableBlockContext(),{rowKey:se}=F,A=(L=(E=(D=(R=F.field)==null?void 0:R.data)==null?void 0:D.selectedRowKeys)!=null?E:p==null?void 0:p.selectedRecordKeys)!=null?L:{},w=h.useNavigate(),q=e.useCompile(),{t:U}=te(),x=l.useField(),{modal:j}=d.App.useApp(),I=e.useVariables();e.useRecord();const{name:de,getField:ae}=e.useCollection_deprecated(),oe=e.useLocalVariables();return{onClick(){return m(this,null,function*(){var K;const{assignedValues:O={},onSuccess:t,updateMode:G}=(K=y==null?void 0:y["x-action-settings"])!=null?K:{};x.data=i.data||{},x.data.loading=!0;const z={},ie=Object.keys(O).map(f=>m(this,null,function*(){const c=O[f],S=ae(f);if(e.isVariable(c)){const b=yield I==null?void 0:I.parseVariable(c,oe);b&&(z[f]=e.transformVariableValue(b,{targetCollectionField:S}))}else c!=null&&c!==""&&(z[f]=c)}));yield Promise.all(ie),j.confirm({title:U("Bulk update",{ns:"client"}),content:G==="selected"?U("Update selected data?",{ns:"client"}):U("Update all data?",{ns:"client"}),onOk(){return m(this,null,function*(){var S,b,N,M,_;const{filter:f}=(b=(S=r.params)==null?void 0:S[0])!=null?b:{},c={values:T({},z),filter:f,forceUpdate:!1};if(G==="selected"){if(!(A!=null&&A.length)){d.message.error(U("Please select the records to be updated")),x.data.loading=!1;return}c.filter={$and:[{[se||"id"]:{$in:A}}]}}c.filter||(c.forceUpdate=!0);try{yield a.update(c)}catch(pe){}finally{x.data.loading=!1}(N=r==null?void 0:r.refresh)==null||N.call(r),a instanceof e.TableFieldResource||(_=(M=o==null?void 0:o.service)==null?void 0:M.refresh)==null||_.call(M),t!=null&&t.successMessage&&(t!=null&&t.manualClose?j.success({title:q(t==null?void 0:t.successMessage),onOk:()=>m(this,null,function*(){t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(k.isURL(t.redirectTo)?window.location.href=t.redirectTo:w(t.redirectTo))})}):(d.message.success(q(t==null?void 0:t.successMessage)),t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(k.isURL(t.redirectTo)?window.location.href=t.redirectTo:w(t.redirectTo))))})},onCancel(){return m(this,null,function*(){x.data.loading=!1})}})})}}};class v extends e.Plugin{load(){return m(this,null,function*(){this.app.addComponents({CustomizeActionInitializer:Z}),this.app.addScopes({useCustomizeBulkUpdateActionProps:V}),this.app.addScopes({useCustomizeBulkUpdateActionProps:V}),this.app.schemaSettingsManager.add(W),this.app.schemaSettingsManager.add(X);const a={title:'{{t("Bulk update")}}',Component:Y,name:"bulkUpdate",useVisible(){const o=e.useCollection_deprecated();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}};this.app.schemaInitializerManager.addItem("table:configureActions","customize.bulkUpdate",a),this.app.schemaInitializerManager.addItem("gantt:configureActions","customize.bulkUpdate",a),this.app.schemaInitializerManager.addItem("map:configureActions","customize.bulkUpdate",a)})}}s.PluginActionBulkUpdateClient=v,s.default=v,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(s,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("@formily/shared"),require("react-i18next"),require("@nocobase/utils/client"),require("antd"),require("react"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","@formily/shared","react-i18next","@nocobase/utils/client","antd","react","react-router-dom"],e):(s=typeof globalThis!="undefined"?globalThis:s||self,e(s["@nocobase/plugin-action-bulk-update"]={},s["@nocobase/client"],s.jsxRuntime,s["@formily/react"],s["@formily/shared"],s["react-i18next"],s["@nocobase/utils"],s.antd,s.react,s["react-router-dom"]))})(this,function(s,e,n,l,C,g,k,d,u,x){"use strict";var ne=Object.defineProperty,re=Object.defineProperties;var ce=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var H=(s,e,n)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n,T=(s,e)=>{for(var n in e||(e={}))le.call(e,n)&&H(s,n,e[n]);if($)for(var n of $(e))ue.call(e,n)&&H(s,n,e[n]);return s},B=(s,e)=>re(s,ce(e));var m=(s,e,n)=>new Promise((l,C)=>{var g=u=>{try{d(n.next(u))}catch(x){C(x)}},k=u=>{try{d(n.throw(u))}catch(x){C(x)}},d=u=>u.done?l(u.value):Promise.resolve(u.value).then(g,k);d((n=n.apply(s,e)).next())});function J(){var r;const{dn:i}=e.useDesignable(),{t:a}=g.useTranslation(),o=l.useFieldSchema();return n.jsx(e.SchemaSettingsSelectItem,{title:a("Data will be updated"),options:[{label:a("Selected"),value:"selected"},{label:a("All"),value:"all"}],value:(r=o==null?void 0:o["x-action-settings"])==null?void 0:r.updateMode,onChange:p=>{o["x-action-settings"].updateMode=p,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-action-settings":o["x-action-settings"]}}),i.refresh()}})}function Q(){var r;const{dn:i}=e.useDesignable(),{t:a}=g.useTranslation(),o=l.useFieldSchema();return n.jsx(e.SchemaSettingsModalItem,{title:a("After successful submission"),initialValues:(r=o==null?void 0:o["x-action-settings"])==null?void 0:r.onSuccess,schema:{type:"object",title:a("After successful submission"),properties:{successMessage:{title:a("Popup message"),"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}},manualClose:{title:a("Popup close method"),enum:[{label:a("Automatic close"),value:!1},{label:a("Manually close"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{}},redirecting:{title:a("Then"),enum:[{label:a("Stay on current page"),value:!1},{label:a("Redirect to"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{!!$self.value}}"}}}},redirectTo:{title:a("Link"),"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:p=>{o["x-action-settings"].onSuccess=p,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-action-settings":o["x-action-settings"]}})}})}const V=[{name:"editButton",Component:e.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:i}=e.useSchemaToolbar();return i}},{name:"updateMode",Component:J,useVisible(){const i=l.useFieldSchema();return["customize:bulkUpdate","customize:bulkEdit"].includes(i["x-action"])}},{name:"assignFieldValues",Component:e.AssignedFieldValues},{name:"afterSuccess",Component:Q,useVisible(){var a;const i=l.useFieldSchema();return C.isValid((a=i==null?void 0:i["x-action-settings"])==null?void 0:a.onSuccess)}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:i}=e.useSchemaToolbar();return i}}],W=new e.SchemaSettings({name:"ActionSettings:customize:bulkUpdate",items:V}),X=new e.SchemaSettings({name:"actionSettings:bulkUpdate",items:V}),Y=()=>{const i=e.useSchemaInitializerItem(),a={type:"void",title:'{{ t("Bulk update") }}',"x-component":"Action","x-use-component-props":"useCustomizeBulkUpdateActionProps","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-action":"customize:bulkUpdate","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:bulkUpdate","x-action-settings":{assignedValues:{},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component-props":{icon:"EditOutlined"}};return n.jsx(e.BlockInitializer,B(T({},i),{schema:a,item:i}))},Z=()=>{const i=e.useSchemaInitializerItem();return n.jsx(e.BlockInitializer,B(T({},i),{item:i}))},ee="bulk-update";function te(){return g.useTranslation(ee,{nsMode:"fallback"})}const v=()=>{var R,D,E,L;const{field:i,resource:a,__parent:o,service:r}=e.useBlockRequestContext(),p=u.useContext(l.SchemaExpressionScopeContext),y=l.useFieldSchema(),F=e.useTableBlockContext(),{rowKey:se}=F,A=(L=(E=(D=(R=F.field)==null?void 0:R.data)==null?void 0:D.selectedRowKeys)!=null?E:p==null?void 0:p.selectedRecordKeys)!=null?L:{},w=x.useNavigate(),q=e.useCompile(),{t:U}=te(),h=l.useField(),{modal:j}=d.App.useApp(),I=e.useVariables();e.useRecord();const{name:de,getField:ae}=e.useCollection_deprecated(),oe=e.useLocalVariables();return{onClick(){return m(this,null,function*(){var K;const{assignedValues:O={},onSuccess:t,updateMode:G}=(K=y==null?void 0:y["x-action-settings"])!=null?K:{};h.data=i.data||{},h.data.loading=!0;const z={},ie=Object.keys(O).map(f=>m(this,null,function*(){const c=O[f],S=ae(f);if(e.isVariable(c)){const b=yield I==null?void 0:I.parseVariable(c,oe);b&&(z[f]=e.transformVariableValue(b,{targetCollectionField:S}))}else c!=null&&c!==""&&(z[f]=c)}));yield Promise.all(ie),j.confirm({title:U("Bulk update",{ns:"client"}),content:G==="selected"?U("Update selected data?",{ns:"client"}):U("Update all data?",{ns:"client"}),onOk(){return m(this,null,function*(){var S,b,N,M,_;const{filter:f}=(b=(S=r.params)==null?void 0:S[0])!=null?b:{},c={values:T({},z),filter:f,forceUpdate:!1};if(G==="selected"){if(!(A!=null&&A.length)){d.message.error(U("Please select the records to be updated")),h.data.loading=!1;return}c.filter={$and:[{[se||"id"]:{$in:A}}]}}c.filter||(c.forceUpdate=!0);try{yield a.update(c)}catch(pe){}finally{h.data.loading=!1}(N=r==null?void 0:r.refresh)==null||N.call(r),a instanceof e.TableFieldResource||(_=(M=o==null?void 0:o.service)==null?void 0:M.refresh)==null||_.call(M),t!=null&&t.successMessage&&(t!=null&&t.manualClose?j.success({title:q(t==null?void 0:t.successMessage),onOk:()=>m(this,null,function*(){t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(k.isURL(t.redirectTo)?window.location.href=t.redirectTo:w(t.redirectTo))})}):(d.message.success(q(t==null?void 0:t.successMessage)),t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(k.isURL(t.redirectTo)?window.location.href=t.redirectTo:w(t.redirectTo))))})},onCancel(){return m(this,null,function*(){h.data.loading=!1})}})})}}};class P extends e.Plugin{load(){return m(this,null,function*(){this.app.addComponents({CustomizeActionInitializer:Z}),this.app.addScopes({useCustomizeBulkUpdateActionProps:v}),this.app.addScopes({useCustomizeBulkUpdateActionProps:v}),this.app.schemaSettingsManager.add(W),this.app.schemaSettingsManager.add(X);const a={title:'{{t("Bulk update")}}',Component:Y,name:"bulkUpdate",useVisible(){const o=e.useCollection_deprecated();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}};this.app.schemaInitializerManager.addItem("table:configureActions","customize.bulkUpdate",a),this.app.schemaInitializerManager.addItem("gantt:configureActions","customize.bulkUpdate",a),this.app.schemaInitializerManager.addItem("map:configureActions","customize.bulkUpdate",a)})}}s.PluginActionBulkUpdateClient=P,s.default=P,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,12 +1,12 @@
1
1
  module.exports = {
2
2
  "@formily/react": "2.3.0",
3
3
  "@formily/shared": "2.3.0",
4
- "@nocobase/client": "0.21.0-alpha.1",
4
+ "@nocobase/client": "0.21.0-alpha.2",
5
5
  "react-i18next": "11.18.6",
6
6
  "react": "18.2.0",
7
- "@nocobase/utils": "0.21.0-alpha.1",
7
+ "@nocobase/utils": "0.21.0-alpha.2",
8
8
  "antd": "5.12.8",
9
9
  "react-router-dom": "6.21.0",
10
- "@nocobase/server": "0.21.0-alpha.1",
11
- "@nocobase/test": "0.21.0-alpha.1"
10
+ "@nocobase/server": "0.21.0-alpha.2",
11
+ "@nocobase/test": "0.21.0-alpha.2"
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-action-bulk-update",
3
- "version": "0.21.0-alpha.1",
3
+ "version": "0.21.0-alpha.2",
4
4
  "main": "dist/server/index.js",
5
5
  "homepage": "https://docs.nocobase.com/handbook/action-bulk-update",
6
6
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-bulk-update",
@@ -14,7 +14,7 @@
14
14
  "@nocobase/server": "0.x",
15
15
  "@nocobase/test": "0.x"
16
16
  },
17
- "gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff",
17
+ "gitHead": "90628f2e2da846208fb2d7966ddb4e467d187ffb",
18
18
  "keywords": [
19
19
  "Actions"
20
20
  ]