@nocobase/plugin-action-duplicate
Advanced tools
Comparing version 0.21.0-alpha.2 to 0.21.0-alpha.3
@@ -1,2 +0,2 @@ | ||
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@emotion/css"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@formily/core"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@emotion/css","@formily/react","antd","react","react-i18next","@formily/core","lodash"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-action-duplicate"]={},o["@nocobase/client"],o.jsxRuntime,o["@emotion/css"],o["@formily/react"],o.antd,o.react,o["react-i18next"],o["@formily/core"],o.lodash))})(this,function(o,e,i,d,p,M,b,q,y,T){"use strict";var he=Object.defineProperty,xe=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var oe=(o,e,i)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,x=(o,e)=>{for(var i in e||(e={}))ne.call(e,i)&&oe(o,i,e[i]);if(j)for(var i of j(e))ie.call(e,i)&&oe(o,i,e[i]);return o},g=(o,e)=>xe(o,ge(e));var ce=(o,e)=>{var i={};for(var d in o)ne.call(o,d)&&e.indexOf(d)<0&&(i[d]=o[d]);if(o!=null&&j)for(var d of j(o))e.indexOf(d)<0&&ie.call(o,d)&&(i[d]=o[d]);return i};var L=(o,e,i)=>new Promise((d,p)=>{var M=y=>{try{q(i.next(y))}catch(T){p(T)}},b=y=>{try{q(i.throw(y))}catch(T){p(T)}},q=y=>y.done?d(y.value):Promise.resolve(y.value).then(M,b);q((i=i.apply(o,e)).next())});const E=d.css` | ||
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@emotion/css"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@formily/core"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@emotion/css","@formily/react","antd","react","react-i18next","@formily/core","lodash"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-action-duplicate"]={},o["@nocobase/client"],o.jsxRuntime,o["@emotion/css"],o["@formily/react"],o.antd,o.react,o["react-i18next"],o["@formily/core"],o.lodash))})(this,function(o,e,i,d,p,I,b,q,y,T){"use strict";var he=Object.defineProperty,xe=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var oe=(o,e,i)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,x=(o,e)=>{for(var i in e||(e={}))ne.call(e,i)&&oe(o,i,e[i]);if(j)for(var i of j(e))ie.call(e,i)&&oe(o,i,e[i]);return o},g=(o,e)=>xe(o,ge(e));var ce=(o,e)=>{var i={};for(var d in o)ne.call(o,d)&&e.indexOf(d)<0&&(i[d]=o[d]);if(o!=null&&j)for(var d of j(o))e.indexOf(d)<0&&ie.call(o,d)&&(i[d]=o[d]);return i};var L=(o,e,i)=>new Promise((d,p)=>{var I=y=>{try{q(i.next(y))}catch(T){p(T)}},b=y=>{try{q(i.throw(y))}catch(T){p(T)}},q=y=>y.done?d(y.value):Promise.resolve(y.value).then(I,b);q((i=i.apply(o,e)).next())});const E=d.css` | ||
position: relative; | ||
@@ -39,3 +39,3 @@ &:hover { | ||
} | ||
`,K=p.observer(t=>{var Z,ee;const{children:c}=t,{message:s}=M.App.useApp(),n=p.useField(),u=p.useFieldSchema(),C=e.useAPIClient(),m=n.disabled||t.disabled,{designable:k}=e.useDesignable(),[z,S]=b.useState(!1),[h,_]=b.useState(!1),{service:v,__parent:w,block:V}=e.useBlockRequestContext(),{duplicateFields:D,duplicateMode:N="quickDulicate",duplicateCollection:B}=u["x-component-props"],l=e.useRecord(),f=e.useCollectionParentRecordData(),{id:a,__collection:r}=l,A=e.useActionContext(),{name:P}=e.useCollection_deprecated(),{getCollectionFields:pe}=e.useCollectionManager_deprecated(),{t:F}=q.useTranslation(),de=pe(r||P),ue=e.useFormBlockContext(),W={key:"duplicate",dataId:a,default:!0,fields:(D==null?void 0:D.filter(I=>de.find(O=>I.includes(O.name))))||[],collection:r||P},X=u["x-component"]==="Action.Link",me=()=>L(this,null,function*(){var I,O,te;_(!0);try{const $=yield e.fetchTemplateData(C,W,F);yield C.resource(r||P).create({values:x({},$)}),s.success(F("Saved successfully")),V==="form"?(O=(I=w==null?void 0:w.service)==null?void 0:I.refresh)==null||O.call(I):yield(te=v==null?void 0:v.refresh)==null?void 0:te.call(v),_(!1)}catch($){_(!1),console.error($)}}),Y=()=>{!m&&!h&&((D==null?void 0:D.length)>0?N==="quickDulicate"?me():S(!0):s.error(F("Please configure the duplicate fields")))};return i.jsx("div",{className:d.cx(E,{[d.css` | ||
`,K=p.observer(t=>{var Z,ee;const{children:c}=t,{message:s}=I.App.useApp(),n=p.useField(),u=p.useFieldSchema(),C=e.useAPIClient(),m=n.disabled||t.disabled,{designable:k}=e.useDesignable(),[_,S]=b.useState(!1),[h,w]=b.useState(!1),{service:v,__parent:z,block:V}=e.useBlockRequestContext(),{duplicateFields:D,duplicateMode:N="quickDulicate",duplicateCollection:B}=u["x-component-props"],l=e.useRecord(),f=e.useCollectionParentRecordData(),{id:a,__collection:r}=l,A=e.useActionContext(),{name:P}=e.useCollection_deprecated(),{getCollectionFields:pe}=e.useCollectionManager_deprecated(),{t:F}=q.useTranslation(),de=pe(r||P),ue=e.useFormBlockContext(),W={key:"duplicate",dataId:a,default:!0,fields:(D==null?void 0:D.filter(M=>de.find(O=>M.includes(O.name))))||[],collection:r||P},X=u["x-component"]==="Action.Link",me=()=>L(this,null,function*(){var M,O,te;w(!0);try{const $=yield e.fetchTemplateData(C,W,F);yield C.resource(r||P).create({values:x({},$)}),s.success(F("Saved successfully")),V==="form"?(O=(M=z==null?void 0:z.service)==null?void 0:M.refresh)==null||O.call(M):yield(te=v==null?void 0:v.refresh)==null?void 0:te.call(v),w(!1)}catch($){w(!1),console.error($)}}),Y=()=>{!m&&!h&&((D==null?void 0:D.length)>0?N==="quickDulicate"?me():S(!0):s.error(F("Please configure the duplicate fields")))};return i.jsx("div",{className:d.cx(E,{[d.css` | ||
.general-schema-designer { | ||
@@ -47,2 +47,2 @@ top: -10px; | ||
} | ||
`]:X}),children:i.jsx(e.FormBlockContext.Provider,{value:g(x({},ue),{duplicateData:{display:!1,enabled:!0,defaultTemplate:W}}),children:i.jsxs("div",{children:[X?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:k&&((Z=n==null?void 0:n.data)==null?void 0:Z.hidden)&&.1,cursor:h?"not-allowed":"pointer",position:"relative"},onClick:Y,children:h?F("Duplicating"):c||F("Duplicate")}):i.jsx(M.Button,g(x({role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:k&&((ee=n==null?void 0:n.data)==null?void 0:ee.hidden)&&.1}},t),{onClick:Y,children:h?F("Duplicating"):c||F("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:B||P,children:i.jsx(e.RecordProvider,{record:g(x({},l),{__collection:B||r}),parent:f,children:i.jsx(e.ActionContextProvider,{value:g(x({},A),{visible:z,setVisible:S}),children:i.jsx(p.RecursionField,{schema:u,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),R=p.connect(M.Tree,p.mapProps((t,c)=>{b.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,n]=b.useState(t.defaultCheckedKeys||[]),u=m=>{n(m),c.value=m};c.onCheck=u;const C=p.useForm();return g(x({},t),{checkedKeys:s,onCheck:u,treeData:t==null?void 0:t.treeData.map(m=>{var k;if(C.values.duplicateMode==="quickDulicate"){const z=(k=m==null?void 0:m.children)==null?void 0:k.map(S=>g(x({},S),{disabled:!1}));return g(x({},m),{disabled:!1,children:z})}return m})})})),G=(t,c)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const s=t[n],{children:u}=s,C=ce(s,["children"]);c.push(C.key),u&&G(u,c)}return c},H=t=>t.reduceProperties((s,n)=>n["x-decorator"]==="FormBlockProvider"?n:H(n),null);function ae(){var V,D,N,B;const{dn:t}=e.useDesignable(),{t:c}=q.useTranslation(),s=p.useField(),n=p.useFieldSchema(),{name:u}=e.useCollection_deprecated(),{collectionList:C,getEnableFieldTree:m,getOnLoadData:k,getOnCheck:z}=e.useCollectionState(u),S=T.cloneDeep(((V=n["x-component-props"])==null?void 0:V.duplicateFields)||[]),h=e.useRecord(),_=b.useCallback((l,f,a)=>{a.query("duplicateFields").take(r=>{r.componentProps.treeData=l,r.componentProps.defaultCheckedKeys=f,r.setInitialValue(f),r==null||r.onCheck(f),a.setValues(g(x({},a.values),{treeData:l}))})},[]),v=l=>({run(){return L(this,null,function*(){l.query("duplicateFields").take(a=>{var A;const r=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=r,a.setInitialValue(r),(A=a==null?void 0:a.onCheck)==null||A.call(a,r)})})}}),w=l=>({run(){return L(this,null,function*(){l.query("duplicateFields").take(a=>{a.componentProps.defaultCheckedKeys=[],a.setInitialValue([]),a==null||a.onCheck([])})})}});return i.jsx(e.SchemaSettingsModalItem,{title:c("Duplicate mode"),components:{Tree:R},scope:{getEnableFieldTree:m,collectionName:((D=n["x-component-props"])==null?void 0:D.duplicateCollection)||(h==null?void 0:h.__collection)||u,currentCollection:(h==null?void 0:h.__collection)||u,getOnLoadData:k,getOnCheck:z,treeData:(N=n["x-component-props"])==null?void 0:N.treeData,duplicateValues:S,onFieldInputValueChange:y.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((B=n["x-component-props"])==null?void 0:B.duplicateMode)||"quickDulicate",enum:[{value:"quickDulicate",label:'{{t("Direct duplicate")}}'},{value:"continueduplicate",label:'{{t("Copy into the form and continue to fill in")}}'}]},collection:{type:"string",title:'{{ t("Target collection") }}',required:!0,description:c("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":C.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:C},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{disabled:'{{ $deps[0]==="quickDulicate" }}',value:'{{ $deps[0]==="quickDulicate"? currentCollection:collectionName }}'}}}]},syncFromForm:{type:"void",title:'{{ t("Sync from form fields") }}',"x-component":"Action.Link","x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{var f;const l=b.useMemo(()=>H(n),[n]);return e.useSyncFromForm(l,((f=n["x-component-props"])==null?void 0:f.duplicateCollection)||(h==null?void 0:h.__collection)||u,_)}},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]!=="quickDulicate" }}'}}}]},selectAll:{type:"void",title:'{{ t("Select all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]==="quickDulicate"}}'}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{const l=p.useForm();return v(l)}}},unselectAll:{type:"void",title:'{{ t("UnSelect all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode",".duplicateFields"],fulfill:{state:{visible:`{{ $deps[0]==="quickDulicate"&&$form.getValuesIn('duplicateFields').length>0 }}`}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200,marginRight:"10px"},useAction:()=>{const l=p.useForm();return w(l)}}},duplicateFields:{type:"array",title:'{{ t("Data fields") }}',required:!0,description:c("Only the selected fields will be used as the initialization data for the form"),"x-decorator":"FormItem","x-component":R,"x-component-props":{defaultCheckedKeys:S,treeData:[],checkable:!0,checkStrictly:!0,selectable:!1,loadData:"{{ getOnLoadData($self) }}",onCheck:"{{ getOnCheck($self) }}",rootStyle:{padding:"8px 0",border:"1px solid #d9d9d9",borderRadius:"2px",maxHeight:"30vh",overflow:"auto",margin:"2px 0"}},"x-reactions":[{dependencies:[".collection",".duplicateMode"],fulfill:{state:{disabled:"{{ !$deps[0] }}",componentProps:{treeData:"{{ getEnableFieldTree($deps[0], $self,treeData) }}"}}}}]}}},onSubmit:({duplicateMode:l,collection:f,duplicateFields:a,treeData:r})=>{var P;const A=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=A,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=l,n["x-component-props"].duplicateFields=A,n["x-component-props"].duplicateCollection=f,n["x-component-props"].treeData=r||((P=s.componentProps)==null?void 0:P.treeData),t.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n["x-component-props"])}}),t.refresh()}})}const U=[{name:"Customize",Component:t=>t.children,children:[{name:"editButton",Component:e.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=e.useSchemaToolbar();return t}},{name:"linkageRules",Component:e.SchemaSettingsLinkageRules,useComponentProps(){const{name:t}=e.useCollection_deprecated(),{linkageRulesProps:c}=e.useSchemaToolbar();return g(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:ae,useVisible(){return p.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=p.useFieldSchema(),c=["create","update","view","customize:popup","duplicate","customize:create"].includes(t["x-action"]||"");return{openMode:c,openSize:c}}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:t}=e.useSchemaToolbar();return t}}]}],se=new e.SchemaSettings({name:"ActionSettings:duplicate",items:U}),le=new e.SchemaSettings({name:"actionSettings:duplicate",items:U}),Q=t=>{const c={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",component:"DuplicateAction"},properties:{drawer:{type:"void",title:'{{ t("Duplicate") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",properties:{tab1:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}}}};return i.jsx(e.ActionInitializer,g(x({},t),{schema:c}))},re=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:Q,DuplicateAction:K},children:t.children});class J extends e.Plugin{load(){return L(this,null,function*(){this.app.use(re),this.app.addComponents({DuplicateActionInitializer:Q,DuplicateAction:K}),this.app.schemaSettingsManager.add(se),this.app.schemaSettingsManager.add(le);const c={title:'{{t("Duplicate")}}',Component:"DuplicateActionInitializer",schema:{"x-component":"Action.Link","x-action":"duplicate","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:duplicate","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible(){const s=e.useCollection_deprecated();return(s.template!=="view"||(s==null?void 0:s.writableView))&&s.template!=="file"&&s.template!=="sql"}};this.app.schemaInitializerManager.addItem("table:configureItemActions","actions.duplicate",c)})}}o.DuplicateAction=K,o.PluginActionDuplicateClient=J,o.actionDesignerCss=E,o.default=J,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
`]:X}),children:i.jsx(e.FormBlockContext.Provider,{value:g(x({},ue),{duplicateData:{display:!1,enabled:!0,defaultTemplate:W}}),children:i.jsxs("div",{children:[X?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:k&&((Z=n==null?void 0:n.data)==null?void 0:Z.hidden)&&.1,cursor:h?"not-allowed":"pointer",position:"relative"},onClick:Y,children:h?F("Duplicating"):c||F("Duplicate")}):i.jsx(I.Button,g(x({role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:k&&((ee=n==null?void 0:n.data)==null?void 0:ee.hidden)&&.1}},t),{onClick:Y,children:h?F("Duplicating"):c||F("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:B||P,children:i.jsx(e.RecordProvider,{record:g(x({},l),{__collection:B||r}),parent:f,children:i.jsx(e.ActionContextProvider,{value:g(x({},A),{visible:_,setVisible:S}),children:i.jsx(p.RecursionField,{schema:u,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),R=p.connect(I.Tree,p.mapProps((t,c)=>{b.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,n]=b.useState(t.defaultCheckedKeys||[]),u=m=>{n(m),c.value=m};c.onCheck=u;const C=p.useForm();return g(x({},t),{checkedKeys:s,onCheck:u,treeData:t==null?void 0:t.treeData.map(m=>{var k;if(C.values.duplicateMode==="quickDulicate"){const _=(k=m==null?void 0:m.children)==null?void 0:k.map(S=>g(x({},S),{disabled:!1}));return g(x({},m),{disabled:!1,children:_})}return m})})})),G=(t,c)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const s=t[n],{children:u}=s,C=ce(s,["children"]);c.push(C.key),u&&G(u,c)}return c},H=t=>t.reduceProperties((s,n)=>n["x-decorator"]==="FormBlockProvider"?n:H(n),null);function ae(){var V,D,N,B;const{dn:t}=e.useDesignable(),{t:c}=q.useTranslation(),s=p.useField(),n=p.useFieldSchema(),{name:u}=e.useCollection_deprecated(),{collectionList:C,getEnableFieldTree:m,getOnLoadData:k,getOnCheck:_}=e.useCollectionState(u),S=T.cloneDeep(((V=n["x-component-props"])==null?void 0:V.duplicateFields)||[]),h=e.useRecord(),w=b.useCallback((l,f,a)=>{a.query("duplicateFields").take(r=>{r.componentProps.treeData=l,r.componentProps.defaultCheckedKeys=f,r.setInitialValue(f),r==null||r.onCheck(f),a.setValues(g(x({},a.values),{treeData:l}))})},[]),v=l=>({run(){return L(this,null,function*(){l.query("duplicateFields").take(a=>{var A;const r=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=r,a.setInitialValue(r),(A=a==null?void 0:a.onCheck)==null||A.call(a,r)})})}}),z=l=>({run(){return L(this,null,function*(){l.query("duplicateFields").take(a=>{a.componentProps.defaultCheckedKeys=[],a.setInitialValue([]),a==null||a.onCheck([])})})}});return i.jsx(e.SchemaSettingsModalItem,{title:c("Duplicate mode"),components:{Tree:R},scope:{getEnableFieldTree:m,collectionName:((D=n["x-component-props"])==null?void 0:D.duplicateCollection)||(h==null?void 0:h.__collection)||u,currentCollection:(h==null?void 0:h.__collection)||u,getOnLoadData:k,getOnCheck:_,treeData:(N=n["x-component-props"])==null?void 0:N.treeData,duplicateValues:S,onFieldInputValueChange:y.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((B=n["x-component-props"])==null?void 0:B.duplicateMode)||"quickDulicate",enum:[{value:"quickDulicate",label:'{{t("Direct duplicate")}}'},{value:"continueduplicate",label:'{{t("Copy into the form and continue to fill in")}}'}]},collection:{type:"string",title:'{{ t("Target collection") }}',required:!0,description:c("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":C.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:C},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{disabled:'{{ $deps[0]==="quickDulicate" }}',value:'{{ $deps[0]==="quickDulicate"? currentCollection:collectionName }}'}}}]},syncFromForm:{type:"void",title:'{{ t("Sync from form fields") }}',"x-component":"Action.Link","x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{var f;const l=b.useMemo(()=>H(n),[n]);return e.useSyncFromForm(l,((f=n["x-component-props"])==null?void 0:f.duplicateCollection)||(h==null?void 0:h.__collection)||u,w)}},"x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]!=="quickDulicate" }}'}}}]},selectAll:{type:"void",title:'{{ t("Select all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode"],fulfill:{state:{visible:'{{ $deps[0]==="quickDulicate"}}'}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>{const l=p.useForm();return v(l)}}},unselectAll:{type:"void",title:'{{ t("UnSelect all") }}',"x-component":"Action.Link","x-reactions":[{dependencies:[".duplicateMode",".duplicateFields"],fulfill:{state:{visible:`{{ $deps[0]==="quickDulicate"&&$form.getValuesIn('duplicateFields').length>0 }}`}}}],"x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200,marginRight:"10px"},useAction:()=>{const l=p.useForm();return z(l)}}},duplicateFields:{type:"array",title:'{{ t("Data fields") }}',required:!0,description:c("Only the selected fields will be used as the initialization data for the form"),"x-decorator":"FormItem","x-component":R,"x-component-props":{defaultCheckedKeys:S,treeData:[],checkable:!0,checkStrictly:!0,selectable:!1,loadData:"{{ getOnLoadData($self) }}",onCheck:"{{ getOnCheck($self) }}",rootStyle:{padding:"8px 0",border:"1px solid #d9d9d9",borderRadius:"2px",maxHeight:"30vh",overflow:"auto",margin:"2px 0"}},"x-reactions":[{dependencies:[".collection",".duplicateMode"],fulfill:{state:{disabled:"{{ !$deps[0] }}",componentProps:{treeData:"{{ getEnableFieldTree($deps[0], $self,treeData) }}"}}}}]}}},onSubmit:({duplicateMode:l,collection:f,duplicateFields:a,treeData:r})=>{var P;const A=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=A,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=l,n["x-component-props"].duplicateFields=A,n["x-component-props"].duplicateCollection=f,n["x-component-props"].treeData=r||((P=s.componentProps)==null?void 0:P.treeData),t.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n["x-component-props"])}}),t.refresh()}})}const U=[{name:"Customize",Component:t=>t.children,children:[{name:"editButton",Component:e.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=e.useSchemaToolbar();return t}},{name:"linkageRules",Component:e.SchemaSettingsLinkageRules,useComponentProps(){const{name:t}=e.useCollection_deprecated(),{linkageRulesProps:c}=e.useSchemaToolbar();return g(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:ae,useVisible(){return p.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=p.useFieldSchema(),c=["create","update","view","customize:popup","duplicate","customize:create"].includes(t["x-action"]||"");return{openMode:c,openSize:c}}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:t}=e.useSchemaToolbar();return t}}]}],se=new e.SchemaSettings({name:"ActionSettings:duplicate",items:U}),le=new e.SchemaSettings({name:"actionSettings:duplicate",items:U}),Q=t=>{const c={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",component:"DuplicateAction"},properties:{drawer:{type:"void",title:'{{ t("Duplicate") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}}}};return i.jsx(e.ActionInitializer,g(x({},t),{schema:c}))},re=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:Q,DuplicateAction:K},children:t.children});class J extends e.Plugin{load(){return L(this,null,function*(){this.app.use(re),this.app.addComponents({DuplicateActionInitializer:Q,DuplicateAction:K}),this.app.schemaSettingsManager.add(se),this.app.schemaSettingsManager.add(le);const c={title:'{{t("Duplicate")}}',Component:"DuplicateActionInitializer",schema:{"x-component":"Action.Link","x-action":"duplicate","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:duplicate","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible(){const s=e.useCollection_deprecated();return(s.template!=="view"||(s==null?void 0:s.writableView))&&s.template!=="file"&&s.template!=="sql"}};this.app.schemaInitializerManager.addItem("table:configureItemActions","actions.duplicate",c)})}}o.DuplicateAction=K,o.PluginActionDuplicateClient=J,o.actionDesignerCss=E,o.default=J,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
module.exports = { | ||
"@formily/core": "2.3.0", | ||
"@formily/react": "2.3.0", | ||
"@nocobase/client": "0.21.0-alpha.2", | ||
"@nocobase/client": "0.21.0-alpha.3", | ||
"antd": "5.12.8", | ||
@@ -10,4 +10,4 @@ "lodash": "4.17.21", | ||
"@emotion/css": "11.11.2", | ||
"@nocobase/server": "0.21.0-alpha.2", | ||
"@nocobase/test": "0.21.0-alpha.2" | ||
"@nocobase/server": "0.21.0-alpha.3", | ||
"@nocobase/test": "0.21.0-alpha.3" | ||
}; |
{ | ||
"name": "@nocobase/plugin-action-duplicate", | ||
"version": "0.21.0-alpha.2", | ||
"version": "0.21.0-alpha.3", | ||
"main": "dist/server/index.js", | ||
@@ -17,3 +17,3 @@ "homepage": "https://docs.nocobase.com/handbook/action-duplicate", | ||
}, | ||
"gitHead": "90628f2e2da846208fb2d7966ddb4e467d187ffb", | ||
"gitHead": "f7276aff14063a2cf825191a0c83aeacde05a912", | ||
"keywords": [ | ||
@@ -20,0 +20,0 @@ "Actions" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55572