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

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,c,C,g,A,l,u,h){"use strict";var ne=Object.defineProperty,re=Object.defineProperties;var ce=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,le=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,v=(s,e)=>{for(var n in e||(e={}))ue.call(e,n)&&H(s,n,e[n]);if($)for(var n of $(e))le.call(e,n)&&H(s,n,e[n]);return s},P=(s,e)=>re(s,ce(e));var m=(s,e,n)=>new Promise((c,C)=>{var g=u=>{try{l(n.next(u))}catch(h){C(h)}},A=u=>{try{l(n.throw(u))}catch(h){C(h)}},l=u=>u.done?c(u.value):Promise.resolve(u.value).then(g,A);l((n=n.apply(s,e)).next())});function J(){var d;const{dn:i}=e.useDesignable(),{t:o}=g.useTranslation(),a=c.useFieldSchema();return n.jsx(e.SchemaSettingsSelectItem,{title:o("Data will be updated"),options:[{label:o("Selected"),value:"selected"},{label:o("All"),value:"all"}],value:(d=a==null?void 0:a["x-action-settings"])==null?void 0:d.updateMode,onChange:p=>{a["x-action-settings"].updateMode=p,i.emit("patch",{schema:{"x-uid":a["x-uid"],"x-action-settings":a["x-action-settings"]}}),i.refresh()}})}function Q(){var d;const{dn:i}=e.useDesignable(),{t:o}=g.useTranslation(),a=c.useFieldSchema();return n.jsx(e.SchemaSettingsModalItem,{title:o("After successful submission"),initialValues:(d=a==null?void 0:a["x-action-settings"])==null?void 0:d.onSuccess,schema:{type:"object",title:o("After successful submission"),properties:{successMessage:{title:o("Popup message"),"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}},manualClose:{title:o("Popup close method"),enum:[{label:o("Automatic close"),value:!1},{label:o("Manually close"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{}},redirecting:{title:o("Then"),enum:[{label:o("Stay on current page"),value:!1},{label:o("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:o("Link"),"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:p=>{a["x-action-settings"].onSuccess=p,i.emit("patch",{schema:{"x-uid":a["x-uid"],"x-action-settings":a["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=c.useFieldSchema();return["customize:bulkUpdate","customize:bulkEdit"].includes(i["x-action"])}},{name:"assignFieldValues",Component:e.AssignedFieldValues},{name:"afterSuccess",Component:Q,useVisible(){var o;const i=c.useFieldSchema();return C.isValid((o=i==null?void 0:i["x-action-settings"])==null?void 0:o.onSuccess)}},{name:"refreshDataBlockRequest",Component:e.RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}}},{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(),o={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,P(v({},i),{schema:o,item:i}))},Z=()=>{const i=e.useSchemaInitializerItem();return n.jsx(e.BlockInitializer,P(v({},i),{item:i}))},ee="bulk-update";function te(){return g.useTranslation(ee,{nsMode:"fallback"})}const F=()=>{var j,E,L,O;const{field:i,resource:o,__parent:a,service:d}=e.useBlockRequestContext(),p=u.useContext(c.SchemaExpressionScopeContext),y=c.useFieldSchema(),B=e.useTableBlockContext(),{rowKey:se}=B,k=(O=(L=(E=(j=B.field)==null?void 0:j.data)==null?void 0:E.selectedRowKeys)!=null?L:p==null?void 0:p.selectedRecordKeys)!=null?O:{},q=h.useNavigate(),R=e.useCompile(),{t:U}=te(),x=c.useField(),{modal:D}=l.App.useApp(),I=e.useVariables();e.useRecord();const{name:de,getField:oe}=e.useCollection_deprecated(),ae=e.useLocalVariables();return{onClick(pe,S){return m(this,null,function*(){var N;const{assignedValues:G={},onSuccess:t,updateMode:K}=(N=y==null?void 0:y["x-action-settings"])!=null?N:{};x.data=i.data||{},x.data.loading=!0;const z={},ie=Object.keys(G).map(f=>m(this,null,function*(){const r=G[f],M=oe(f);if(e.isVariable(r)){const b=yield I==null?void 0:I.parseVariable(r,ae);b&&(z[f]=e.transformVariableValue(b,{targetCollectionField:M}))}else r!=null&&r!==""&&(z[f]=r)}));yield Promise.all(ie),D.confirm({title:U("Bulk update",{ns:"client"}),content:K==="selected"?U("Update selected data?",{ns:"client"}):U("Update all data?",{ns:"client"}),onOk(){return m(this,null,function*(){var M,b,T,_;const{filter:f}=(b=(M=d.params)==null?void 0:M[0])!=null?b:{},r={values:v({},z),filter:f,forceUpdate:!1};if(K==="selected"){if(!(k!=null&&k.length)){l.message.error(U("Please select the records to be updated")),x.data.loading=!1;return}r.filter={$and:[{[se||"id"]:{$in:k}}]}}r.filter||(r.forceUpdate=!0);try{yield o.update(r)}catch(me){}finally{x.data.loading=!1}S&&(S==null||S()),o instanceof e.TableFieldResource||(_=(T=a==null?void 0:a.service)==null?void 0:T.refresh)==null||_.call(T),t!=null&&t.successMessage&&(t!=null&&t.manualClose?D.success({title:R(t==null?void 0:t.successMessage),onOk:()=>m(this,null,function*(){t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(A.isURL(t.redirectTo)?window.location.href=t.redirectTo:q(t.redirectTo))})}):(l.message.success(R(t==null?void 0:t.successMessage)),t!=null&&t.redirecting&&(t!=null&&t.redirectTo)&&(A.isURL(t.redirectTo)?window.location.href=t.redirectTo:q(t.redirectTo))))})},onCancel(){return m(this,null,function*(){x.data.loading=!1})}})})}}};class w extends e.Plugin{load(){return m(this,null,function*(){this.app.addComponents({CustomizeActionInitializer:Z}),this.app.addScopes({useCustomizeBulkUpdateActionProps:F}),this.app.addScopes({useCustomizeBulkUpdateActionProps:F}),this.app.schemaSettingsManager.add(W),this.app.schemaSettingsManager.add(X);const o={title:'{{t("Bulk update")}}',Component:Y,name:"bulkUpdate",useVisible(){const a=e.useCollection_deprecated();return(a.template!=="view"||(a==null?void 0:a.writableView))&&a.template!=="file"&&a.template!=="sql"}};this.app.schemaInitializerManager.addItem("table:configureActions","customize.bulkUpdate",o),this.app.schemaInitializerManager.addItem("gantt:configureActions","customize.bulkUpdate",o),this.app.schemaInitializerManager.addItem("map:configureActions","customize.bulkUpdate",o)})}}s.PluginActionBulkUpdateClient=w,s.default=w,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,3 +1,3 @@
1
1
  export declare const useCustomizeBulkUpdateActionProps: () => {
2
- onClick(): Promise<void>;
2
+ onClick(e: any, callBack: any): Promise<void>;
3
3
  };
@@ -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.3",
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.3",
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.3",
11
+ "@nocobase/test": "0.21.0-alpha.3"
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.3",
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": "f7276aff14063a2cf825191a0c83aeacde05a912",
18
18
  "keywords": [
19
19
  "Actions"
20
20
  ]