@nocobase/plugin-action-duplicate 0.19.0-alpha.9 → 0.20.0-alpha.2
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,3 +1,8 @@
|
|
|
1
1
|
import { SchemaSettings } from '@nocobase/client';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated
|
|
4
|
+
* 用于兼容之前的 name
|
|
5
|
+
*/
|
|
6
|
+
declare const deprecatedDuplicateActionSettings: SchemaSettings<{}>;
|
|
2
7
|
declare const duplicateActionSettings: SchemaSettings<{}>;
|
|
3
|
-
export { duplicateActionSettings };
|
|
8
|
+
export { deprecatedDuplicateActionSettings, duplicateActionSettings };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from '@nocobase/client';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class PluginDuplicateClient extends Plugin {
|
|
3
3
|
load(): Promise<void>;
|
|
4
4
|
}
|
|
5
|
-
export default
|
|
5
|
+
export default PluginDuplicateClient;
|
|
6
6
|
export * from './DuplicateAction';
|
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(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,
|
|
1
|
+
(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`
|
|
2
2
|
position: relative;
|
|
3
3
|
&:hover {
|
|
4
4
|
.general-schema-designer {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
`,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`
|
|
40
40
|
.general-schema-designer {
|
|
41
41
|
top: -10px;
|
|
42
42
|
bottom: -10px;
|
|
43
43
|
left: -10px;
|
|
44
44
|
right: -10px;
|
|
45
45
|
}
|
|
46
|
-
`]:
|
|
46
|
+
`]: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"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"react": "18.2.0",
|
|
3
|
-
"@nocobase/client": "0.19.0-alpha.9",
|
|
4
2
|
"@formily/core": "2.3.0",
|
|
5
|
-
"
|
|
3
|
+
"@formily/react": "2.3.0",
|
|
4
|
+
"@nocobase/client": "0.20.0-alpha.2",
|
|
6
5
|
"antd": "5.12.8",
|
|
6
|
+
"lodash": "4.17.21",
|
|
7
|
+
"react": "18.2.0",
|
|
7
8
|
"react-i18next": "11.18.6",
|
|
8
|
-
"@formily/react": "2.3.0",
|
|
9
9
|
"@emotion/css": "11.11.2",
|
|
10
|
-
"@nocobase/server": "0.
|
|
11
|
-
"@nocobase/test": "0.
|
|
10
|
+
"@nocobase/server": "0.20.0-alpha.2",
|
|
11
|
+
"@nocobase/test": "0.20.0-alpha.2"
|
|
12
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-action-duplicate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-alpha.2",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/plugins/action-duplicate",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/plugins/action-duplicate",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@nocobase/server": "0.x",
|
|
15
15
|
"@nocobase/test": "0.x"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "6fb885dfc3554e4b0f29e9a7a1eecbbe85d0eebb",
|
|
18
18
|
"keywords": [
|
|
19
19
|
"Actions"
|
|
20
20
|
]
|