@nocobase/plugin-action-duplicate 1.4.9 → 1.4.11
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.
- package/dist/client/index.js +3 -3
- package/dist/externalVersion.js +3 -3
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(n,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):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-action-duplicate"]={},n["@nocobase/client"],n.jsxRuntime,n["@emotion/css"],n["@formily/react"],n.antd,n.react,n["react-i18next"],n["@formily/core"],n.lodash))})(this,function(n,e,i,
|
|
10
|
+
(function(n,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):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-action-duplicate"]={},n["@nocobase/client"],n.jsxRuntime,n["@emotion/css"],n["@formily/react"],n.antd,n.react,n["react-i18next"],n["@formily/core"],n.lodash))})(this,function(n,e,i,p,d,q,D,A,b,I){"use strict";var Se=Object.defineProperty,Ae=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var ae=(n,e,i)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,x=(n,e)=>{for(var i in e||(e={}))ce.call(e,i)&&ae(n,i,e[i]);if(N)for(var i of N(e))se.call(e,i)&&ae(n,i,e[i]);return n},y=(n,e)=>Ae(n,ve(e));var le=(n,e)=>{var i={};for(var p in n)ce.call(n,p)&&e.indexOf(p)<0&&(i[p]=n[p]);if(n!=null&&N)for(var p of N(n))e.indexOf(p)<0&&se.call(n,p)&&(i[p]=n[p]);return i};var B=(n,e,i)=>new Promise((p,d)=>{var q=b=>{try{A(i.next(b))}catch(I){d(I)}},D=b=>{try{A(i.throw(b))}catch(I){d(I)}},A=b=>b.done?p(b.value):Promise.resolve(b.value).then(q,D);A((i=i.apply(n,e)).next())});const H=p.css`
|
|
11
11
|
position: relative;
|
|
12
12
|
&:hover {
|
|
13
13
|
.general-schema-designer {
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
`,
|
|
48
|
+
`,j=d.observer(t=>{var te,oe,ne;const{children:a}=t,{message:l}=q.App.useApp(),o=d.useField(),u=d.useFieldSchema(),S=e.useAPIClient(),m=o.disabled||t.disabled,{designable:C}=e.useDesignable(),[_,v]=D.useState(!1),[h,L]=D.useState(!1),{service:P,__parent:z,block:O,resource:w}=e.useBlockRequestContext(),{duplicateFields:k,duplicateMode:K="quickDulicate",duplicateCollection:s}=u["x-component-props"],g=e.useRecord(),c=e.useCollectionParentRecordData(),r=e.useCollection(),{id:F,__collection:M}=g,he=e.useActionContext(),{name:E}=e.useCollection_deprecated(),{getCollectionFields:xe}=e.useCollectionManager_deprecated(),{t:T}=A.useTranslation(),ge=xe(M||E),fe=e.useFormBlockContext(),X=e.useACLActionParamsContext(),ye=e.useDataSourceKey(),De=e.useDataSourceHeaders(ye),be=Array.isArray(r.filterTargetKey)?Object.assign({},...r.filterTargetKey.map(f=>({[f]:g[f]}))):g[r.filterTargetKey]||F,Ce=D.useMemo(()=>{var f;return{opacity:C&&(((f=o==null?void 0:o.data)==null?void 0:f.hidden)||!X)&&.1}},[C,(te=o==null?void 0:o.data)==null?void 0:te.hidden]),Y={key:"duplicate",dataId:be,default:!0,fields:(k==null?void 0:k.filter(f=>ge.find(V=>f.includes(V.name))))||[],collection:M||E},Z=u["x-component"]==="Action.Link",ke=()=>B(this,null,function*(){var f,V,ie;L(!0);try{const $=yield e.fetchTemplateData(S,Y,De);yield w.create({values:x({},$)}),l.success(T("Saved successfully")),O==="form"?(V=(f=z==null?void 0:z.service)==null?void 0:f.refresh)==null||V.call(f):yield(ie=P==null?void 0:P.refresh)==null?void 0:ie.call(P),L(!1)}catch($){L(!1),console.error($)}}),ee=()=>{!m&&!h&&X&&((k==null?void 0:k.length)>0?K==="quickDulicate"?ke():v(!0):l.error(T("Please configure the duplicate fields")))};return i.jsx("div",{className:p.cx(H,{[p.css`
|
|
49
49
|
.general-schema-designer {
|
|
50
50
|
top: -10px;
|
|
51
51
|
bottom: -10px;
|
|
52
52
|
left: -10px;
|
|
53
53
|
right: -10px;
|
|
54
54
|
}
|
|
55
|
-
`]:Z}),children:i.jsx(e.FormBlockContext.Provider,{value:
|
|
55
|
+
`]:Z}),children:i.jsx(e.FormBlockContext.Provider,{value:y(x({},fe),{duplicateData:{display:!1,enabled:!0,defaultTemplate:Y}}),children:i.jsxs("div",{children:[Z?i.jsx("a",{className:"nb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:m,style:x({opacity:C&&((oe=o==null?void 0:o.data)==null?void 0:oe.hidden)&&.1,cursor:h?"not-allowed":"pointer",position:"relative"},Ce),onClick:ee,children:h?T("Duplicating"):a||T("Duplicate")}):i.jsx(q.Button,y(x({role:t.role,"aria-label":t["aria-label"],disabled:m,style:{opacity:C&&((ne=o==null?void 0:o.data)==null?void 0:ne.hidden)&&.1}},t),{onClick:ee,children:h?T("Duplicating"):a||T("Duplicate")})),i.jsx(e.TabsContextProvider,{children:i.jsx(e.CollectionProvider_deprecated,{name:s||E,children:i.jsx(e.RecordProvider,{record:y(x({},c),{__collection:s||M}),children:i.jsx(e.ActionContextProvider,{value:y(x({},he),{visible:_,setVisible:v}),children:i.jsx(e.PopupSettingsProvider,{enableURL:!1,children:i.jsx(d.RecursionField,{schema:u,basePath:o.address,onlyRenderProperties:!0})})})})})})]})})})},{displayName:"DuplicateAction"}),R=d.connect(q.Tree,d.mapProps((t,a)=>{D.useEffect(()=>{a.value=t.defaultCheckedKeys||[]},[]);const[l,o]=D.useState(t.defaultCheckedKeys||[]),u=m=>{o(m),a.value=m};a.onCheck=u;const S=d.useForm();return y(x({},t),{checkedKeys:l,onCheck:u,treeData:t==null?void 0:t.treeData.map(m=>{var C;if(S.values.duplicateMode==="quickDulicate"){const _=(C=m==null?void 0:m.children)==null?void 0:C.map(v=>y(x({},v),{disabled:!1}));return y(x({},m),{disabled:!1,children:_})}return m})})})),U=(t,a)=>{for(let o=0;o<(t==null?void 0:t.length);o++){const l=t[o],{children:u}=l,S=le(l,["children"]);a.push(S.key),u&&U(u,a)}return a},G=t=>t.reduceProperties((l,o)=>o["x-decorator"]==="FormBlockProvider"?o:G(o),null);function re(){var O,w,k,K;const{dn:t}=e.useDesignable(),{t:a}=A.useTranslation(),l=d.useField(),o=d.useFieldSchema(),{name:u}=e.useCollection_deprecated(),{collectionList:S,getEnableFieldTree:m,getOnLoadData:C,getOnCheck:_}=e.useCollectionState(u),v=I.cloneDeep(((O=o["x-component-props"])==null?void 0:O.duplicateFields)||[]),h=e.useRecord(),L=D.useCallback((s,g,c)=>{c.query("duplicateFields").take(r=>{r.componentProps.treeData=s,r.componentProps.defaultCheckedKeys=g,r.setInitialValue(g),r==null||r.onCheck(g),c.setValues(y(x({},c.values),{treeData:s}))})},[]),P=s=>({run(){return B(this,null,function*(){s.query("duplicateFields").take(c=>{var F;const r=U(c.componentProps.treeData,[]);c.componentProps.defaultCheckedKeys=r,c.setInitialValue(r),(F=c==null?void 0:c.onCheck)==null||F.call(c,r)})})}}),z=s=>({run(){return B(this,null,function*(){s.query("duplicateFields").take(c=>{c.componentProps.defaultCheckedKeys=[],c.setInitialValue([]),c==null||c.onCheck([])})})}});return i.jsx(e.SchemaSettingsModalItem,{title:a("Duplicate mode"),components:{Tree:R},scope:{getEnableFieldTree:m,collectionName:((w=o["x-component-props"])==null?void 0:w.duplicateCollection)||(h==null?void 0:h.__collection)||u,currentCollection:(h==null?void 0:h.__collection)||u,getOnLoadData:C,getOnCheck:_,treeData:(k=o["x-component-props"])==null?void 0:k.treeData,duplicateValues:v,onFieldInputValueChange:b.onFieldInputValueChange},schema:{type:"object",title:a("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:a("Duplicate mode"),default:((K=o["x-component-props"])==null?void 0:K.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:a("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":S.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:S},"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 s=D.useMemo(()=>G(o),[o]);return e.useSyncFromForm(s,((g=o["x-component-props"])==null?void 0:g.duplicateCollection)||(h==null?void 0:h.__collection)||u,L)}},"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 s=d.useForm();return P(s)}}},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 s=d.useForm();return z(s)}}},duplicateFields:{type:"array",title:'{{ t("Data fields") }}',required:!0,description:a("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:s,collection:g,duplicateFields:c,treeData:r})=>{var M;const F=Array.isArray(c)?c:c.checked||[];l.componentProps.duplicateMode=s,l.componentProps.duplicateFields=F,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].duplicateMode=s,o["x-component-props"].duplicateFields=F,o["x-component-props"].duplicateCollection=g,o["x-component-props"].treeData=r||((M=l.componentProps)==null?void 0:M.treeData),t.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":x({},o["x-component-props"])}}),t.refresh()}})}const Q=[{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:a}=e.useSchemaToolbar();return y(x({},a),{collectionName:t})}},{name:"duplicationMode",Component:re,useVisible(){return d.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:t}=e.useOpenModeContext(),{t:a}=A.useTranslation(),l=D.useMemo(()=>[{label:a("Drawer"),value:"drawer"},{label:a("Dialog"),value:"modal"}],[a]);return{openMode:!t,openSize:!t,modeOptions:l}}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:t}=e.useSchemaToolbar();return t}}]}],pe=new e.SchemaSettings({name:"ActionSettings:duplicate",items:Q}),de=new e.SchemaSettings({name:"actionSettings:duplicate",items:Q}),ue=t=>i.jsx(e.ACLActionProvider,{children:t.children}),J=t=>{const{defaultOpenMode:a}=e.useOpenModeContext(),l={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-component":"Action.Link","x-decorator":"DuplicateActionDecorator","x-component-props":{openMode:a,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.ActionInitializerItem,y(x({},t),{schema:l}))},me=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:J,DuplicateAction:j},children:t.children});class W extends e.Plugin{load(){return B(this,null,function*(){this.app.use(me),this.app.addComponents({DuplicateActionInitializer:J,DuplicateAction:j,DuplicateActionDecorator:ue}),this.app.schemaSettingsManager.add(pe),this.app.schemaSettingsManager.add(de);const a={title:'{{t("Duplicate")}}',Component:"DuplicateActionInitializer",schema:{"x-component":"Action.Link","x-action":"duplicate","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:duplicate","x-decorator":"DuplicateActionDecorator","x-component-props":{type:"primary"}},useVisible:()=>e.useActionAvailable("create")};this.app.schemaInitializerManager.addItem("table:configureItemActions","actions.duplicate",a)})}}n.DuplicateAction=j,n.PluginActionDuplicateClient=W,n.actionDesignerCss=H,n.default=W,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/core": "2.3.0",
|
|
12
12
|
"@formily/react": "2.3.0",
|
|
13
|
-
"@nocobase/client": "1.4.
|
|
13
|
+
"@nocobase/client": "1.4.11",
|
|
14
14
|
"antd": "5.12.8",
|
|
15
15
|
"lodash": "4.17.21",
|
|
16
16
|
"react": "18.2.0",
|
|
17
17
|
"react-i18next": "11.18.6",
|
|
18
18
|
"@emotion/css": "11.13.0",
|
|
19
|
-
"@nocobase/server": "1.4.
|
|
20
|
-
"@nocobase/test": "1.4.
|
|
19
|
+
"@nocobase/server": "1.4.11",
|
|
20
|
+
"@nocobase/test": "1.4.11"
|
|
21
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-action-duplicate",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.11",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/action-duplicate",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-duplicate",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@nocobase/server": "1.x",
|
|
15
15
|
"@nocobase/test": "1.x"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "275065a7af0069fc43be71b0231d246146854c7e",
|
|
18
18
|
"keywords": [
|
|
19
19
|
"Actions"
|
|
20
20
|
]
|