@nocobase/plugin-workflow-manual 0.20.0-alpha.8 → 0.21.0-alpha.1
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 +4 -4
- package/dist/client/instruction/SchemaConfig.d.ts +11 -3
- package/dist/client/instruction/createManualFormBlockUISchema.d.ts +57 -0
- package/dist/client/instruction/forms/custom.d.ts +6 -2
- package/dist/externalVersion.js +9 -9
- package/dist/server/forms/create.d.ts +2 -1
- package/dist/server/forms/create.js +4 -4
- package/dist/server/forms/update.d.ts +2 -1
- package/dist/server/forms/update.js +4 -4
- package/dist/server/migrations/20240325213145-fix-schema.d.ts +4 -0
- package/dist/server/migrations/20240325213145-fix-schema.js +88 -0
- package/package.json +2 -2
- package/src/client/WorkflowTodo.tsx +1 -1
- package/src/client/__e2e__/createRecordForm.test.ts +121 -65
- package/src/client/__e2e__/customFormBlocks.test.ts +131 -66
- package/src/client/__e2e__/datablocks.test.ts +30 -30
- package/src/client/__e2e__/updateRecordForm.test.ts +94 -53
- package/src/client/__e2e__/workflowTodo.test.ts +16 -7
- package/src/client/index.ts +12 -4
- package/src/client/instruction/FormBlockInitializer.tsx +3 -3
- package/src/client/instruction/SchemaConfig.tsx +117 -26
- package/src/client/instruction/createManualFormBlockUISchema.ts +5 -0
- package/src/client/instruction/forms/create.tsx +1 -1
- package/src/client/instruction/forms/custom.tsx +50 -17
- package/src/client/instruction/forms/update.tsx +1 -1
- package/src/client/instruction/index.tsx +1 -1
- package/src/server/__tests__/data-source.test.ts +223 -0
- package/src/server/__tests__/{instruction.test.ts → form.test.ts} +0 -510
- package/src/server/__tests__/mode.test.ts +561 -0
- package/src/server/forms/create.ts +10 -3
- package/src/server/forms/update.ts +10 -3
- package/src/server/migrations/20240325213145-fix-schema.ts +81 -0
- package/dist/client/instruction/DetailsBlockProvider.d.ts +0 -2
- package/src/client/instruction/DetailsBlockProvider.tsx +0 -87
package/dist/client/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(C,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react/jsx-runtime"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@nocobase/utils/client"),require("lodash"),require("@ant-design/icons"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","react/jsx-runtime","@formily/antd-v5","@formily/core","@formily/react","antd","react","react-i18next","@nocobase/utils/client","lodash","@ant-design/icons","dayjs"],e):(C=typeof globalThis!="undefined"?globalThis:C||self,e(C["@nocobase/plugin-workflow-manual"]={},C["@nocobase/client"],C["@nocobase/plugin-workflow"],C.jsxRuntime,C["@formily/antd-v5"],C["@formily/core"],C["@formily/react"],C.antd,C.react,C["react-i18next"],C["@nocobase/utils"],C.lodash,C["@ant-design/icons"],C.dayjs))})(this,function(C,e,d,s,E,U,b,S,h,j,T,J,K,ie){"use strict";var Re=Object.defineProperty,eo=Object.defineProperties;var oo=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var Q=(C,e,d)=>e in C?Re(C,e,{enumerable:!0,configurable:!0,writable:!0,value:d}):C[e]=d,g=(C,e)=>{for(var d in e||(e={}))re.call(e,d)&&Q(C,d,e[d]);if(L)for(var d of L(e))se.call(e,d)&&Q(C,d,e[d]);return C},k=(C,e)=>eo(C,oo(e));var V=(C,e)=>{var d={};for(var s in C)re.call(C,s)&&e.indexOf(s)<0&&(d[s]=C[s]);if(C!=null&&L)for(var s of L(C))e.indexOf(s)<0&&se.call(C,s)&&(d[s]=C[s]);return d};var $=(C,e,d)=>(Q(C,typeof e!="symbol"?e+"":e,d),d);var _=(C,e,d)=>new Promise((s,E)=>{var U=h=>{try{S(d.next(h))}catch(j){E(j)}},b=h=>{try{S(d.throw(h))}catch(j){E(j)}},S=h=>h.done?s(h.value):Promise.resolve(h.value).then(U,b);S((d=d.apply(C,e)).next())});const y="workflow-manual";function w(o,n={}){const{t:r}=ae(n);return r(o)}function ae(o){return j.useTranslation(y,o)}function ce(o){const{execution:n,nodes:r}=d.useFlowContext(),t=h.useMemo(()=>r.reduce((c,u)=>Object.assign(c,{[u.id]:u.key}),{}),[r]),i=h.useMemo(()=>{var c;return{$context:n==null?void 0:n.context,$jobsMapByNodeKey:((c=n==null?void 0:n.jobs)!=null?c:[]).reduce((u,l)=>Object.assign(u,{[t[l.nodeId]]:l.result}),{})}},[n==null?void 0:n.context,n==null?void 0:n.jobs,t]);return h.useMemo(()=>T.parse(o)(i),[i,o])}function H(o){const n=b.useField(),r=h.useRef(null),{getAssociationAppends:t}=e.useAssociationNames(),{appends:i,updateAssociationValues:a}=t(),c=ce(o.dataSource),u=h.useMemo(()=>U.createForm({values:c,readPretty:!0}),[c]),l={appends:i},x={loading:!1,data:{data:c}},p=e.useAPIClient().resource(o.collection),m=e.useBlockRequestContext();return s.jsx(e.CollectionProvider_deprecated,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:c,parent:null,children:s.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:x,resource:p,__parent:m},children:s.jsx(e.FormBlockContext.Provider,{value:{params:l,form:u,field:n,service:x,updateAssociationValues:a,formBlockRef:r},children:o.children})})})})}function X(o){var N,q,G;const n=e.useRecord(),r=b.useFieldSchema(),t=b.useField(),i=h.useRef(null),a=o.dataSource||e.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:c}=e.useAssociationNames(a),{appends:u,updateAssociationValues:l}=c(),[x]=Object.keys((N=r.toJSON().properties)!=null?N:{}),f=(q=n==null?void 0:n.result)==null?void 0:q[x],{findComponent:p}=e.useDesignable(),m=p((G=t.component)==null?void 0:G[0])||h.Fragment,v=h.useMemo(()=>U.createForm({initialValues:f}),[f]),A=h.useMemo(()=>g({appends:u},o.params),[u,o.params]),F=h.useMemo(()=>({loading:!1,data:{data:f}}),[f]),I=e.useAPIClient(),O=e.useDataSourceHeaders(a),D=I.resource(o.collection,void 0,O),B=e.useBlockRequestContext(),P=h.useMemo(()=>({params:A,form:v,field:t,service:F,updateAssociationValues:l,formBlockRef:i}),[t,v,A,F,l]);return!n.status||f?s.jsx(e.CollectionManagerProvider,{dataSource:a,children:s.jsx(e.CollectionProvider_deprecated,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:f,parent:null,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",children:s.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:o,field:t,service:F,resource:D,__parent:B},children:s.jsx(e.FormBlockContext.Provider,{value:P,children:s.jsxs(m,k(g({},t.componentProps),{children:[s.jsx(e.FormV2.Templates,{style:{marginBottom:18},form:v}),s.jsx("div",{ref:i,children:s.jsx(b.RecursionField,{schema:r,onlyRenderProperties:!0})})]}))})})})})})}):null}function le(r){var t=r,{schema:o}=t,n=V(t,["schema"]);const{getTemplateSchemaByMode:i}=e.useSchemaTemplateManager(),{insert:a}=e.useSchemaInitializer(),c=e.useRecordCollectionDataSourceItems("FormItem");function u(x){return _(this,arguments,function*({item:l}){var A;const f=l.template?yield i(l):null,p=e.createFormBlockSchema(k(g({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${y}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:d.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},o),{template:f}));delete p["x-acl-action-props"],delete p["x-acl-action"];const[m]=Object.keys(p.properties),v=((A=Object.entries(p.properties[m].properties).find(([F,I])=>I["x-component"]==="ActionBar"))==null?void 0:A[0])||"actions";p.properties[m].properties[v]["x-decorator"]="ActionBarProvider",p.properties[m].properties[v]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},d.traverseSchema(p,F=>{F["x-uid"]&&delete F["x-uid"]}),a(p)})}return s.jsx(e.SchemaInitializerItem,k(g({},n),{onClick:u,items:c}))}function Z(){var n,r;const o=e.useSchemaInitializerItem();return s.jsx(e.CollectionProvider_deprecated,{dataSource:(n=o.schema)==null?void 0:n.dataSource,collection:(r=o.schema)==null?void 0:r.collection,children:s.jsx(le,g({},o))})}function M(o,n,r=!1){const t=[];return o?n(o)&&(!r||!o.properties)?(t.push(o),t):(o.properties&&Object.keys(o.properties).forEach(i=>{t.push(...M(o.properties[i],n))}),t):t}function pe(){const{name:o,title:n}=e.useCollection_deprecated();return s.jsxs(e.GeneralSchemaDesigner,{title:n||o,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:o}),s.jsx(e.SchemaSettingsDataTemplates,{collectionName:o}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const de={title:`{{t("Create record form", { ns: "${y}" })}}`,config:{useInitializer({allCollections:o}){const n=h.useMemo(()=>o.map(({key:a,displayName:c,collections:u})=>({key:a,name:a,label:c,type:"subMenu",children:u.map(l=>({name:J.camelCase(`createRecordForm-child-${l.name}`),type:"item",title:l.title||l.tableName,schema:{collection:l.name,dataSource:a,title:`{{t("Create record", { ns: "${y}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Z}))})),[o]),[r,t]=h.useState([]),i=e.useMenuSearch(n,r);return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${y}" })}}`,componentProps:{onOpenChange(a){t(a)}},children:i}},initializers:{},components:{CreateFormDesigner:pe},parseFormOptions(o){const n={};return M(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var u,l;const[i]=Object.keys(t.properties),a=t.properties[i],c=((u=Object.entries(a.properties).find(([x,f])=>f["x-component"]==="ActionBar"))==null?void 0:u[0])||"actions";n[i]={type:"create",title:((l=t["x-component-props"])==null?void 0:l.title)||i,actions:M(a.properties[c],x=>x["x-component"]==="Action").map(x=>{var f,p;return{status:x["x-decorator-props"].value,values:(p=(f=x["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:p.values,key:x.name}}),collection:t["x-decorator-props"].collection}}),n}},block:{scope:{},components:{}}};function W(o){var x,f,p,m;const[n,r]=h.useState((f=(x=o.collection)==null?void 0:x.fields)!=null?f:[]),t=e.useRecord(),i=b.useField(),a=b.useFieldSchema(),[c]=Object.keys((p=a.toJSON().properties)!=null?p:{}),u=(m=t==null?void 0:t.result)==null?void 0:m[c],l=h.useMemo(()=>U.createForm({initialValues:u}),[u]);return!t.status||u?s.jsx(e.CollectionProvider_deprecated,{collection:k(g({},o.collection),{fields:n}),children:s.jsx(e.RecordProvider,{record:u,parent:null,children:s.jsx(e.FormBlockContext.Provider,{value:{form:l,field:i,setCollectionFields:r},children:o.children})})}):null}function ue(){const{insert:o}=e.useSchemaInitializer(),n=e.useSchemaInitializerItem();return s.jsx(e.SchemaInitializerItem,k(g({},n),{onClick:()=>{o({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:T.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[T.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${y}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:d.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const R={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function me(o){const n={};return Object.keys(o).forEach(r=>{const t=o[r],{group:i="others"}=t;n[i]=n[i]||{},J.set(n,[i,r],t)}),Object.keys(R).filter(r=>["basic","choices","datetime","media"].includes(r)).map(r=>({title:R[r],children:Object.keys(n[r]||{}).map(t=>{const i=n[r][t];return g({value:t,title:i.title,name:t},n[r][t])}).sort((t,i)=>t.order-i.order)}))}function fe(){const{interfaces:o}=e.useCollectionManager_deprecated();return me(o).map(r=>({name:r.title,type:"itemGroup",title:r.title,children:r.children.map(t=>({name:t.name,type:"item",title:t.title,Component:Ce,fieldInterface:t.name}))}))}const ee=h.createContext({}),he=o=>{const[n,r]=h.useState(null),[t,i]=h.useState(),a=fe(),c=e.useCollection_deprecated(),{setCollectionFields:u}=h.useContext(e.FormBlockContext);return s.jsxs(ee.Provider,{value:{onAddField(l){const v=J.cloneDeep(l),{properties:A}=v,F=A,{unique:x,type:f}=F,p=V(F,["unique","type"]),m=V(v,["properties"]);delete p.name["x-disabled"],r(k(g({},m),{properties:p}))},setCallback:i},children:[s.jsx(e.SchemaInitializerItems,k(g({},o),{items:a})),s.jsx(e.ActionContextProvider,{value:{visible:!!n},children:n?s.jsx(e.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:k(g({},n.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const l=b.useForm();return{run(){return _(this,null,function*(){i(null),r(null),l.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:l,query:x}=b.useForm(),f=[w("Field name existed in form")];return{run(){return _(this,null,function*(){var I,O,D,B;const{default:m}=n,v=T.uid();if(m.name=(I=l.name)!=null?I:v,m.uiSchema.title=(D=(O=l.uiSchema)==null?void 0:O.title)!=null?D:v,m.interface=n.name,(B=c.fields)==null?void 0:B.find(P=>P.name===m.name)){x("name").take().setFeedback({type:"error",messages:f});return}const F=T.merge(m,l);u([...c.fields,F]),t({name:m.name,type:m.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:F},"x-collection-field":`${c.name}.${m.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),i(null),r(null)})}}}}}}}})},components:{ArrayTable:E.ArrayTable}}):null})]})},xe=new e.SchemaInitializer({name:"AddCustomFormField",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:he});function Ce(){const o=e.useSchemaInitializerItem(),{insert:n,setVisible:r}=e.useSchemaInitializer(),{onAddField:t,setCallback:i}=h.useContext(ee),{getInterface:a}=e.useCollectionManager_deprecated(),c=a(o.fieldInterface);return s.jsx(e.SchemaInitializerItem,g({onClick:()=>{i(()=>n),t(c),r(!1)}},o),o.fieldInterface)}const oe={title:`{{t("Custom form", { ns: "${y}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${y}" })}}`,Component:ue}},initializers:{},components:{CustomFormBlockProvider:W},parseFormOptions(o){const n={};return M(o,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var l,x;const[i]=Object.keys(t.properties),a=t.properties[i],c=M(a.properties.grid,f=>f["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=c.map(f=>{var p,m;return(m=(p=f["x-component-props"])==null?void 0:p.field)!=null?m:f["x-interface-options"]});const u=((l=Object.entries(a.properties).find(([f,p])=>p["x-component"]==="ActionBar"))==null?void 0:l[0])||"actions";n[i]={type:"custom",title:((x=t["x-component-props"])==null?void 0:x.title)||i,actions:M(a.properties[u],f=>f["x-component"]==="Action").map(f=>{var p,m;return{status:f["x-decorator-props"].value,values:(m=(p=f["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:m.values,key:f.name}}),collection:t["x-decorator-props"].collection}}),n}},block:{scope:{},components:{CustomFormBlockProvider:W}}};function ye(){const{name:o,title:n}=e.useCollection_deprecated(),r=b.useFieldSchema(),{t}=j.useTranslation(),{dn:i}=e.useDesignable();return s.jsxs(e.GeneralSchemaDesigner,{title:n||o,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsActionModalItem,{title:t("Filter settings",{ns:y}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var c;return{options:e.useCollectionFilterOptions((c=r==null?void 0:r["x-decorator-props"])==null?void 0:c.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:r==null?void 0:r["x-decorator-props"],onSubmit:({filter:a})=>{r["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":r["x-decorator-props"]}}),i.refresh()}}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:o}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ge={title:`{{t("Update record form", { ns: "${y}" })}}`,config:{useInitializer({allCollections:o}){const n=h.useMemo(()=>o.map(({key:a,displayName:c,collections:u})=>({key:a,name:a,label:c,type:"subMenu",children:u.map(l=>({name:J.camelCase(`updateRecordForm-child-${l.name}`),type:"item",title:l.title||l.tableName,schema:{collection:l.name,dataSource:a,title:`{{t("Update record", { ns: "${y}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Z}))})),[o]),[r,t]=h.useState([]),i=e.useMenuSearch(n,r);return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${y}" })}}`,componentProps:{onOpenChange(a){t(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:d.FilterDynamicComponent,UpdateFormDesigner:ye},parseFormOptions(o){const n={};return M(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var u,l;const[i]=Object.keys(t.properties),a=t.properties[i],c=((u=Object.entries(a.properties).find(([x,f])=>f["x-component"]==="ActionBar"))==null?void 0:u[0])||"actions";n[i]=k(g({},t["x-decorator-props"]),{type:"update",title:((l=t["x-component-props"])==null?void 0:l.title)||i,actions:M(a.properties[c],x=>x["x-component"]==="Action").map(x=>{var f,p;return{status:x["x-decorator-props"].value,values:(p=(f=x["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:p.values,key:x.name}})})}),n}},block:{scope:{},components:{}}},z=new T.Registry;z.register("customForm",oe),z.register("createForm",de),z.register("updateForm",ge);function be(){const{workflow:o}=d.useFlowContext(),n=d.useTrigger();return n.useInitializers?n.useInitializers(o.config):null}const Se={customForm:oe.title,record:`{{t("Data record", { ns: "${y}" })}}`};function ve(){var t,i;const o=b.useFieldSchema(),n=(i=Se[(t=o["x-designer-props"])==null?void 0:t.type])!=null?i:'{{t("Block")}}',r=e.useCompile();return s.jsxs(e.GeneralSchemaDesigner,{title:r(n),children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Fe=new e.SchemaInitializer({name:"AddBlockButton",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const o=e.usePlugin(d),n=d.useNodeContext(),r=d.useAvailableUpstreams(n),t=[be()].filter(Boolean),i=r.map(c=>{var l;const u=o.instructions.get(c.type);return(l=u==null?void 0:u.useInitializers)==null?void 0:l.call(u,c)}).filter(Boolean);return[...t,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${y}" })}}`,children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const n=e.useDataSourceManager().getAllCollections();return Array.from(z.getValues()).map(r=>{const{useInitializer:t}=r.config;return t({allCollections:n})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});function ke(){var I,O,D;const o=h.useContext(e.SchemaComponentContext),{t:n}=j.useTranslation(),r=b.useFieldSchema(),t=d.useWorkflowVariableOptions(),[i,a]=h.useState(!1),[c,u]=h.useState((D=(O=(I=r==null?void 0:r["x-action-settings"])==null?void 0:I.assignedValues)==null?void 0:O.schema)!=null?D:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[l,x]=h.useState(null),{components:f}=e.useSchemaOptionsContext();h.useEffect(()=>{x(new b.Schema({properties:{grid:c}}))},[c]);const p=h.useMemo(()=>{var P,N;const B=(N=(P=r==null?void 0:r["x-action-settings"])==null?void 0:P.assignedValues)==null?void 0:N.values;return U.createForm({initialValues:T.lodash.cloneDeep(B),values:T.lodash.cloneDeep(B)})},[r]),m=e.useFormActiveFields(),v=n("Assign field values");function A(){a(!1)}function F(){r["x-action-settings"]||(r["x-action-settings"]={}),r["x-action-settings"].assignedValues||(r["x-action-settings"].assignedValues={}),r["x-action-settings"].assignedValues.schema=c,r["x-action-settings"].assignedValues.values=p.values,a(!1),setTimeout(()=>{var B;(B=o.refresh)==null||B.call(o)},300)}return s.jsxs(s.Fragment,{children:[s.jsx(e.SchemaSettingsItem,{title:v,onClick:()=>a(!0),children:v}),s.jsx(S.Modal,{width:"50%",title:v,open:i,onCancel:A,footer:s.jsxs(S.Space,{children:[s.jsx(S.Button,{onClick:A,children:n("Cancel")}),s.jsx(S.Button,{type:"primary",onClick:F,children:n("Submit")})]}),children:s.jsx(e.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:s.jsx(e.VariableScopeProvider,{scope:t,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:m==null?void 0:m.getActiveFieldsName,children:s.jsx(b.FormProvider,{form:p,children:s.jsxs(E.FormLayout,{layout:"vertical",children:[s.jsx(S.Alert,{message:w("Values preset in this form will override user submitted ones when continue or reject.")}),s.jsx("br",{}),i&&l&&s.jsx(e.SchemaComponentContext.Provider,{value:k(g({},o),{refresh(){u(T.lodash.get(l.toJSON(),"properties.grid"))}}),children:s.jsx(e.SchemaComponent,{schema:l,components:f})})]})})})})})})]})}function Ae(o){return s.jsxs(e.GeneralSchemaDesigner,k(g({},o),{disableInitializer:!0,children:[s.jsx(e.Action.Designer.ButtonEditor,{}),s.jsx(ke,{}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Ie(){const a=e.useSchemaInitializerItem(),{action:n,actionProps:r}=a,t=V(a,["action","actionProps"]),{insert:i}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,k(g({},t),{onClick:()=>{i({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:n},"x-component":"Action","x-component-props":k(g({},r),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function te(){const o=e.useSchemaInitializerItem(),i=o,{action:n,actionProps:r}=i,t=V(i,["action","actionProps"]);return s.jsx(e.InitializerWithSwitch,k(g({},t),{item:o,schema:{type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:n},"x-component":"Action","x-component-props":k(g({},r),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${n}`},type:"x-action"}))}const we=new e.SchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${y}" })}}`,Component:Ie,action:d.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${y}" })}}`,Component:te,action:d.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${y}" })}}`,Component:te,action:d.JOB_STATUS.PENDING}]});function Be(){return{run(){}}}function Te({value:o,onChange:n}){const r=e.usePlugin(d),t=h.useContext(e.SchemaComponentContext),i=d.useNodeContext(),a=d.useAvailableUpstreams(i),c=b.useForm(),{workflow:u}=d.useFlowContext(),l={};a.forEach(p=>{const m=r.instructions.get(p.type);Object.assign(l,m.components)});const x=h.useMemo(()=>new b.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${y}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:e.css`
|
|
1
|
+
(function(C,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react/jsx-runtime"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@nocobase/utils/client"),require("lodash"),require("@ant-design/icons"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","react/jsx-runtime","@formily/antd-v5","@formily/core","@formily/react","antd","react","react-i18next","@nocobase/utils/client","lodash","@ant-design/icons","dayjs"],e):(C=typeof globalThis!="undefined"?globalThis:C||self,e(C["@nocobase/plugin-workflow-manual"]={},C["@nocobase/client"],C["@nocobase/plugin-workflow"],C.jsxRuntime,C["@formily/antd-v5"],C["@formily/core"],C["@formily/react"],C.antd,C.react,C["react-i18next"],C["@nocobase/utils"],C.lodash,C["@ant-design/icons"],C.dayjs))})(this,function(C,e,c,s,_,K,b,S,h,N,D,J,q,de){"use strict";var Re=Object.defineProperty,eo=Object.defineProperties;var oo=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var H=(C,e,c)=>e in C?Re(C,e,{enumerable:!0,configurable:!0,writable:!0,value:c}):C[e]=c,y=(C,e)=>{for(var c in e||(e={}))le.call(e,c)&&H(C,c,e[c]);if(Y)for(var c of Y(e))pe.call(e,c)&&H(C,c,e[c]);return C},w=(C,e)=>eo(C,oo(e));var $=(C,e)=>{var c={};for(var s in C)le.call(C,s)&&e.indexOf(s)<0&&(c[s]=C[s]);if(C!=null&&Y)for(var s of Y(C))e.indexOf(s)<0&&pe.call(C,s)&&(c[s]=C[s]);return c};var E=(C,e,c)=>(H(C,typeof e!="symbol"?e+"":e,c),c);var U=(C,e,c)=>new Promise((s,_)=>{var K=h=>{try{S(c.next(h))}catch(N){_(N)}},b=h=>{try{S(c.throw(h))}catch(N){_(N)}},S=h=>h.done?s(h.value):Promise.resolve(h.value).then(K,b);S((c=c.apply(C,e)).next())});const g="workflow-manual";function A(o,r={}){const{t:n}=ue(r);return n(o)}function ue(o){return N.useTranslation(g,o)}function X(o){var M,j,G;const r=e.useRecord(),n=b.useFieldSchema(),t=b.useField(),i=h.useRef(null),a=o.dataSource||e.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:p}=e.useAssociationNames(a),{appends:u,updateAssociationValues:d}=p(),[f]=Object.keys((M=n.toJSON().properties)!=null?M:{}),m=(j=r==null?void 0:r.result)==null?void 0:j[f],{findComponent:l}=e.useDesignable(),x=l((G=t.component)==null?void 0:G[0])||h.Fragment,k=h.useMemo(()=>K.createForm({initialValues:m}),[m]),v=h.useMemo(()=>y({appends:u},o.params),[u,o.params]),F=h.useMemo(()=>({loading:!1,data:{data:m}}),[m]),I=e.useAPIClient(),z=e.useDataSourceHeaders(a),T=I.resource(o.collection,void 0,z),B=e.useBlockRequestContext(),V=h.useMemo(()=>({params:v,form:k,field:t,service:F,updateAssociationValues:d,formBlockRef:i}),[t,k,v,F,d]);return!r.status||m?s.jsx(e.CollectionManagerProvider,{dataSource:a,children:s.jsx(e.CollectionProvider_deprecated,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:m,parent:null,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",children:s.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:o,field:t,service:F,resource:T,__parent:B},children:s.jsx(e.FormBlockContext.Provider,{value:V,children:s.jsxs(x,w(y({},t.componentProps),{children:[s.jsx(e.FormV2.Templates,{style:{marginBottom:18},form:k}),s.jsx("div",{ref:i,children:s.jsx(b.RecursionField,{schema:n,onlyRenderProperties:!0})})]}))})})})})})}):null}function me(o){return e.createFormBlockSchema(o)}function fe(n){var t=n,{schema:o}=t,r=$(t,["schema"]);const{getTemplateSchemaByMode:i}=e.useSchemaTemplateManager(),{insert:a}=e.useSchemaInitializer(),p=e.useRecordCollectionDataSourceItems("FormItem");function u(f){return U(this,arguments,function*({item:d}){var v;const m=d.template?yield i(d):null,l=me(w(y({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${g}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:c.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},o),{template:m}));delete l["x-acl-action-props"],delete l["x-acl-action"];const[x]=Object.keys(l.properties),k=((v=Object.entries(l.properties[x].properties).find(([F,I])=>I["x-component"]==="ActionBar"))==null?void 0:v[0])||"actions";l.properties[x].properties[k]["x-decorator"]="ActionBarProvider",l.properties[x].properties[k]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},c.traverseSchema(l,F=>{F["x-uid"]&&delete F["x-uid"]}),a(l)})}return s.jsx(e.SchemaInitializerItem,w(y({},r),{onClick:u,items:p}))}function Z(){var r,n;const o=e.useSchemaInitializerItem();return s.jsx(e.CollectionProvider_deprecated,{dataSource:(r=o.schema)==null?void 0:r.dataSource,collection:(n=o.schema)==null?void 0:n.collection,children:s.jsx(fe,y({},o))})}function P(o,r,n=!1){const t=[];return o?r(o)&&(!n||!o.properties)?(t.push(o),t):(o.properties&&Object.keys(o.properties).forEach(i=>{t.push(...P(o.properties[i],r))}),t):t}function he(){const{name:o,title:r}=e.useCollection_deprecated();return s.jsxs(e.GeneralSchemaDesigner,{title:r||o,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:o}),s.jsx(e.SchemaSettingsDataTemplates,{collectionName:o}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const xe={title:`{{t("Create record form", { ns: "${g}" })}}`,config:{useInitializer({allCollections:o}){const r=h.useMemo(()=>o.map(({key:a,displayName:p,collections:u})=>({key:a,name:a,label:p,type:"subMenu",children:u.map(d=>({name:J.camelCase(`createRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Create record", { ns: "${g}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Z}))})),[o]),[n,t]=h.useState([]),i=e.useMenuSearch({data:r,openKeys:n});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${g}" })}}`,componentProps:{onOpenChange(a){t(a)}},children:i}},initializers:{},components:{CreateFormDesigner:he},parseFormOptions(o){const r={};return P(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var u,d;const[i]=Object.keys(t.properties),a=t.properties[i],p=((u=Object.entries(a.properties).find(([f,m])=>m["x-component"]==="ActionBar"))==null?void 0:u[0])||"actions";r[i]={type:"create",title:((d=t["x-component-props"])==null?void 0:d.title)||i,actions:P(a.properties[p],f=>f["x-component"]==="Action").map(f=>{var m,l;return{status:f["x-decorator-props"].value,values:(l=(m=f["x-action-settings"])==null?void 0:m.assignedValues)==null?void 0:l.values,key:f.name}}),collection:t["x-decorator-props"].collection}}),r}},block:{scope:{},components:{}}};function W(o){var f,m,l,x;const[r,n]=h.useState((m=(f=o.collection)==null?void 0:f.fields)!=null?m:[]),t=e.useRecord(),i=b.useField(),a=b.useFieldSchema(),[p]=Object.keys((l=a.toJSON().properties)!=null?l:{}),u=(x=t==null?void 0:t.result)==null?void 0:x[p],d=h.useMemo(()=>K.createForm({initialValues:u}),[u]);return!t.status||u?s.jsx(e.CollectionProvider_deprecated,{collection:w(y({},o.collection),{fields:r}),children:s.jsx(e.RecordProvider,{record:u,parent:null,children:s.jsx(e.FormBlockContext.Provider,{value:{form:d,field:i,setCollectionFields:n},children:o.children})})}):null}function Ce(){const{insert:o}=e.useSchemaInitializer(),r=e.useSchemaInitializerItem();return s.jsx(e.SchemaInitializerItem,w(y({},r),{onClick:()=>{o({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:D.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[D.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${g}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:c.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const R={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function ge(o){const r={};return Object.keys(o).forEach(n=>{const t=o[n],{group:i="others"}=t;r[i]=r[i]||{},J.set(r,[i,n],t)}),Object.keys(R).filter(n=>["basic","choices","datetime","media"].includes(n)).map(n=>({title:R[n],children:Object.keys(r[n]||{}).map(t=>{const i=r[n][t];return y({value:t,title:i.title,name:t},r[n][t])}).sort((t,i)=>t.order-i.order)}))}function ye(){const{interfaces:o}=e.useCollectionManager_deprecated();return ge(o).map(n=>({name:n.title,type:"itemGroup",title:n.title,children:n.children.map(t=>({name:t.name,type:"item",title:t.title,Component:Se,fieldInterface:t.name}))}))}const ee=h.createContext({}),oe=o=>{const[r,n]=h.useState(null),[t,i]=h.useState(),a=ye(),p=e.useCollection_deprecated(),{setCollectionFields:u}=h.useContext(e.FormBlockContext),d=h.useMemo(()=>K.createForm(),[r]);return s.jsxs(ee.Provider,{value:{onAddField(f){const m=J.pick(f,["name","group","title","default","validateSchema"]),{properties:z}=f,T=z,{unique:l,type:x,layout:k,autoIncrement:v}=T,F=$(T,["unique","type","layout","autoIncrement"]);m.properties=F;const I=J.cloneDeep(m);delete I.properties.name["x-disabled"],n(I)},setCallback:i},children:[s.jsx(e.SchemaInitializerItems,w(y({},o),{items:a})),s.jsx(e.ActionContextProvider,{value:{visible:!!r,setVisible(f){f||n(null)}},children:r?s.jsx(e.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:d},"x-component":"Action.Drawer",properties:w(y({},r.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const f=b.useForm();return{run(){return U(this,null,function*(){i(null),n(null),f.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:f,query:m,reset:l}=b.useForm(),x=[A("Field name existed in form")];return{run(){return U(this,null,function*(){var T,B,V,M;const{default:v}=r,F=D.uid();if(v.name=(T=f.name)!=null?T:F,v.uiSchema.title=(V=(B=f.uiSchema)==null?void 0:B.title)!=null?V:F,v.interface=r.name,(M=p.fields)==null?void 0:M.find(j=>j.name===v.name)){m("name").take().setFeedback({type:"error",messages:x});return}const z=D.merge(v,f);u([...p.fields,z]),t({name:v.name,type:v.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:z},"x-collection-field":`${p.name}.${v.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),l(),i(null),n(null)})}}}}}}}})},components:{ArrayTable:_.ArrayTable}}):null})]})},te=new e.CompatibleSchemaInitializer({name:"AddCustomFormField",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:oe}),be=new e.CompatibleSchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:oe},te);function Se(){const o=e.useSchemaInitializerItem(),{insert:r,setVisible:n}=e.useSchemaInitializer(),{onAddField:t,setCallback:i}=h.useContext(ee),{getInterface:a}=e.useCollectionManager_deprecated(),p=a(o.fieldInterface);return s.jsx(e.SchemaInitializerItem,y({onClick:()=>{i(()=>r),t(p),n(!1)}},o),o.fieldInterface)}const ne={title:`{{t("Custom form", { ns: "${g}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${g}" })}}`,Component:Ce}},initializers:{},components:{CustomFormBlockProvider:W},parseFormOptions(o){const r={};return P(o,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var d,f;const[i]=Object.keys(t.properties),a=t.properties[i],p=P(a.properties.grid,m=>m["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=p.map(m=>{var l,x;return(x=(l=m["x-component-props"])==null?void 0:l.field)!=null?x:m["x-interface-options"]});const u=((d=Object.entries(a.properties).find(([m,l])=>l["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";r[i]={type:"custom",title:((f=t["x-component-props"])==null?void 0:f.title)||i,actions:P(a.properties[u],m=>m["x-component"]==="Action").map(m=>{var l,x;return{status:m["x-decorator-props"].value,values:(x=(l=m["x-action-settings"])==null?void 0:l.assignedValues)==null?void 0:x.values,key:m.name}}),collection:t["x-decorator-props"].collection}}),r}},block:{scope:{},components:{CustomFormBlockProvider:W}}};function ve(){const{name:o,title:r}=e.useCollection_deprecated(),n=b.useFieldSchema(),{t}=N.useTranslation(),{dn:i}=e.useDesignable();return s.jsxs(e.GeneralSchemaDesigner,{title:r||o,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsActionModalItem,{title:t("Filter settings",{ns:g}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var p;return{options:e.useCollectionFilterOptions((p=n==null?void 0:n["x-decorator-props"])==null?void 0:p.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:n==null?void 0:n["x-decorator-props"],onSubmit:({filter:a})=>{n["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":n["x-decorator-props"]}}),i.refresh()}}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:o}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Fe={title:`{{t("Update record form", { ns: "${g}" })}}`,config:{useInitializer({allCollections:o}){const r=h.useMemo(()=>o.map(({key:a,displayName:p,collections:u})=>({key:a,name:a,label:p,type:"subMenu",children:u.map(d=>({name:J.camelCase(`updateRecordForm-child-${d.name}`),type:"item",title:d.title||d.tableName,schema:{collection:d.name,dataSource:a,title:`{{t("Update record", { ns: "${g}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Z}))})),[o]),[n,t]=h.useState([]),i=e.useMenuSearch({data:r,openKeys:n});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${g}" })}}`,componentProps:{onOpenChange(a){t(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:c.FilterDynamicComponent,UpdateFormDesigner:ve},parseFormOptions(o){const r={};return P(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var u,d;const[i]=Object.keys(t.properties),a=t.properties[i],p=((u=Object.entries(a.properties).find(([f,m])=>m["x-component"]==="ActionBar"))==null?void 0:u[0])||"actions";r[i]=w(y({},t["x-decorator-props"]),{type:"update",title:((d=t["x-component-props"])==null?void 0:d.title)||i,actions:P(a.properties[p],f=>f["x-component"]==="Action").map(f=>{var m,l;return{status:f["x-decorator-props"].value,values:(l=(m=f["x-action-settings"])==null?void 0:m.assignedValues)==null?void 0:l.values,key:f.name}})})}),r}},block:{scope:{},components:{}}},O=new D.Registry;O.register("customForm",ne),O.register("createForm",xe),O.register("updateForm",Fe);function re(){const{workflow:o}=c.useFlowContext(),r=c.useTrigger();return r.useInitializers?r.useInitializers(o.config):null}ne.title,`${g}`;const se=new e.CompatibleSchemaInitializer({name:"AddBlockButton",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const o=e.usePlugin(c),r=c.useNodeContext(),n=c.useAvailableUpstreams(r),t=[re()].filter(Boolean),i=n.map(p=>{var d;const u=o.instructions.get(p.type);return(d=u==null?void 0:u.useInitializers)==null?void 0:d.call(u,p)}).filter(Boolean);return[...t,...i.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const r=e.useDataSourceManager().getAllCollections();return Array.from(O.getValues()).map(n=>{const{useInitializer:t}=n.config;return t({allCollections:r})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]}),ke=new e.CompatibleSchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const o=e.usePlugin(c),r=c.useNodeContext(),n=c.useAvailableUpstreams(r),t=[re()].filter(Boolean),i=n.map(p=>{var d;const u=o.instructions.get(p.type);return(d=u==null?void 0:u.useInitializers)==null?void 0:d.call(u,p)}).filter(Boolean);return[...t,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${g}" })}}`,children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const r=e.useDataSourceManager().getAllCollections();return Array.from(O.getValues()).map(n=>{const{useInitializer:t}=n.config;return t({allCollections:r})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},se);function we(){var I,z,T;const o=h.useContext(e.SchemaComponentContext),{t:r}=N.useTranslation(),n=b.useFieldSchema(),t=c.useWorkflowVariableOptions(),[i,a]=h.useState(!1),[p,u]=h.useState((T=(z=(I=n==null?void 0:n["x-action-settings"])==null?void 0:I.assignedValues)==null?void 0:z.schema)!=null?T:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[d,f]=h.useState(null),{components:m}=e.useSchemaOptionsContext();h.useEffect(()=>{f(new b.Schema({properties:{grid:p}}))},[p]);const l=h.useMemo(()=>{var V,M;const B=(M=(V=n==null?void 0:n["x-action-settings"])==null?void 0:V.assignedValues)==null?void 0:M.values;return K.createForm({initialValues:D.lodash.cloneDeep(B),values:D.lodash.cloneDeep(B)})},[n]),x=e.useFormActiveFields(),k=r("Assign field values");function v(){a(!1)}function F(){n["x-action-settings"]||(n["x-action-settings"]={}),n["x-action-settings"].assignedValues||(n["x-action-settings"].assignedValues={}),n["x-action-settings"].assignedValues.schema=p,n["x-action-settings"].assignedValues.values=l.values,a(!1),setTimeout(()=>{var B;(B=o.refresh)==null||B.call(o)},300)}return s.jsxs(s.Fragment,{children:[s.jsx(e.SchemaSettingsItem,{title:k,onClick:()=>a(!0),children:k}),s.jsx(S.Modal,{width:"50%",title:k,open:i,onCancel:v,footer:s.jsxs(S.Space,{children:[s.jsx(S.Button,{onClick:v,children:r("Cancel")}),s.jsx(S.Button,{type:"primary",onClick:F,children:r("Submit")})]}),children:s.jsx(e.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:s.jsx(e.VariableScopeProvider,{scope:t,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:x==null?void 0:x.getActiveFieldsName,children:s.jsx(b.FormProvider,{form:l,children:s.jsxs(_.FormLayout,{layout:"vertical",children:[s.jsx(S.Alert,{message:A("Values preset in this form will override user submitted ones when continue or reject.")}),s.jsx("br",{}),i&&d&&s.jsx(e.SchemaComponentContext.Provider,{value:w(y({},o),{refresh(){u(D.lodash.get(d.toJSON(),"properties.grid"))}}),children:s.jsx(e.SchemaComponent,{schema:d,components:m})})]})})})})})})]})}function Ie(o){return s.jsxs(e.GeneralSchemaDesigner,w(y({},o),{disableInitializer:!0,children:[s.jsx(e.Action.Designer.ButtonEditor,{}),s.jsx(we,{}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function ie(){const a=e.useSchemaInitializerItem(),{action:r,actionProps:n}=a,t=$(a,["action","actionProps"]),{insert:i}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,w(y({},t),{onClick:()=>{i({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":w(y({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function L(){const o=e.useSchemaInitializerItem(),i=o,{action:r,actionProps:n}=i,t=$(i,["action","actionProps"]);return s.jsx(e.InitializerWithSwitch,w(y({},t),{item:o,schema:{type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":w(y({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${r}`},type:"x-action"}))}const ae=new e.CompatibleSchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${g}" })}}`,Component:ie,action:c.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.PENDING}]}),Ae=new e.CompatibleSchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${g}" })}}`,Component:ie,action:c.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.PENDING}]},ae);function Be(){return{run(){}}}function Te({value:o,onChange:r}){const n=e.usePlugin(c),t=h.useContext(e.SchemaComponentContext),i=c.useNodeContext(),a=c.useAvailableUpstreams(i),p=b.useForm(),{workflow:u}=c.useFlowContext(),d={};a.forEach(l=>{const x=n.instructions.get(l.type);Object.assign(d,x.components)});const f=h.useMemo(()=>new b.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${g}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:e.css`
|
|
2
2
|
.ant-drawer-body {
|
|
3
3
|
background: var(--nb-box-bg);
|
|
4
4
|
}
|
|
5
|
-
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"
|
|
5
|
+
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:o!=null?o:{tab1:{type:"void",title:`{{t("Manual", { ns: "${g}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),m=h.useCallback(function(){const{tabs:x}=D.lodash.get(f.toJSON(),"properties.drawer.properties"),k=Array.from(O.getValues()).reduce((v,F)=>Object.assign(v,F.config.parseFormOptions(x)),{});p.setValuesIn("forms",k),r(x.properties)},[p,r,f]);return s.jsx(e.SchemaComponentContext.Provider,{value:w(y({},t),{designable:!u.executed,refresh:m}),children:s.jsx(e.SchemaComponent,{schema:f,components:w(y(y({},d),Array.from(O.getValues()).reduce((l,x)=>Object.assign(l,x.config.components),{})),{FormBlockProvider:X,DetailsBlockProvider:c.DetailsBlockProvider,ManualActionStatusProvider(l){return l.children},ActionBarProvider(l){return l.children},SimpleDesigner:c.SimpleDesigner,ManualActionDesigner:Ie}),scope:{useSubmit:Be,useDetailsBlockProps:e.useFormBlockContext}})})}function ze(o){const{workflow:r}=c.useFlowContext(),[n,t]=h.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(S.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:A(r.executed?"View user interface":"Configure user interface")}),s.jsx(e.ActionContextProvider,{value:{visible:n,setVisible:t,formValueChanged:!1},children:o.children})]})}function Me({value:o,onChange:r}){const n=s.jsx("fieldset",{children:s.jsx(_.FormLayout,{layout:"vertical",children:s.jsx(e.FormItem,{label:A("Negotiation"),children:s.jsxs(S.Radio.Group,{value:o,onChange:r,children:[s.jsx(S.Radio,{value:1,children:s.jsxs(S.Tooltip,{title:A("Everyone should pass"),placement:"bottom",children:[s.jsx("span",{children:A("All pass")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:-1,children:s.jsxs(S.Tooltip,{title:A("Anyone pass"),placement:"bottom",children:[s.jsx("span",{children:A("Any pass")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return s.jsxs("fieldset",{className:e.css`
|
|
6
6
|
.ant-radio-group {
|
|
7
7
|
.anticon {
|
|
8
8
|
margin-left: 0.5em;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
`,children:[s.jsx(S.Form.Item,{children:s.jsxs(S.Radio.Group,{value:!!o,onChange:({target:{value:t}})=>{console.log(t),n(Number(t))},children:[s.jsx(S.Radio,{value:!0,children:s.jsxs(S.Tooltip,{title:w("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:w("Separately")}),s.jsx(K.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:!1,children:s.jsxs(S.Tooltip,{title:w("Everyone shares one task"),placement:"bottom",children:[s.jsx("span",{children:w("Collaboratively")}),s.jsx(K.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),o?r:null]})}function Me(o){return o.isForeignKey?o.target==="users":o.collectionName==="users"&&o.name==="id"}function ze({multiple:o=!1,value:n=[],onChange:r}){const t=d.useWorkflowVariableOptions({types:[Me]});return s.jsx(e.Variable.Input,{scope:t,value:n[0],onChange:i=>{r([i])},children:s.jsx(e.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:n[0],onChange:i=>{r(i!=null?[i]:[])}})})}class Pe extends d.Instruction{constructor(){super(...arguments);$(this,"title",`{{t("Manual", { ns: "${y}" })}}`);$(this,"type","manual");$(this,"group","manual");$(this,"description",`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${y}" })}}`);$(this,"fieldset",{assignees:{type:"array",title:`{{t("Assignees", { ns: "${y}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${y}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${y}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}});$(this,"components",{SchemaConfigButton:Oe,SchemaConfig:Te,ModeConfig:De,AssigneesSelect:ze})}useVariables({key:r,title:t,config:i},{types:a,fieldNames:c=d.defaultFieldNames}){var p;const u=e.useCompile(),{getCollectionFields:l}=e.useCollectionManager_deprecated(),x=Object.keys((p=i.forms)!=null?p:{});if(!x.length)return null;const f=x.map(m=>{var I;const v=i.forms[m],A=d.getCollectionFieldOptions({fields:(I=v.collection)==null?void 0:I.fields,collection:v.collection,types:a,compile:u,getCollectionFields:l}),F=u(v.title)||m;return A.length?{key:m,value:m,label:F,title:F,children:A}:null}).filter(Boolean);return f.length?{[c.value]:r,[c.label]:t,[c.children]:f}:null}useInitializers(r){var c;const{getCollection:t}=e.useCollectionManager_deprecated(),i=Object.keys((c=r.config.forms)!=null?c:{});if(!i.length||r.config.mode)return null;const a=i.map(u=>{var f,p;const l=r.config.forms[u],{fields:x=[]}=t(l.collection);return x.length?{name:(f=l.title)!=null?f:u,type:"item",title:(p=l.title)!=null?p:u,Component:d.CollectionBlockInitializer,collection:l.collection,dataSource:`{{$jobsMapByNodeKey.${r.key}.${u}}}`}:null}).filter(Boolean);return a.length?{name:`#${r.id}`,key:"forms",type:"subMenu",title:r.title,children:a}:null}isAvailable({engine:r,workflow:t,upstream:i,branchIndex:a}){return!r.isWorkflowSync(t)}}const Ve={title:`{{t("Task", { ns: "${y}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},je={title:`{{t("Workflow", { ns: "${y}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Ne={title:`{{t("Workflow todos", { ns: "${y}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${y}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${y}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${y}" })}}`,"x-component":"Select",enum:d.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},$e=b.observer(()=>{var n,r,t;const o=b.useField();return(t=(n=o==null?void 0:o.value)==null?void 0:n.title)!=null?t:`#${(r=o.value)==null?void 0:r.id}`},{displayName:"NodeColumn"}),_e=b.observer(()=>{var n,r,t;const o=b.useField();return(t=(n=o==null?void 0:o.value)==null?void 0:n.title)!=null?t:`#${(r=o.value)==null?void 0:r.id}`},{displayName:"WorkflowColumn"}),Ee=b.observer(()=>{var n,r,t;const o=b.useField();return(t=(n=o==null?void 0:o.value)==null?void 0:n.nickname)!=null?t:(r=o.value)==null?void 0:r.id},{displayName:"UserColumn"});function Ue(o){const n=e.useRecord(),r=w("Unprocessed");return n.execution.status&&!n.status?s.jsx(S.Tag,{children:r}):o.children}const Y=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:$e,WorkflowColumn:_e,UserColumn:Ee,UserJobStatusColumn:Ue},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${y}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${y}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Ke(o){var x;const{data:n}=e.useCurrentUserContext(),{userJob:r}=d.useFlowContext(),{status:t,result:i,userId:a}=r,c=b.useFieldSchema(),{name:u}=c.parent.toJSON();let{children:l}=o;return t?i[u]||(l=null):((x=n==null?void 0:n.data)==null?void 0:x.id)!==a&&(l=null),l}const ne=h.createContext(null);ne.displayName="ManualActionStatusContext";function qe({value:o,children:n}){const{userJob:r,execution:t}=d.useFlowContext(),i=b.useField(),a=b.useFieldSchema();return h.useEffect(()=>{(t.status||r.status)&&(i.disabled=!0,i.visible=r.status===o&&r.result._===a.name)},[t,r,o,i,a.name]),s.jsx(ne.Provider,{value:o,children:n})}function Ge(){const o=e.useAPIClient(),{setVisible:n}=e.useActionContext(),{values:r,submit:t}=b.useForm(),i=b.useFieldSchema(),{service:a}=e.useTableBlockContext(),{userJob:c,execution:u}=d.useFlowContext(),{name:l}=i,{name:x}=i.parent.parent;return{run(){return _(this,null,function*(){u.status||c.status||(yield t(),yield o.resource("users_jobs").submit({filterByTk:c.id,values:{result:{[x]:r,_:l}}}),n(!1),a.refresh())})}}}function Je(o){var f;const n=e.usePlugin(d),r=e.useAPIClient(),{id:t}=e.useRecord(),[i,a]=h.useState(null),[c,u]=h.useState(null);h.useEffect(()=>{var p,m;t&&((m=(p=r.resource("users_jobs")).get)==null||m.call(p,{filterByTk:t,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:v})=>{var B;const P=(B=v==null?void 0:v.data)!=null?B:{},{node:A,workflow:N={}}=P,q=N,{nodes:F=[]}=q,I=V(q,["nodes"]),G=P,{execution:O}=G,D=V(G,["node","workflow","execution"]);d.linkNodes(F),u(A),a({userJob:D,workflow:I,nodes:F,execution:O})}))},[r,t]);const x=d.useAvailableUpstreams(i==null?void 0:i.nodes.find(p=>p.id===c.id)).reduce((p,{type:m})=>Object.assign(p,n.instructions.get(m).components),{});return c&&i?s.jsx(d.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:g(g({FormBlockProvider:X,DetailsBlockProvider:H,ActionBarProvider:Ke,ManualActionStatusProvider:qe},Array.from(z.getValues()).reduce((p,m)=>Object.assign(p,m.block.components),{})),x),scope:g({useSubmit:Ge,useFormBlockProps:Le,useDetailsBlockProps:Ye},Array.from(z.getValues()).reduce((p,m)=>Object.assign(p,m.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(f=c.config)==null?void 0:f.schema}})}):s.jsx(S.Spin,{})}function Le(){var c;const{userJob:o,execution:n}=d.useFlowContext(),r=e.useRecord(),{data:t}=e.useCurrentUserContext(),{form:i}=e.useFormBlockContext(),a=n.status||o.status?r?"readPretty":"disabled":((c=t==null?void 0:t.data)==null?void 0:c.id)!==o.userId?"disabled":"editable";return h.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Ye(){const{form:o}=e.useFormBlockContext();return{form:o}}function Qe(){const o=e.useCompile(),{status:n,updatedAt:r}=e.useRecord(),t=d.JobStatusOptionsMap[n];return n?s.jsxs(S.Space,{children:[s.jsx("time",{className:e.css`
|
|
11
|
+
`,children:[s.jsx(S.Form.Item,{children:s.jsxs(S.Radio.Group,{value:!!o,onChange:({target:{value:t}})=>{console.log(t),r(Number(t))},children:[s.jsx(S.Radio,{value:!0,children:s.jsxs(S.Tooltip,{title:A("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:A("Separately")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:!1,children:s.jsxs(S.Tooltip,{title:A("Everyone shares one task"),placement:"bottom",children:[s.jsx("span",{children:A("Collaboratively")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),o?n:null]})}function De(o){return o.isForeignKey?o.target==="users":o.collectionName==="users"&&o.name==="id"}function Oe({multiple:o=!1,value:r=[],onChange:n}){const t=c.useWorkflowVariableOptions({types:[De]});return s.jsx(e.Variable.Input,{scope:t,value:r[0],onChange:i=>{n([i])},children:s.jsx(e.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:r[0],onChange:i=>{n(i!=null?[i]:[])}})})}class Pe extends c.Instruction{constructor(){super(...arguments);E(this,"title",`{{t("Manual", { ns: "${g}" })}}`);E(this,"type","manual");E(this,"group","manual");E(this,"description",`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${g}" })}}`);E(this,"fieldset",{assignees:{type:"array",title:`{{t("Assignees", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}});E(this,"components",{SchemaConfigButton:ze,SchemaConfig:Te,ModeConfig:Me,AssigneesSelect:Oe})}useVariables({key:n,title:t,config:i},{types:a,fieldNames:p=c.defaultFieldNames}){var l;const u=e.useCompile(),{getCollectionFields:d}=e.useCollectionManager_deprecated(),f=Object.keys((l=i.forms)!=null?l:{});if(!f.length)return null;const m=f.map(x=>{var I;const k=i.forms[x],v=c.getCollectionFieldOptions({fields:(I=k.collection)==null?void 0:I.fields,collection:k.collection,types:a,compile:u,getCollectionFields:d}),F=u(k.title)||x;return v.length?{key:x,value:x,label:F,title:F,children:v}:null}).filter(Boolean);return m.length?{[p.value]:n,[p.label]:t,[p.children]:m}:null}useInitializers(n){var p;const{getCollection:t}=e.useCollectionManager_deprecated(),i=Object.keys((p=n.config.forms)!=null?p:{});if(!i.length||n.config.mode)return null;const a=i.map(u=>{var m,l;const d=n.config.forms[u],{fields:f=[]}=t(d.collection);return f.length?{name:(m=d.title)!=null?m:u,type:"item",title:(l=d.title)!=null?l:u,Component:c.CollectionBlockInitializer,collection:d.collection,dataPath:`$jobsMapByNodeKey.${n.key}.${u}`}:null}).filter(Boolean);return a.length?{name:`#${n.id}`,key:"forms",type:"subMenu",title:n.title,children:a}:null}isAvailable({engine:n,workflow:t,upstream:i,branchIndex:a}){return!n.isWorkflowSync(t)}}const Ve={title:`{{t("Task", { ns: "${g}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},je={title:`{{t("Workflow", { ns: "${g}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Ne={title:`{{t("Workflow todos", { ns: "${g}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${g}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${g}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${g}" })}}`,"x-component":"Select",enum:c.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},$e=b.observer(()=>{var r,n,t;const o=b.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),Ee=b.observer(()=>{var r,n,t;const o=b.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),Ue=b.observer(()=>{var r,n,t;const o=b.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.nickname)!=null?t:(n=o.value)==null?void 0:n.id},{displayName:"UserColumn"});function _e(o){const r=e.useRecord(),n=A("Unprocessed");return r.execution.status&&!r.status?s.jsx(S.Tag,{children:n}):o.children}const Q=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:$e,WorkflowColumn:Ee,UserColumn:Ue,UserJobStatusColumn:_e},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${g}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${g}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Ke(o){var f;const{data:r}=e.useCurrentUserContext(),{userJob:n}=c.useFlowContext(),{status:t,result:i,userId:a}=n,p=b.useFieldSchema(),{name:u}=p.parent.toJSON();let{children:d}=o;return t?i[u]||(d=null):((f=r==null?void 0:r.data)==null?void 0:f.id)!==a&&(d=null),d}const ce=h.createContext(null);ce.displayName="ManualActionStatusContext";function Je({value:o,children:r}){const{userJob:n,execution:t}=c.useFlowContext(),i=b.useField(),a=b.useFieldSchema();return h.useEffect(()=>{(t.status||n.status)&&(i.disabled=!0,i.visible=n.status===o&&n.result._===a.name)},[t,n,o,i,a.name]),s.jsx(ce.Provider,{value:o,children:r})}function qe(){const o=e.useAPIClient(),{setVisible:r}=e.useActionContext(),{values:n,submit:t}=b.useForm(),i=b.useFieldSchema(),{service:a}=e.useTableBlockContext(),{userJob:p,execution:u}=c.useFlowContext(),{name:d}=i,{name:f}=i.parent.parent;return{run(){return U(this,null,function*(){u.status||p.status||(yield t(),yield o.resource("users_jobs").submit({filterByTk:p.id,values:{result:{[f]:n,_:d}}}),r(!1),a.refresh())})}}}function Ge(o){var m;const r=e.usePlugin(c),n=e.useAPIClient(),{id:t}=e.useRecord(),[i,a]=h.useState(null),[p,u]=h.useState(null);h.useEffect(()=>{var l,x;t&&((x=(l=n.resource("users_jobs")).get)==null||x.call(l,{filterByTk:t,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:k})=>{var B;const V=(B=k==null?void 0:k.data)!=null?B:{},{node:v,workflow:M={}}=V,j=M,{nodes:F=[]}=j,I=$(j,["nodes"]),G=V,{execution:z}=G,T=$(G,["node","workflow","execution"]);c.linkNodes(F),u(v),a({userJob:T,workflow:I,nodes:F,execution:z})}))},[n,t]);const f=c.useAvailableUpstreams(i==null?void 0:i.nodes.find(l=>l.id===p.id)).reduce((l,{type:x})=>Object.assign(l,r.instructions.get(x).components),{});return p&&i?s.jsx(c.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:y(y({FormBlockProvider:X,DetailsBlockProvider:c.DetailsBlockProvider,ActionBarProvider:Ke,ManualActionStatusProvider:Je},Array.from(O.getValues()).reduce((l,x)=>Object.assign(l,x.block.components),{})),f),scope:y({useSubmit:qe,useFormBlockProps:Le,useDetailsBlockProps:Ye},Array.from(O.getValues()).reduce((l,x)=>Object.assign(l,x.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(m=p.config)==null?void 0:m.schema}})}):s.jsx(S.Spin,{})}function Le(){var p;const{userJob:o,execution:r}=c.useFlowContext(),n=e.useRecord(),{data:t}=e.useCurrentUserContext(),{form:i}=e.useFormBlockContext(),a=r.status||o.status?n?"readPretty":"disabled":((p=t==null?void 0:t.data)==null?void 0:p.id)!==o.userId?"disabled":"editable";return h.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Ye(){const{form:o}=e.useFormBlockContext();return{form:o}}function Qe(){const o=e.useCompile(),{status:r,updatedAt:n}=e.useRecord(),t=c.JobStatusOptionsMap[r];return r?s.jsxs(S.Space,{children:[s.jsx("time",{className:e.css`
|
|
12
12
|
margin-right: 0.5em;
|
|
13
|
-
`,children:
|
|
13
|
+
`,children:de(n).format("YYYY-MM-DD HH:mm:ss")}),s.jsx(S.Tag,{icon:t.icon,color:t.color,children:o(t.label)})]}):null}function He(){var a;const o=h.useContext(e.SchemaComponentContext),{id:r,node:n,workflow:t,status:i}=e.useRecord();return s.jsx(e.SchemaComponentContext.Provider,{value:w(y({},o),{reset(){},designable:!1}),children:s.jsx(e.SchemaComponent,{components:{FooterStatus:Qe,FlowContextProvider:Ge},schema:{type:"void",name:`drawer-${r}-${i}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${t.title} - ${(a=n.title)!=null?a:`#${n.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function Xe({params:o={},children:r}){const n={collection:"users_jobs",resource:"users_jobs",action:"list",params:w(y({pageSize:20,sort:["-createdAt"]},o),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return s.jsx(e.ExtendCollectionsProvider,{collections:[Ve,je,Ne],children:s.jsx(e.TableBlockProvider,w(y({name:"workflow-todo"},n),{children:r}))})}Q.Drawer=He,Q.Decorator=Xe;const Ze=()=>{const o=e.useSchemaInitializerItem(),{insert:r}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,w(y({icon:s.jsx(q.TableOutlined,{})},o),{onClick:()=>{r({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class We extends e.Plugin{afterAdd(){return U(this,null,function*(){})}load(){return U(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",Pe),this.app.schemaInitializerManager.add(se),this.app.schemaInitializerManager.add(ke),this.app.schemaInitializerManager.add(ae),this.app.schemaInitializerManager.add(Ae),this.app.schemaInitializerManager.add(te),this.app.schemaInitializerManager.add(be),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflowTodos",{title:`{{t("Workflow todos", { ns: "${g}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"})})}addComponents(){this.app.addComponents({WorkflowTodo:Q,WorkflowTodoBlockInitializer:Ze})}}C.default=We,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISchema } from '@formily/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { CompatibleSchemaInitializer, SchemaInitializerItemType } from '@nocobase/client';
|
|
4
4
|
import { JOB_STATUS } from '@nocobase/plugin-workflow/client';
|
|
5
5
|
type ValueOf<T> = T[keyof T];
|
|
6
6
|
export type FormType = {
|
|
@@ -39,8 +39,16 @@ export type ManualFormType = {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
export declare const manualFormTypes: any;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated
|
|
44
|
+
*/
|
|
45
|
+
export declare const addBlockButton_deprecated: CompatibleSchemaInitializer;
|
|
46
|
+
export declare const addBlockButton: CompatibleSchemaInitializer;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated
|
|
49
|
+
*/
|
|
50
|
+
export declare const addActionButton_deprecated: CompatibleSchemaInitializer;
|
|
51
|
+
export declare const addActionButton: CompatibleSchemaInitializer;
|
|
44
52
|
export declare function SchemaConfig({ value, onChange }: {
|
|
45
53
|
value: any;
|
|
46
54
|
onChange: any;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare function createManualFormBlockUISchema(options: any): import("@formily/json-schema").Stringify<{
|
|
2
|
+
[key: symbol]: any;
|
|
3
|
+
[key: `x-${string}`]: any;
|
|
4
|
+
[key: `x-${number}`]: any;
|
|
5
|
+
version?: string;
|
|
6
|
+
name?: import("@formily/json-schema").SchemaKey;
|
|
7
|
+
title?: any;
|
|
8
|
+
description?: any;
|
|
9
|
+
default?: any;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
writeOnly?: boolean;
|
|
12
|
+
type?: import("@formily/json-schema").SchemaTypes;
|
|
13
|
+
enum?: import("@formily/json-schema").SchemaEnum<any>;
|
|
14
|
+
const?: any;
|
|
15
|
+
multipleOf?: number;
|
|
16
|
+
maximum?: number;
|
|
17
|
+
exclusiveMaximum?: number;
|
|
18
|
+
minimum?: number;
|
|
19
|
+
exclusiveMinimum?: number;
|
|
20
|
+
maxLength?: number;
|
|
21
|
+
minLength?: number;
|
|
22
|
+
pattern?: string | RegExp;
|
|
23
|
+
maxItems?: number;
|
|
24
|
+
minItems?: number;
|
|
25
|
+
uniqueItems?: boolean;
|
|
26
|
+
maxProperties?: number;
|
|
27
|
+
minProperties?: number;
|
|
28
|
+
required?: string | boolean | string[];
|
|
29
|
+
format?: string;
|
|
30
|
+
$ref?: string;
|
|
31
|
+
$namespace?: string;
|
|
32
|
+
definitions?: import("@formily/json-schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
33
|
+
properties?: import("@formily/json-schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
34
|
+
items?: import("@formily/json-schema").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
35
|
+
additionalItems?: import("@formily/json-schema").Stringify<any>;
|
|
36
|
+
patternProperties?: import("@formily/json-schema").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
37
|
+
additionalProperties?: import("@formily/json-schema").Stringify<any>;
|
|
38
|
+
"x-value"?: any;
|
|
39
|
+
"x-index"?: number;
|
|
40
|
+
"x-pattern"?: any;
|
|
41
|
+
"x-display"?: any;
|
|
42
|
+
"x-validator"?: any;
|
|
43
|
+
"x-decorator"?: any;
|
|
44
|
+
"x-decorator-props"?: any;
|
|
45
|
+
"x-component"?: any;
|
|
46
|
+
"x-component-props"?: any;
|
|
47
|
+
"x-reactions"?: import("@formily/json-schema").SchemaReactions<any>;
|
|
48
|
+
"x-content"?: any;
|
|
49
|
+
"x-data"?: any;
|
|
50
|
+
"x-visible"?: boolean;
|
|
51
|
+
"x-hidden"?: boolean;
|
|
52
|
+
"x-disabled"?: boolean;
|
|
53
|
+
"x-editable"?: boolean;
|
|
54
|
+
"x-read-only"?: boolean;
|
|
55
|
+
"x-read-pretty"?: boolean;
|
|
56
|
+
"x-compile-omitted"?: string[];
|
|
57
|
+
}>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CompatibleSchemaInitializer } from '@nocobase/client';
|
|
2
2
|
import { ManualFormType } from '../SchemaConfig';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated
|
|
5
|
+
*/
|
|
6
|
+
export declare const addCustomFormField_deprecated: CompatibleSchemaInitializer;
|
|
7
|
+
export declare const addCustomFormField: CompatibleSchemaInitializer;
|
|
4
8
|
declare const _default: ManualFormType;
|
|
5
9
|
export default _default;
|
package/dist/externalVersion.js
CHANGED
|
@@ -3,18 +3,18 @@ module.exports = {
|
|
|
3
3
|
"antd": "5.12.8",
|
|
4
4
|
"dayjs": "1.11.10",
|
|
5
5
|
"react": "18.2.0",
|
|
6
|
-
"@nocobase/client": "0.
|
|
7
|
-
"@nocobase/plugin-workflow": "0.
|
|
6
|
+
"@nocobase/client": "0.21.0-alpha.1",
|
|
7
|
+
"@nocobase/plugin-workflow": "0.21.0-alpha.1",
|
|
8
8
|
"@ant-design/icons": "5.2.6",
|
|
9
9
|
"react-i18next": "11.18.6",
|
|
10
|
-
"@nocobase/utils": "0.
|
|
11
|
-
"@nocobase/server": "0.
|
|
12
|
-
"@nocobase/actions": "0.
|
|
13
|
-
"@nocobase/resourcer": "0.
|
|
14
|
-
"@nocobase/plugin-workflow-test": "0.
|
|
15
|
-
"@nocobase/test": "0.
|
|
10
|
+
"@nocobase/utils": "0.21.0-alpha.1",
|
|
11
|
+
"@nocobase/server": "0.21.0-alpha.1",
|
|
12
|
+
"@nocobase/actions": "0.21.0-alpha.1",
|
|
13
|
+
"@nocobase/resourcer": "0.21.0-alpha.1",
|
|
14
|
+
"@nocobase/plugin-workflow-test": "0.21.0-alpha.1",
|
|
15
|
+
"@nocobase/test": "0.21.0-alpha.1",
|
|
16
16
|
"@formily/core": "2.3.0",
|
|
17
17
|
"@formily/antd-v5": "1.1.9",
|
|
18
|
-
"@nocobase/database": "0.
|
|
18
|
+
"@nocobase/database": "0.21.0-alpha.1",
|
|
19
19
|
"lodash": "4.17.21"
|
|
20
20
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Processor } from '@nocobase/plugin-workflow';
|
|
2
2
|
import ManualInstruction from '../ManualInstruction';
|
|
3
|
-
export default function (this: ManualInstruction, instance: any, { collection }: {
|
|
3
|
+
export default function (this: ManualInstruction, instance: any, { dataSource, collection }: {
|
|
4
|
+
dataSource?: string;
|
|
4
5
|
collection: any;
|
|
5
6
|
}, processor: Processor): Promise<void>;
|
|
@@ -20,8 +20,8 @@ __export(create_exports, {
|
|
|
20
20
|
default: () => create_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(create_exports);
|
|
23
|
-
async function create_default(instance, { collection }, processor) {
|
|
24
|
-
const repo = this.workflow.
|
|
23
|
+
async function create_default(instance, { dataSource = "main", collection }, processor) {
|
|
24
|
+
const repo = this.workflow.app.dataSourceManager.dataSources.get(dataSource).collectionManager.getRepository(collection);
|
|
25
25
|
if (!repo) {
|
|
26
26
|
throw new Error(`collection ${collection} for create data on manual node not found`);
|
|
27
27
|
}
|
|
@@ -35,7 +35,7 @@ async function create_default(instance, { collection }, processor) {
|
|
|
35
35
|
},
|
|
36
36
|
context: {
|
|
37
37
|
executionId: processor.execution.id
|
|
38
|
-
}
|
|
39
|
-
|
|
38
|
+
},
|
|
39
|
+
transaction: processor.transaction
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Processor } from '@nocobase/plugin-workflow';
|
|
2
2
|
import ManualInstruction from '../ManualInstruction';
|
|
3
|
-
export default function (this: ManualInstruction, instance: any, { collection, filter }: {
|
|
3
|
+
export default function (this: ManualInstruction, instance: any, { dataSource, collection, filter }: {
|
|
4
|
+
dataSource?: string;
|
|
4
5
|
collection: any;
|
|
5
6
|
filter?: {};
|
|
6
7
|
}, processor: Processor): Promise<void>;
|
|
@@ -20,8 +20,8 @@ __export(update_exports, {
|
|
|
20
20
|
default: () => update_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(update_exports);
|
|
23
|
-
async function update_default(instance, { collection, filter = {} }, processor) {
|
|
24
|
-
const repo = this.workflow.
|
|
23
|
+
async function update_default(instance, { dataSource = "main", collection, filter = {} }, processor) {
|
|
24
|
+
const repo = this.workflow.app.dataSourceManager.dataSources.get(dataSource).collectionManager.getRepository(collection);
|
|
25
25
|
if (!repo) {
|
|
26
26
|
throw new Error(`collection ${collection} for update data on manual node not found`);
|
|
27
27
|
}
|
|
@@ -35,7 +35,7 @@ async function update_default(instance, { collection, filter = {} }, processor)
|
|
|
35
35
|
},
|
|
36
36
|
context: {
|
|
37
37
|
executionId: processor.execution.id
|
|
38
|
-
}
|
|
39
|
-
|
|
38
|
+
},
|
|
39
|
+
transaction: processor.transaction
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var fix_schema_exports = {};
|
|
19
|
+
__export(fix_schema_exports, {
|
|
20
|
+
default: () => fix_schema_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(fix_schema_exports);
|
|
23
|
+
var import_server = require("@nocobase/server");
|
|
24
|
+
function findSchema(root, filter, onlyLeaf = false) {
|
|
25
|
+
const result = [];
|
|
26
|
+
if (!root) {
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
if (filter(root) && (!onlyLeaf || !root.properties)) {
|
|
30
|
+
result.push(root);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
if (root.properties) {
|
|
34
|
+
Object.keys(root.properties).forEach((key) => {
|
|
35
|
+
result.push(...findSchema(root.properties[key], filter));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
function changeToDataPath(item) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (item && ((_a = item["x-decorator-props"]) == null ? void 0 : _a.dataSource)) {
|
|
43
|
+
item["x-decorator-props"].dataPath = item["x-decorator-props"].dataSource.replace(/^{{|}}$/g, "");
|
|
44
|
+
delete item["x-decorator-props"].dataSource;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function migrateSchema(schema) {
|
|
48
|
+
const root = { properties: schema };
|
|
49
|
+
const detailNodes = findSchema(root, (item) => {
|
|
50
|
+
return item["x-decorator"] === "DetailsBlockProvider" && item["x-component"] === "CardItem" && item["x-designer"] === "SimpleDesigner";
|
|
51
|
+
});
|
|
52
|
+
detailNodes.forEach(changeToDataPath);
|
|
53
|
+
return schema;
|
|
54
|
+
}
|
|
55
|
+
class fix_schema_default extends import_server.Migration {
|
|
56
|
+
async up() {
|
|
57
|
+
const { db } = this.context;
|
|
58
|
+
const NodeRepo = db.getRepository("flow_nodes");
|
|
59
|
+
await db.sequelize.transaction(async (transaction) => {
|
|
60
|
+
const nodes = await NodeRepo.find({
|
|
61
|
+
filter: {
|
|
62
|
+
type: "manual"
|
|
63
|
+
},
|
|
64
|
+
transaction
|
|
65
|
+
});
|
|
66
|
+
console.log("%d nodes need to be migrated.", nodes.length);
|
|
67
|
+
await nodes.reduce(
|
|
68
|
+
(promise, node) => promise.then(() => {
|
|
69
|
+
const { assignees, forms, schema = {}, ...tabs } = node.config;
|
|
70
|
+
return node.update(
|
|
71
|
+
{
|
|
72
|
+
config: {
|
|
73
|
+
assignees,
|
|
74
|
+
forms,
|
|
75
|
+
schema: migrateSchema({ ...tabs, ...schema })
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
silent: true,
|
|
80
|
+
transaction
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}),
|
|
84
|
+
Promise.resolve()
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:人工处理节点",
|
|
5
5
|
"description": "Could be used for workflows which some of decisions are made by users.",
|
|
6
6
|
"description.zh-CN": "用于人工控制部分决策的流程。",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.21.0-alpha.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow-manual",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@nocobase/test": "0.x",
|
|
31
31
|
"@nocobase/utils": "0.x"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff",
|
|
34
34
|
"keywords": [
|
|
35
35
|
"Workflow"
|
|
36
36
|
]
|
|
@@ -24,10 +24,10 @@ import WorkflowPlugin, {
|
|
|
24
24
|
linkNodes,
|
|
25
25
|
useAvailableUpstreams,
|
|
26
26
|
useFlowContext,
|
|
27
|
+
DetailsBlockProvider,
|
|
27
28
|
} from '@nocobase/plugin-workflow/client';
|
|
28
29
|
|
|
29
30
|
import { NAMESPACE, useLang } from '../locale';
|
|
30
|
-
import { DetailsBlockProvider } from './instruction/DetailsBlockProvider';
|
|
31
31
|
import { FormBlockProvider } from './instruction/FormBlockProvider';
|
|
32
32
|
import { ManualFormType, manualFormTypes } from './instruction/SchemaConfig';
|
|
33
33
|
|