@nocobase/plugin-action-duplicate
Advanced tools
Comparing version 0.19.0-alpha.9 to 0.20.0-alpha.1
import { SchemaSettings } from '@nocobase/client'; | ||
/** | ||
* @deprecated | ||
* 用于兼容之前的 name | ||
*/ | ||
declare const deprecatedDuplicateActionSettings: SchemaSettings<{}>; | ||
declare const duplicateActionSettings: SchemaSettings<{}>; | ||
export { duplicateActionSettings }; | ||
export { deprecatedDuplicateActionSettings, duplicateActionSettings }; |
import { Plugin } from '@nocobase/client'; | ||
export declare class DuplicatePlugin extends Plugin { | ||
export declare class PluginDuplicateClient extends Plugin { | ||
load(): Promise<void>; | ||
} | ||
export default DuplicatePlugin; | ||
export default PluginDuplicateClient; | ||
export * from './DuplicateAction'; |
@@ -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,u,d,M,b,q,D,z){"use strict";var de=Object.defineProperty,ue=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var Z=(o,e,i)=>e in o?de(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,g=(o,e)=>{for(var i in e||(e={}))ee.call(e,i)&&Z(o,i,e[i]);if(j)for(var i of j(e))te.call(e,i)&&Z(o,i,e[i]);return o},y=(o,e)=>ue(o,me(e));var oe=(o,e)=>{var i={};for(var u in o)ee.call(o,u)&&e.indexOf(u)<0&&(i[u]=o[u]);if(o!=null&&j)for(var u of j(o))e.indexOf(u)<0&&te.call(o,u)&&(i[u]=o[u]);return i};var B=(o,e,i)=>new Promise((u,d)=>{var M=D=>{try{q(i.next(D))}catch(z){d(z)}},b=D=>{try{q(i.throw(D))}catch(z){d(z)}},q=D=>D.done?u(D.value):Promise.resolve(D.value).then(M,b);q((i=i.apply(o,e)).next())});const ne=t=>{const c={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-designer":"Action.Designer","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":"CreateFormBlockInitializers",properties:{}}}}}}}}}};return i.jsx(e.ActionInitializer,y(g({},t),{schema:c}))},N=u.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,p,r,I,k,F,C,M){"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},f=(o,e)=>xe(o,ge(e));var ce=(o,e)=>{var i={};for(var p in o)ne.call(o,p)&&e.indexOf(p)<0&&(i[p]=o[p]);if(o!=null&&j)for(var p of j(o))e.indexOf(p)<0&&ie.call(o,p)&&(i[p]=o[p]);return i};var w=(o,e,i)=>new Promise((p,r)=>{var I=C=>{try{F(i.next(C))}catch(M){r(M)}},k=C=>{try{F(i.throw(C))}catch(M){r(M)}},F=C=>C.done?p(C.value):Promise.resolve(C.value).then(I,k);F((i=i.apply(o,e)).next())});const E=p.css` | ||
position: relative; | ||
@@ -39,3 +39,3 @@ &:hover { | ||
} | ||
`,$=d.observer(t=>{var W,X;const{children:c}=t,{message:m}=M.App.useApp(),n=d.useField(),l=d.useFieldSchema(),x=e.useAPIClient(),a=n.disabled||t.disabled,{designable:k}=e.useDesignable(),[T,A]=b.useState(!1),[h,w]=b.useState(!1),{service:S,__parent:L,block:V}=e.useBlockRequestContext(),{duplicateFields:C,duplicateMode:_="quickDulicate",duplicateCollection:r}=l["x-component-props"],f=e.useRecord(),{id:s,__collection:p}=f,v=e.useActionContext(),{name:P}=e.useCollection(),{getCollectionFields:se}=e.useCollectionManager(),{t:F}=q.useTranslation(),le=se(p||P),re=e.useFormBlockContext(),U={key:"duplicate",dataId:s,default:!0,fields:(C==null?void 0:C.filter(I=>le.find(O=>I.includes(O.name))))||[],collection:p||P},Q=l["x-component"]==="Action.Link",pe=()=>B(this,null,function*(){var I,O,Y;w(!0);try{const K=yield e.fetchTemplateData(x,U,F);yield x.resource(p||P).create({values:g({},K)}),m.success(F("Saved successfully")),V==="form"?(O=(I=L==null?void 0:L.service)==null?void 0:I.refresh)==null||O.call(I):yield(Y=S==null?void 0:S.refresh)==null?void 0:Y.call(S),w(!1)}catch(K){w(!1),console.error(K)}}),J=()=>{!a&&!h&&((C==null?void 0:C.length)>0?_==="quickDulicate"?pe():A(!0):m.error(F("Please configure the duplicate fields")))};return i.jsx("div",{className:u.cx(N,{[u.css` | ||
`,K=r.observer(t=>{var Z,ee;const{children:c}=t,{message:s}=I.App.useApp(),n=r.useField(),d=r.useFieldSchema(),D=e.useAPIClient(),u=n.disabled||t.disabled,{designable:S}=e.useDesignable(),[T,v]=k.useState(!1),[m,z]=k.useState(!1),{service:A,__parent:_,block:B}=e.useBlockRequestContext(),{duplicateFields:b,duplicateMode:L="quickDulicate",duplicateCollection:l}=d["x-component-props"],g=e.useRecord(),a=e.useCollectionParentRecordData(),{id:h,__collection:y}=g,V=e.useActionContext(),{name:N}=e.useCollection_deprecated(),{getCollectionFields:pe}=e.useCollectionManager_deprecated(),{t:P}=F.useTranslation(),de=pe(y||N),ue=e.useFormBlockContext(),W={key:"duplicate",dataId:h,default:!0,fields:(b==null?void 0:b.filter(q=>de.find(O=>q.includes(O.name))))||[],collection:y||N},X=d["x-component"]==="Action.Link",me=()=>w(this,null,function*(){var q,O,te;z(!0);try{const $=yield e.fetchTemplateData(D,W,P);yield D.resource(y||N).create({values:x({},$)}),s.success(P("Saved successfully")),B==="form"?(O=(q=_==null?void 0:_.service)==null?void 0:q.refresh)==null||O.call(q):yield(te=A==null?void 0:A.refresh)==null?void 0:te.call(A),z(!1)}catch($){z(!1),console.error($)}}),Y=()=>{!u&&!m&&((b==null?void 0:b.length)>0?L==="quickDulicate"?me():v(!0):s.error(P("Please configure the duplicate fields")))};return i.jsx("div",{className:p.cx(E,{[p.css` | ||
.general-schema-designer { | ||
@@ -47,2 +47,2 @@ top: -10px; | ||
} | ||
`]:Q}),children:i.jsx(e.FormBlockContext.Provider,{value:y(g({},re),{duplicateData:{display:!1,enabled:!0,defaultTemplate:U}}),children:i.jsxs("div",{children:[Q?i.jsx("a",{role:t.role,"aria-label":t["aria-label"],disabled:a,style:{opacity:k&&((W=n==null?void 0:n.data)==null?void 0:W.hidden)&&.1,cursor:h?"not-allowed":"pointer"},onClick:J,children:h?F("Duplicating"):c||F("Duplicate")}):i.jsx(M.Button,y(g({role:t.role,"aria-label":t["aria-label"],disabled:a,style:{opacity:k&&((X=n==null?void 0:n.data)==null?void 0:X.hidden)&&.1}},t),{onClick:J,children:h?F("Duplicating"):c||F("Duplicate")})),i.jsx(e.CollectionProvider,{name:r||P,children:i.jsx(e.RecordProvider,{record:y(g({},f),{__collection:r||p}),children:i.jsx(e.ActionContextProvider,{value:y(g({},v),{visible:T,setVisible:A}),children:i.jsx(d.RecursionField,{schema:l,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),ie=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:ne,DuplicateAction:$},children:t.children}),E=d.connect(M.Tree,d.mapProps((t,c)=>{b.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[m,n]=b.useState(t.defaultCheckedKeys||[]),l=a=>{n(a),c.value=a};c.onCheck=l;const x=d.useForm();return y(g({},t),{checkedKeys:m,onCheck:l,treeData:t==null?void 0:t.treeData.map(a=>{var k;if(x.values.duplicateMode==="quickDulicate"){const T=(k=a==null?void 0:a.children)==null?void 0:k.map(A=>y(g({},A),{disabled:!1}));return y(g({},a),{disabled:!1,children:T})}return a})})})),R=(t,c)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const m=t[n],{children:l}=m,x=oe(m,["children"]);c.push(x.key),l&&R(l,c)}return c},G=t=>t.reduceProperties((m,n)=>n["x-decorator"]==="FormBlockProvider"?n:G(n),null);function ce(){var V,C,_;const{dn:t}=e.useDesignable(),{t:c}=q.useTranslation(),m=d.useField(),n=d.useFieldSchema(),{name:l}=e.useCollection(),{collectionList:x,getEnableFieldTree:a,getOnLoadData:k,getOnCheck:T}=e.useCollectionState(l),A=z.cloneDeep(n["x-component-props"].duplicateFields||[]),h=e.useRecord(),w=b.useCallback((r,f,s)=>{s.query("duplicateFields").take(p=>{p.componentProps.treeData=r,p.componentProps.defaultCheckedKeys=f,p.setInitialValue(f),p==null||p.onCheck(f),s.setValues(y(g({},s.values),{treeData:r}))})},[]),S=r=>({run(){return B(this,null,function*(){r.query("duplicateFields").take(s=>{var v;const p=R(s.componentProps.treeData,[]);s.componentProps.defaultCheckedKeys=p,s.setInitialValue(p),(v=s==null?void 0:s.onCheck)==null||v.call(s,p)})})}}),L=r=>({run(){return B(this,null,function*(){r.query("duplicateFields").take(s=>{s.componentProps.defaultCheckedKeys=[],s.setInitialValue([]),s==null||s.onCheck([])})})}});return i.jsx(e.SchemaSettingsModalItem,{title:c("Duplicate mode"),components:{Tree:E},scope:{getEnableFieldTree:a,collectionName:((V=n["x-component-props"])==null?void 0:V.duplicateCollection)||(h==null?void 0:h.__collection)||l,currentCollection:(h==null?void 0:h.__collection)||l,getOnLoadData:k,getOnCheck:T,treeData:(C=n["x-component-props"])==null?void 0:C.treeData,duplicateValues:A,onFieldInputValueChange:D.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((_=n["x-component-props"])==null?void 0:_.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":x.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:x},"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 r=b.useMemo(()=>G(n),[n]);return e.useSyncFromForm(r,((f=n["x-component-props"])==null?void 0:f.duplicateCollection)||(h==null?void 0:h.__collection)||l,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 r=d.useForm();return S(r)}}},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 r=d.useForm();return L(r)}}},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":E,"x-component-props":{defaultCheckedKeys:A,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:r,collection:f,duplicateFields:s,treeData:p})=>{var P;const v=Array.isArray(s)?s:s.checked||[];m.componentProps.duplicateMode=r,m.componentProps.duplicateFields=v,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=r,n["x-component-props"].duplicateFields=v,n["x-component-props"].duplicateCollection=f,n["x-component-props"].treeData=p||((P=m.componentProps)==null?void 0:P.treeData),t.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":g({},n["x-component-props"])}}),t.refresh()}})}const ae=new e.SchemaSettings({name:"ActionSettings:duplicate",items:[{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(),{linkageRulesProps:c}=e.useSchemaToolbar();return y(g({},c),{collectionName:t})}},{name:"duplicationMode",Component:ce,useVisible(){return d.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=d.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}}]}]});class H extends e.Plugin{load(){return B(this,null,function*(){this.app.use(ie),this.app.schemaSettingsManager.add(ae);const c={title:'{{t("Duplicate")}}',Component:"DuplicateActionInitializer",schema:{"x-component":"Action","x-action":"duplicate","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible(){const a=e.useCollection();return(a.template!=="view"||(a==null?void 0:a.writableView))&&a.template!=="file"&&a.template!=="sql"}},m={title:'{{t("Duplicate")}}',Component:"DuplicateActionInitializer",schema:{"x-component":"Action.Link","x-action":"duplicate","x-designer":"Action.Designer","x-settings":"ActionSettings:duplicate","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}},useVisible(){const a=e.useCollection();return(a.template!=="view"||(a==null?void 0:a.writableView))&&a.template!=="file"&&a.template!=="sql"}},n=this.app.schemaInitializerManager.get("TableActionColumnInitializers");n==null||n.add("actions.duplicate",m);const l=this.app.schemaInitializerManager.get("DetailsActionInitializers");l==null||l.add("enableActions.duplicate",c);const x=this.app.schemaInitializerManager.get("ReadPrettyFormActionInitializers");x==null||x.add("enableActions.duplicate",c)})}}o.DuplicateAction=$,o.DuplicatePlugin=H,o.actionDesignerCss=N,o.default=H,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
`]:X}),children:i.jsx(e.FormBlockContext.Provider,{value:f(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:u,style:{opacity:S&&((Z=n==null?void 0:n.data)==null?void 0:Z.hidden)&&.1,cursor:m?"not-allowed":"pointer",position:"relative"},onClick:Y,children:m?P("Duplicating"):c||P("Duplicate")}):i.jsx(I.Button,f(x({role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:S&&((ee=n==null?void 0:n.data)==null?void 0:ee.hidden)&&.1}},t),{onClick:Y,children:m?P("Duplicating"):c||P("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:l||N,children:i.jsx(e.RecordProvider,{record:f(x({},g),{__collection:l||y}),parent:a,children:i.jsx(e.ActionContextProvider,{value:f(x({},V),{visible:T,setVisible:v}),children:i.jsx(r.RecursionField,{schema:d,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),R=r.connect(I.Tree,r.mapProps((t,c)=>{k.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,n]=k.useState(t.defaultCheckedKeys||[]),d=u=>{n(u),c.value=u};c.onCheck=d;const D=r.useForm();return f(x({},t),{checkedKeys:s,onCheck:d,treeData:t==null?void 0:t.treeData.map(u=>{var S;if(D.values.duplicateMode==="quickDulicate"){const T=(S=u==null?void 0:u.children)==null?void 0:S.map(v=>f(x({},v),{disabled:!1}));return f(x({},u),{disabled:!1,children:T})}return u})})})),G=(t,c)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const s=t[n],{children:d}=s,D=ce(s,["children"]);c.push(D.key),d&&G(d,c)}return c},H=t=>t.reduceProperties((s,n)=>n["x-decorator"]==="FormBlockProvider"?n:H(n),null);function ae(){var B,b,L;const{dn:t}=e.useDesignable(),{t:c}=F.useTranslation(),s=r.useField(),n=r.useFieldSchema(),{name:d}=e.useCollection_deprecated(),{collectionList:D,getEnableFieldTree:u,getOnLoadData:S,getOnCheck:T}=e.useCollectionState(d),v=M.cloneDeep(n["x-component-props"].duplicateFields||[]),m=e.useRecord(),z=k.useCallback((l,g,a)=>{a.query("duplicateFields").take(h=>{h.componentProps.treeData=l,h.componentProps.defaultCheckedKeys=g,h.setInitialValue(g),h==null||h.onCheck(g),a.setValues(f(x({},a.values),{treeData:l}))})},[]),A=l=>({run(){return w(this,null,function*(){l.query("duplicateFields").take(a=>{var y;const h=G(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=h,a.setInitialValue(h),(y=a==null?void 0:a.onCheck)==null||y.call(a,h)})})}}),_=l=>({run(){return w(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:u,collectionName:((B=n["x-component-props"])==null?void 0:B.duplicateCollection)||(m==null?void 0:m.__collection)||d,currentCollection:(m==null?void 0:m.__collection)||d,getOnLoadData:S,getOnCheck:T,treeData:(b=n["x-component-props"])==null?void 0:b.treeData,duplicateValues:v,onFieldInputValueChange:C.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((L=n["x-component-props"])==null?void 0:L.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":D.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:D},"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 g;const l=k.useMemo(()=>H(n),[n]);return e.useSyncFromForm(l,((g=n["x-component-props"])==null?void 0:g.duplicateCollection)||(m==null?void 0:m.__collection)||d,z)}},"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=r.useForm();return A(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=r.useForm();return _(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:v,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:g,duplicateFields:a,treeData:h})=>{var V;const y=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=y,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=l,n["x-component-props"].duplicateFields=y,n["x-component-props"].duplicateCollection=g,n["x-component-props"].treeData=h||((V=s.componentProps)==null?void 0:V.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 f(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:ae,useVisible(){return r.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=r.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":"CreateFormBlockInitializers",properties:{}}}}}}}}}};return i.jsx(e.ActionInitializer,f(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 w(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("TableActionColumnInitializers","actions.duplicate",c)})}}o.DuplicateAction=K,o.PluginDuplicateClient=J,o.actionDesignerCss=E,o.default=J,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
module.exports = { | ||
"react": "18.2.0", | ||
"@nocobase/client": "0.19.0-alpha.9", | ||
"@formily/core": "2.3.0", | ||
"@formily/react": "2.3.0", | ||
"@nocobase/client": "0.20.0-alpha.1", | ||
"antd": "5.12.8", | ||
"lodash": "4.17.21", | ||
"antd": "5.12.8", | ||
"react": "18.2.0", | ||
"react-i18next": "11.18.6", | ||
"@formily/react": "2.3.0", | ||
"@emotion/css": "11.11.2", | ||
"@nocobase/server": "0.19.0-alpha.9", | ||
"@nocobase/test": "0.19.0-alpha.9" | ||
"@nocobase/server": "0.20.0-alpha.1", | ||
"@nocobase/test": "0.20.0-alpha.1" | ||
}; |
{ | ||
"name": "@nocobase/plugin-action-duplicate", | ||
"version": "0.19.0-alpha.9", | ||
"version": "0.20.0-alpha.1", | ||
"main": "dist/server/index.js", | ||
@@ -17,3 +17,3 @@ "homepage": "https://docs.nocobase.com/plugins/action-duplicate", | ||
}, | ||
"gitHead": "975f9c58a1995df6a8d7a4d191a0dc4a9769ebc5", | ||
"gitHead": "516c0b1470d77ff499f533ae6b57e4c084450ff5", | ||
"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
261
55545