@nocobase/plugin-action-bulk-update 0.19.0-alpha.6 → 0.19.0-alpha.8

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