@nocobase/plugin-action-duplicate 1.2.3-alpha → 1.2.5-alpha
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,r,M,y,q,C,I){"use strict";var ye=Object.defineProperty,Ce=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var ce=(n,e,i)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,x=(n,e)=>{for(var i in e||(e={}))ae.call(e,i)&&ce(n,i,e[i]);if(j)for(var i of j(e))se.call(e,i)&&ce(n,i,e[i]);return n},g=(n,e)=>Ce(n,be(e));var le=(n,e)=>{var i={};for(var p in n)ae.call(n,p)&&e.indexOf(p)<0&&(i[p]=n[p]);if(n!=null&&j)for(var p of j(n))e.indexOf(p)<0&&se.call(n,p)&&(i[p]=n[p]);return i};var z=(n,e,i)=>new Promise((p,r)=>{var M=C=>{try{q(i.next(C))}catch(I){r(I)}},y=C=>{try{q(i.throw(C))}catch(I){r(I)}},q=C=>C.done?p(C.value):Promise.resolve(C.value).then(M,y);q((i=i.apply(n,e)).next())});const $=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
|
-
`,K=
|
|
48
|
+
`,K=r.observer(t=>{var te,oe,ne;const{children:c}=t,{message:s}=M.App.useApp(),o=r.useField(),d=r.useFieldSchema(),v=e.useAPIClient(),u=o.disabled||t.disabled,{designable:b}=e.useDesignable(),[T,A]=y.useState(!1),[m,_]=y.useState(!1),{service:P,__parent:w,block:L,resource:B}=e.useBlockRequestContext(),{duplicateFields:D,duplicateMode:V="quickDulicate",duplicateCollection:l}=d["x-component-props"],f=e.useRecord(),a=e.useCollectionParentRecordData(),{id:h,__collection:k}=f,N=e.useActionContext(),{name:E}=e.useCollection_deprecated(),{getCollectionFields:me}=e.useCollectionManager_deprecated(),{t:F}=q.useTranslation(),he=me(k||E),xe=e.useFormBlockContext(),X=e.useACLActionParamsContext(),ge=y.useMemo(()=>{var S;return{opacity:b&&(((S=o==null?void 0:o.data)==null?void 0:S.hidden)||!X)&&.1}},[b,(te=o==null?void 0:o.data)==null?void 0:te.hidden]),Y={key:"duplicate",dataId:h,default:!0,fields:(D==null?void 0:D.filter(S=>he.find(O=>S.includes(O.name))))||[],collection:k||E},Z=d["x-component"]==="Action.Link",fe=()=>z(this,null,function*(){var S,O,ie;_(!0);try{const R=yield e.fetchTemplateData(v,Y,F);yield B.create({values:x({},R)}),s.success(F("Saved successfully")),L==="form"?(O=(S=w==null?void 0:w.service)==null?void 0:S.refresh)==null||O.call(S):yield(ie=P==null?void 0:P.refresh)==null?void 0:ie.call(P),_(!1)}catch(R){_(!1),console.error(R)}}),ee=()=>{!u&&!m&&X&&((D==null?void 0:D.length)>0?V==="quickDulicate"?fe():A(!0):s.error(F("Please configure the duplicate fields")))};return i.jsx("div",{className:p.cx($,{[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
|
-
`]:
|
|
55
|
+
`]:Z}),children:i.jsx(e.FormBlockContext.Provider,{value:g(x({},xe),{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:u,style:x({opacity:b&&((oe=o==null?void 0:o.data)==null?void 0:oe.hidden)&&.1,cursor:m?"not-allowed":"pointer",position:"relative"},ge),onClick:ee,children:m?F("Duplicating"):c||F("Duplicate")}):i.jsx(M.Button,g(x({role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:b&&((ne=o==null?void 0:o.data)==null?void 0:ne.hidden)&&.1}},t),{onClick:ee,children:m?F("Duplicating"):c||F("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:l||E,children:i.jsx(e.RecordProvider,{record:g(x({},a),{__collection:l||k}),children:i.jsx(e.ActionContextProvider,{value:g(x({},N),{visible:T,setVisible:A}),children:i.jsx(r.RecursionField,{schema:d,basePath:o.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),G=r.connect(M.Tree,r.mapProps((t,c)=>{y.useEffect(()=>{c.value=t.defaultCheckedKeys||[]},[]);const[s,o]=y.useState(t.defaultCheckedKeys||[]),d=u=>{o(u),c.value=u};c.onCheck=d;const v=r.useForm();return g(x({},t),{checkedKeys:s,onCheck:d,treeData:t==null?void 0:t.treeData.map(u=>{var b;if(v.values.duplicateMode==="quickDulicate"){const T=(b=u==null?void 0:u.children)==null?void 0:b.map(A=>g(x({},A),{disabled:!1}));return g(x({},u),{disabled:!1,children:T})}return u})})})),H=(t,c)=>{for(let o=0;o<(t==null?void 0:t.length);o++){const s=t[o],{children:d}=s,v=le(s,["children"]);c.push(v.key),d&&H(d,c)}return c},U=t=>t.reduceProperties((s,o)=>o["x-decorator"]==="FormBlockProvider"?o:U(o),null);function re(){var L,B,D,V;const{dn:t}=e.useDesignable(),{t:c}=q.useTranslation(),s=r.useField(),o=r.useFieldSchema(),{name:d}=e.useCollection_deprecated(),{collectionList:v,getEnableFieldTree:u,getOnLoadData:b,getOnCheck:T}=e.useCollectionState(d),A=I.cloneDeep(((L=o["x-component-props"])==null?void 0:L.duplicateFields)||[]),m=e.useRecord(),_=y.useCallback((l,f,a)=>{a.query("duplicateFields").take(h=>{h.componentProps.treeData=l,h.componentProps.defaultCheckedKeys=f,h.setInitialValue(f),h==null||h.onCheck(f),a.setValues(g(x({},a.values),{treeData:l}))})},[]),P=l=>({run(){return z(this,null,function*(){l.query("duplicateFields").take(a=>{var k;const h=H(a.componentProps.treeData,[]);a.componentProps.defaultCheckedKeys=h,a.setInitialValue(h),(k=a==null?void 0:a.onCheck)==null||k.call(a,h)})})}}),w=l=>({run(){return z(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:G},scope:{getEnableFieldTree:u,collectionName:((B=o["x-component-props"])==null?void 0:B.duplicateCollection)||(m==null?void 0:m.__collection)||d,currentCollection:(m==null?void 0:m.__collection)||d,getOnLoadData:b,getOnCheck:T,treeData:(D=o["x-component-props"])==null?void 0:D.treeData,duplicateValues:A,onFieldInputValueChange:C.onFieldInputValueChange},schema:{type:"object",title:c("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Duplicate mode"),default:((V=o["x-component-props"])==null?void 0:V.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":v.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:v},"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=y.useMemo(()=>U(o),[o]);return e.useSyncFromForm(l,((f=o["x-component-props"])==null?void 0:f.duplicateCollection)||(m==null?void 0:m.__collection)||d,_)}},"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 P(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 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":G,"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:l,collection:f,duplicateFields:a,treeData:h})=>{var N;const k=Array.isArray(a)?a:a.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=k,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].duplicateMode=l,o["x-component-props"].duplicateFields=k,o["x-component-props"].duplicateCollection=f,o["x-component-props"].treeData=h||((N=s.componentProps)==null?void 0:N.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:c}=e.useSchemaToolbar();return g(x({},c),{collectionName:t})}},{name:"duplicationMode",Component:re,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}}]}],pe=new e.SchemaSettings({name:"ActionSettings:duplicate",items:Q}),de=new e.SchemaSettings({name:"actionSettings:duplicate",items:Q}),J=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.ActionInitializerItem,g(x({},t),{schema:c}))},ue=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:J,DuplicateAction:K},children:t.children});class W extends e.Plugin{load(){return z(this,null,function*(){this.app.use(ue),this.app.addComponents({DuplicateActionInitializer:J,DuplicateAction:K}),this.app.schemaSettingsManager.add(pe),this.app.schemaSettingsManager.add(de);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)})}}n.DuplicateAction=K,n.PluginActionDuplicateClient=W,n.actionDesignerCss=$,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.2.
|
|
13
|
+
"@nocobase/client": "1.2.5-alpha",
|
|
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.11.2",
|
|
19
|
-
"@nocobase/server": "1.2.
|
|
20
|
-
"@nocobase/test": "1.2.
|
|
19
|
+
"@nocobase/server": "1.2.5-alpha",
|
|
20
|
+
"@nocobase/test": "1.2.5-alpha"
|
|
21
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-action-duplicate",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5-alpha",
|
|
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": "ca7baa2d4dffe0e2c02f676b96ff841f3ee31e7e",
|
|
18
18
|
"keywords": [
|
|
19
19
|
"Actions"
|
|
20
20
|
]
|