@tachybase/plugin-action-duplicate 1.3.16 → 1.3.18
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 +4 -4
- package/dist/index.js +4 -4
- package/package.json +5 -5
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("antd"),require("react-i18next"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/schema","antd","react-i18next","lodash"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@tachybase/plugin-action-duplicate"]={},o["@tachybase/client"],o.jsxRuntime,o.react,o["@tachybase/schema"],o.antd,o["react-i18next"],o.lodash))})(this,function(o,e,i,r,p,
|
|
1
|
+
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("antd"),require("react-i18next"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/schema","antd","react-i18next","lodash"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@tachybase/plugin-action-duplicate"]={},o["@tachybase/client"],o.jsxRuntime,o.react,o["@tachybase/schema"],o.antd,o["react-i18next"],o.lodash))})(this,function(o,e,i,r,p,M,B,q){"use strict";var me=Object.defineProperty,he=Object.defineProperties;var xe=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var te=(o,e,i)=>e in o?me(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,x=(o,e)=>{for(var i in e||(e={}))oe.call(e,i)&&te(o,i,e[i]);if(K)for(var i of K(e))ne.call(e,i)&&te(o,i,e[i]);return o},g=(o,e)=>he(o,xe(e));var ie=(o,e)=>{var i={};for(var r in o)oe.call(o,r)&&e.indexOf(r)<0&&(i[r]=o[r]);if(o!=null&&K)for(var r of K(o))e.indexOf(r)<0&&ne.call(o,r)&&(i[r]=o[r]);return i};var z=(o,e,i)=>new Promise((r,p)=>{var M=y=>{try{q(i.next(y))}catch(k){p(k)}},B=y=>{try{q(i.throw(y))}catch(k){p(k)}},q=y=>y.done?r(y.value):Promise.resolve(y.value).then(M,B);q((i=i.apply(o,e)).next())});const y=e.css`
|
|
2
2
|
position: relative;
|
|
3
3
|
&:hover {
|
|
4
4
|
.general-schema-designer {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`,k=p.observer(t=>{var Y,Z;const{children:a}=t,{message:s}=
|
|
39
|
+
`,k=p.observer(t=>{var Y,Z;const{children:a}=t,{message:s}=M.App.useApp(),n=p.useField(),d=p.useFieldSchema(),D=e.useAPIClient(),u=n.disabled||t.disabled,{designable:S}=e.useDesignable(),[I,v]=r.useState(!1),[m,T]=r.useState(!1),{service:A,__parent:_,block:L}=e.useBlockRequestContext(),{duplicateFields:C,duplicateMode:V="quickDulicate",duplicateCollection:w}=d["x-component-props"],l=e.useRecord(),f=e.useCollectionParentRecordData(),{__collection:c}=l,h=e.useActionContext(),{name:b}=e.useCollection_deprecated(),{getCollectionFields:$}=e.useCollectionManager_deprecated(),{t:P}=B.useTranslation(),re=$(c||b),pe=e.useFormBlockContext(),N=e.useCollection(),de=N==null?void 0:N.getPrimaryKey(),W={key:"duplicate",dataId:l[de],default:!0,fields:(C==null?void 0:C.filter(F=>re.find(O=>F.includes(O.name))))||[],collection:c||b},J=d["x-component"]==="Action.Link",ue=()=>z(null,null,function*(){var F,O,ee;T(!0);try{const j=yield e.fetchTemplateData(D,W,P);yield D.resource(c||b).create({values:x({},j)}),s.success(P("Saved successfully")),L==="form"?(O=(F=_==null?void 0:_.service)==null?void 0:F.refresh)==null||O.call(F):yield(ee=A==null?void 0:A.refresh)==null?void 0:ee.call(A),T(!1)}catch(j){T(!1),console.error(j)}}),X=()=>{!u&&!m&&((C==null?void 0:C.length)>0?V==="quickDulicate"?ue():v(!0):s.error(P("Please configure the duplicate fields")))};return i.jsx("div",{className:e.cx(y,{[e.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
|
+
`]:J}),children:i.jsx(e.FormBlockContext.Provider,{value:g(x({},pe),{duplicateData:{display:!1,enabled:!0,defaultTemplate:W}}),children:i.jsxs("div",{children:[J?i.jsx("a",{className:"tb-action-link",role:t.role,"aria-label":t["aria-label"],disabled:u,style:{opacity:S&&((Y=n==null?void 0:n.data)==null?void 0:Y.hidden)&&.1,cursor:m?"not-allowed":"pointer",position:"relative"},onClick:X,children:m?P("Duplicating"):a||P("Duplicate")}):i.jsx(M.Button,g(x({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}},t),{onClick:X,children:m?P("Duplicating"):a||P("Duplicate")})),i.jsx(e.CollectionProvider_deprecated,{name:w||b,children:i.jsx(e.RecordProvider,{record:g(x({},l),{__collection:w||c}),parent:f,children:i.jsx(e.ActionContextProvider,{value:g(x({},h),{visible:I,setVisible:v}),children:i.jsx(p.RecursionField,{schema:d,basePath:n.address,onlyRenderProperties:!0})})})})]})})})},{displayName:"DuplicateAction"}),E=p.connect(M.Tree,p.mapProps((t,a)=>{r.useEffect(()=>{a.value=t.defaultCheckedKeys||[]},[]);const[s,n]=r.useState(t.defaultCheckedKeys||[]),d=u=>{n(u),a.value=u};a.onCheck=d;const D=p.useForm();return g(x({},t),{checkedKeys:s,onCheck:d,treeData:t==null?void 0:t.treeData.map(u=>{var S;if(D.values.duplicateMode==="quickDulicate"){const I=(S=u==null?void 0:u.children)==null?void 0:S.map(v=>g(x({},v),{disabled:!1}));return g(x({},u),{disabled:!1,children:I})}return u})})})),R=(t,a)=>{for(let n=0;n<(t==null?void 0:t.length);n++){const s=t[n],{children:d}=s,D=ie(s,["children"]);a.push(D.key),d&&R(d,a)}return a},G=t=>t.reduceProperties((s,n)=>n["x-decorator"]==="FormBlockProvider"?n:G(n),null);function ae(){var L,C,V,w;const{dn:t}=e.useDesignable(),{t:a}=B.useTranslation(),s=p.useField(),n=p.useFieldSchema(),{name:d}=e.useCollection_deprecated(),{collectionList:D,getEnableFieldTree:u,getOnLoadData:S,getOnCheck:I}=e.useCollectionState(d),v=q.cloneDeep(((L=n["x-component-props"])==null?void 0:L.duplicateFields)||[]),m=e.useRecord(),T=r.useCallback((l,f,c)=>{c.query("duplicateFields").take(h=>{h.componentProps.treeData=l,h.componentProps.defaultCheckedKeys=f,h.setInitialValue(f),h==null||h.onCheck(f),c.setValues(g(x({},c.values),{treeData:l}))})},[]),A=l=>({run(){return z(this,null,function*(){l.query("duplicateFields").take(c=>{var b;const h=R(c.componentProps.treeData,[]);c.componentProps.defaultCheckedKeys=h,c.setInitialValue(h),(b=c==null?void 0:c.onCheck)==null||b.call(c,h)})})}}),_=l=>({run(){return z(this,null,function*(){l.query("duplicateFields").take(c=>{c.componentProps.defaultCheckedKeys=[],c.setInitialValue([]),c==null||c.onCheck([])})})}});return i.jsx(e.SchemaSettingsModalItem,{title:a("Duplicate mode"),components:{Tree:E},scope:{getEnableFieldTree:u,collectionName:((C=n["x-component-props"])==null?void 0:C.duplicateCollection)||(m==null?void 0:m.__collection)||d,currentCollection:(m==null?void 0:m.__collection)||d,getOnLoadData:S,getOnCheck:I,treeData:(V=n["x-component-props"])==null?void 0:V.treeData,duplicateValues:v,onFieldInputValueChange:p.onFieldInputValueChange},schema:{type:"object",title:a("Duplicate mode"),properties:{duplicateMode:{"x-decorator":"FormItem","x-component":"Radio.Group",title:a("Duplicate mode"),default:((w=n["x-component-props"])==null?void 0:w.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":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 f;const l=r.useMemo(()=>G(n),[n]);return e.useSyncFromForm(l,((f=n["x-component-props"])==null?void 0:f.duplicateCollection)||(m==null?void 0:m.__collection)||d,T)}},"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 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=p.useForm();return _(l)}}},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":E,"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:f,duplicateFields:c,treeData:h})=>{var $;const b=Array.isArray(c)?c:c.checked||[];s.componentProps.duplicateMode=l,s.componentProps.duplicateFields=b,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].duplicateMode=l,n["x-component-props"].duplicateFields=b,n["x-component-props"].duplicateCollection=f,n["x-component-props"].treeData=h||(($=s.componentProps)==null?void 0:$.treeData),t.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n["x-component-props"])}}),t.refresh()}})}const H=[{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 g(x({},a),{collectionName:t})}},{name:"duplicationMode",Component:ae,useVisible(){return p.useFieldSchema()["x-action"]==="duplicate"}},{name:"openMode",Component:e.SchemaSettingOpenModeSchemaItems,useComponentProps(){const t=p.useFieldSchema(),a=["create","update","view","customize:popup","duplicate","customize:create"].includes(t["x-action"]||"");return{openMode:a,openSize:a}}},{name:"remove",sort:100,Component:e.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:t}=e.useSchemaToolbar();return t}}],ce=new e.SchemaSettings({name:"ActionSettings:duplicate",items:H}),se=new e.SchemaSettings({name:"actionSettings:duplicate",items:H}),U=t=>{const a={type:"void","x-action":"duplicate","x-acl-action":"create",title:'{{ t("Duplicate") }}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-component-props":{openMode:e.OpenMode.DRAWER_MODE,component:"DuplicateAction"},properties:{drawer:{type:"void",title:'{{ t("Duplicate") }}',"x-component":"Action.Container","x-component-props":{className:"tb-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:a}))},le=t=>i.jsx(e.SchemaComponentOptions,{components:{DuplicateActionInitializer:U,DuplicateAction:k},children:t.children});class Q extends e.Plugin{load(){return z(this,null,function*(){this.app.use(le),this.app.addComponents({DuplicateActionInitializer:U,DuplicateAction:k}),this.app.schemaSettingsManager.add(ce),this.app.schemaSettingsManager.add(se);const a={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",a)})}}o.DuplicateAction=k,o.PluginActionDuplicateClient=Q,o.actionDesignerCss=y,o.default=Q,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.3.
|
|
4
|
-
"@tachybase/schema": "1.3.
|
|
3
|
+
"@tachybase/client": "1.3.18",
|
|
4
|
+
"@tachybase/schema": "1.3.18",
|
|
5
5
|
"antd": "5.22.5",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
7
|
"react-i18next": "15.2.0",
|
|
8
|
-
"@tachybase/server": "1.3.
|
|
9
|
-
"@tachybase/test": "1.3.
|
|
8
|
+
"@tachybase/server": "1.3.18",
|
|
9
|
+
"@tachybase/test": "1.3.18"
|
|
10
10
|
};
|
package/dist/index.js
CHANGED
|
@@ -26,12 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
31
|
default: () => import_server.default
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
__reExport(
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
__reExport(index_exports, require("./server"), module.exports);
|
|
35
35
|
var import_server = __toESM(require("./server"));
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-action-duplicate",
|
|
3
3
|
"displayName": "Action: Duplicate record",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.18",
|
|
5
5
|
"description": "Duplicate a record, you can either duplicate it into a form and edit it before saving it, or you can duplicate it directly to generate a new record.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Actions"
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"antd": "5.22.5",
|
|
14
14
|
"lodash": "4.17.21",
|
|
15
15
|
"react-i18next": "^15.2.0",
|
|
16
|
-
"@tachybase/schema": "1.3.
|
|
16
|
+
"@tachybase/schema": "1.3.18"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@tachybase/client": "1.3.
|
|
20
|
-
"@tachybase/
|
|
21
|
-
"@tachybase/
|
|
19
|
+
"@tachybase/client": "1.3.18",
|
|
20
|
+
"@tachybase/server": "1.3.18",
|
|
21
|
+
"@tachybase/test": "1.3.18"
|
|
22
22
|
},
|
|
23
23
|
"description.zh-CN": "复制一条记录,可以复制到表单中编辑后再提交,也可以直接复制并生成一条新记录。",
|
|
24
24
|
"displayName.zh-CN": "操作:复制记录",
|