@nocobase/plugin-workflow-manual 0.18.0-alpha.9 → 0.19.0-alpha.10

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.
Files changed (41) hide show
  1. package/dist/client/index.js +4 -4
  2. package/dist/client/instruction/SchemaConfig.d.ts +3 -3
  3. package/dist/client/instruction/forms/custom.d.ts +1 -1
  4. package/dist/client/instruction/index.d.ts +6 -0
  5. package/dist/externalVersion.js +10 -8
  6. package/dist/locale/ko_KR.json +32 -0
  7. package/dist/locale/zh-CN.json +2 -1
  8. package/dist/server/ManualInstruction.js +1 -0
  9. package/dist/server/Plugin.js +3 -7
  10. package/dist/server/collections/1-users_jobs.d.ts +2 -0
  11. package/dist/server/collections/{users_jobs.js → 1-users_jobs.js} +7 -4
  12. package/dist/server/collections/2-jobs.d.ts +6 -0
  13. package/dist/server/collections/{jobs.js → 2-jobs.js} +3 -2
  14. package/dist/server/collections/3-users.d.ts +6 -0
  15. package/dist/server/collections/{users.js → 3-users.js} +3 -2
  16. package/package.json +7 -2
  17. package/src/client/WorkflowTodo.tsx +73 -41
  18. package/src/client/__e2e__/assignees.test.ts +0 -0
  19. package/src/client/__e2e__/createRecordForm.test.ts +2231 -0
  20. package/src/client/__e2e__/customFormBlocks.test.ts +1868 -0
  21. package/src/client/__e2e__/datablocks.test.ts +1195 -0
  22. package/src/client/__e2e__/updateRecordForm.test.ts +2154 -0
  23. package/src/client/__e2e__/workflowTodo.test.ts +233 -0
  24. package/src/client/index.ts +1 -2
  25. package/src/client/instruction/FormBlockInitializer.tsx +6 -2
  26. package/src/client/instruction/SchemaConfig.tsx +6 -7
  27. package/src/client/instruction/forms/create.tsx +4 -1
  28. package/src/client/instruction/forms/custom.tsx +8 -5
  29. package/src/client/instruction/forms/update.tsx +4 -1
  30. package/src/client/instruction/index.tsx +5 -2
  31. package/src/locale/ko_KR.json +32 -0
  32. package/src/locale/zh-CN.json +2 -1
  33. package/src/server/ManualInstruction.ts +1 -0
  34. package/src/server/Plugin.ts +3 -7
  35. package/src/server/__tests__/instruction.test.ts +5 -7
  36. package/src/server/collections/{users_jobs.ts → 1-users_jobs.ts} +7 -5
  37. package/src/server/collections/{jobs.ts → 2-jobs.ts} +4 -2
  38. package/src/server/collections/{users.ts → 3-users.ts} +4 -2
  39. package/dist/server/collections/jobs.d.ts +0 -19
  40. package/dist/server/collections/users.d.ts +0 -15
  41. package/dist/server/collections/users_jobs.d.ts +0 -3
@@ -1,13 +1,13 @@
1
- (function(h,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react/jsx-runtime"),require("react"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/react"),require("antd"),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","react","@formily/antd-v5","@formily/core","@formily/react","antd","react-i18next","@nocobase/utils/client","lodash","@ant-design/icons","dayjs"],e):(h=typeof globalThis!="undefined"?globalThis:h||self,e(h["@nocobase/plugin-workflow-manual"]={},h["@nocobase/client"],h["@nocobase/plugin-workflow"],h.jsxRuntime,h.react,h["@formily/antd-v5"],h["@formily/core"],h["@formily/react"],h.antd,h["react-i18next"],h["@nocobase/utils"],h.lodash,h["@ant-design/icons"],h.dayjs))})(this,function(h,e,p,s,m,U,q,b,v,j,T,G,_,se){"use strict";var We=Object.defineProperty,Re=Object.defineProperties;var eo=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var L=(h,e,p)=>e in h?We(h,e,{enumerable:!0,configurable:!0,writable:!0,value:p}):h[e]=p,y=(h,e)=>{for(var p in e||(e={}))ne.call(e,p)&&L(h,p,e[p]);if(J)for(var p of J(e))re.call(e,p)&&L(h,p,e[p]);return h},F=(h,e)=>Re(h,eo(e));var M=(h,e)=>{var p={};for(var s in h)ne.call(h,s)&&e.indexOf(s)<0&&(p[s]=h[s]);if(h!=null&&J)for(var s of J(h))e.indexOf(s)<0&&re.call(h,s)&&(p[s]=h[s]);return p};var $=(h,e,p)=>(L(h,typeof e!="symbol"?e+"":e,p),p);var E=(h,e,p)=>new Promise((s,m)=>{var U=v=>{try{b(p.next(v))}catch(j){m(j)}},q=v=>{try{b(p.throw(v))}catch(j){m(j)}},b=v=>v.done?s(v.value):Promise.resolve(v.value).then(U,q);b((p=p.apply(h,e)).next())});const C="workflow-manual";function B(o,n={}){const{t:r}=ie(n);return r(o)}function ie(o){return j.useTranslation(C,o)}function ae(o){const{execution:n,nodes:r}=p.useFlowContext(),t=m.useMemo(()=>r.reduce((c,d)=>Object.assign(c,{[d.id]:d.key}),{}),[r]),i=m.useMemo(()=>{var c;return{$context:n==null?void 0:n.context,$jobsMapByNodeKey:((c=n==null?void 0:n.jobs)!=null?c:[]).reduce((d,l)=>Object.assign(d,{[t[l.nodeId]]:l.result}),{})}},[n==null?void 0:n.context,n==null?void 0:n.jobs,t]);return m.useMemo(()=>T.parse(o)(i),[i,o])}function Q(o){const n=b.useField(),r=m.useRef(null),{getAssociationAppends:t}=e.useAssociationNames(),{appends:i,updateAssociationValues:a}=t(),c=ae(o.dataSource),d=m.useMemo(()=>q.createForm({values:c,readPretty:!0}),[c]),l={appends:i},f={loading:!1,data:{data:c}},x=e.useAPIClient().resource(o.collection),u=m.useContext(e.BlockRequestContext);return s.jsx(e.CollectionProvider,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:c,parent:!1,children:s.jsx(e.BlockRequestContext.Provider,{value:{block:"form",field:n,service:f,resource:x,__parent:u},children:s.jsx(e.FormBlockContext.Provider,{value:{params:l,form:d,field:n,service:f,updateAssociationValues:a,formBlockRef:r},children:o.children})})})})}function Y(o){var w,D,N;const n=e.useRecord(),r=b.useFieldSchema(),t=b.useField(),i=m.useRef(null),{getAssociationAppends:a}=e.useAssociationNames(),{appends:c,updateAssociationValues:d}=a(),[l]=Object.keys((w=r.toJSON().properties)!=null?w:{}),f=(D=n==null?void 0:n.result)==null?void 0:D[l],{findComponent:g}=e.useDesignable(),x=g((N=t.component)==null?void 0:N[0])||m.Fragment,u=m.useMemo(()=>q.createForm({initialValues:f}),[f]),S=m.useMemo(()=>y({appends:c},o.params),[c,o.params]),k=m.useMemo(()=>({loading:!1,data:{data:f}}),[f]),A=e.useAPIClient().resource(o.collection),O=m.useContext(e.BlockRequestContext),z=m.useMemo(()=>({params:S,form:u,field:t,service:k,updateAssociationValues:d,formBlockRef:i}),[t,u,S,k,d]);return!n.status||f?s.jsx(e.CollectionProvider,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:f,parent:!1,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",children:s.jsx(e.BlockRequestContext.Provider,{value:{block:"form",props:o,field:t,service:k,resource:A,__parent:O},children:s.jsx(e.FormBlockContext.Provider,{value:z,children:s.jsxs(x,F(y({},t.componentProps),{children:[s.jsx(e.FormV2.Templates,{style:{marginBottom:18},form:u}),s.jsx("div",{ref:i,children:s.jsx(b.RecursionField,{schema:r,onlyRenderProperties:!0})})]}))})})})})}):null}function ce(r){var t=r,{schema:o}=t,n=M(t,["schema"]);const{getTemplateSchemaByMode:i}=e.useSchemaTemplateManager(),{insert:a}=e.useSchemaInitializer(),c=e.useRecordCollectionDataSourceItems("FormItem");function d(f){return E(this,arguments,function*({item:l}){const g=l.template?yield i(l):null,x=e.createFormBlockSchema(F(y({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${C}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:p.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},o),{template:g}));delete x["x-acl-action-props"],delete x["x-acl-action"];const[u]=Object.keys(x.properties);x.properties[u].properties.actions["x-decorator"]="ActionBarProvider",x.properties[u].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},p.traverseSchema(x,S=>{S["x-uid"]&&delete S["x-uid"]}),a(x)})}return s.jsx(e.SchemaInitializerItem,F(y({},n),{onClick:d,items:c}))}function H(){var n;const o=e.useSchemaInitializerItem();return s.jsx(e.CollectionProvider,{collection:(n=o.schema)==null?void 0:n.collection,children:s.jsx(ce,y({},o))})}function P(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(...P(o.properties[i],n))}),t):t}function le(){const{name:o,title:n}=e.useCollection();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 pe={title:`{{t("Create record form", { ns: "${C}" })}}`,config:{useInitializer({collections:o}){const n=m.useMemo(()=>o.map(a=>({name:G.camelCase(`createRecordForm-child-${a.name}`),type:"item",title:a.title,label:a.label,schema:{collection:a.name,title:`{{t("Create record", { ns: "${C}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:H})),[o]),[r,t]=m.useState(!1),i=e.useMenuSearch(n,r,!0);return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${C}" })}}`,componentProps:{onOpenChange(a){t(a.length>0)}},children:i}},initializers:{},components:{CreateFormDesigner:le},parseFormOptions(o){const n={};return P(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var c;const[i]=Object.keys(t.properties),a=t.properties[i];n[i]={type:"create",title:((c=t["x-component-props"])==null?void 0:c.title)||i,actions:P(a.properties.actions,d=>d["x-component"]==="Action").map(d=>{var l,f;return{status:d["x-decorator-props"].value,values:(f=(l=d["x-action-settings"])==null?void 0:l.assignedValues)==null?void 0:f.values,key:d.name}}),collection:t["x-decorator-props"].collection}}),n}},block:{scope:{},components:{}}};function X(o){var f,g,x,u;const[n,r]=m.useState((g=(f=o.collection)==null?void 0:f.fields)!=null?g:[]),t=e.useRecord(),i=b.useField(),a=b.useFieldSchema(),[c]=Object.keys((x=a.toJSON().properties)!=null?x:{}),d=(u=t==null?void 0:t.result)==null?void 0:u[c],l=m.useMemo(()=>q.createForm({initialValues:d}),[d]);return!t.status||d?s.jsx(e.CollectionProvider,{collection:F(y({},o.collection),{fields:n}),children:s.jsx(e.RecordProvider,{record:d,parent:!1,children:s.jsx(e.FormBlockContext.Provider,{value:{form:l,field:i,setCollectionFields:r},children:o.children})})}):null}function de(){const{insert:o}=e.useSchemaInitializer(),n=e.useSchemaInitializerItem();return s.jsx(e.SchemaInitializerItem,F(y({},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: "${C}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:p.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Z={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 ue(o){const n={};return Object.keys(o).forEach(r=>{const t=o[r],{group:i="others"}=t;n[i]=n[i]||{},G.set(n,[i,r],t)}),Object.keys(Z).filter(r=>["basic","choices","datetime","media"].includes(r)).map(r=>({title:Z[r],children:Object.keys(n[r]||{}).map(t=>{const i=n[r][t];return y({value:t,title:i.title,name:t},n[r][t])}).sort((t,i)=>t.order-i.order)}))}function me(){const{interfaces:o}=e.useCollectionManager();return ue(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:xe,fieldInterface:t.name}))}))}const W=m.createContext({}),fe=o=>{const[n,r]=m.useState(null),[t,i]=m.useState(),a=me(),c=m.useContext(e.CollectionContext),{setCollectionFields:d}=m.useContext(e.FormBlockContext);return s.jsxs(W.Provider,{value:{onAddField(l){const S=G.cloneDeep(l),{properties:k}=S,I=k,{unique:f,type:g}=I,x=M(I,["unique","type"]),u=M(S,["properties"]);delete x.name["x-disabled"],r(F(y({},u),{properties:x}))},setCallback:i},children:[s.jsx(e.SchemaInitializerItems,F(y({},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:F(y({},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 E(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:f}=b.useForm(),g=[B("Field name existed in form")];return{run(){return E(this,null,function*(){var A,O,z,w;const{default:u}=n,S=T.uid();if(u.name=(A=l.name)!=null?A:S,u.uiSchema.title=(z=(O=l.uiSchema)==null?void 0:O.title)!=null?z:S,u.interface=n.name,(w=c.fields)==null?void 0:w.find(D=>D.name===u.name)){f("name").take().setFeedback({type:"error",messages:g});return}const I=T.merge(u,l);d([...c.fields,I]),t({name:u.name,type:u.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:I},"x-collection-field":`${c.name}.${u.name}`,"x-designer":"FormItem.Designer"}),i(null),r(null)})}}}}}}}})},components:{ArrayTable:U.ArrayTable}}):null})]})},he=new e.SchemaInitializer({name:"AddCustomFormField",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:fe});function xe(){const o=e.useSchemaInitializerItem(),{insert:n,setVisible:r}=e.useSchemaInitializer(),{onAddField:t,setCallback:i}=m.useContext(W),{getInterface:a}=e.useCollectionManager(),c=a(o.fieldInterface);return s.jsx(e.SchemaInitializerItem,y({onClick:()=>{i(()=>n),t(c),r(!1)}},o),o.fieldInterface)}const R={title:`{{t("Custom form", { ns: "${C}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${C}" })}}`,Component:de}},initializers:{},components:{CustomFormBlockProvider:X},parseFormOptions(o){const n={};return P(o,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var d;const[i]=Object.keys(t.properties),a=t.properties[i],c=P(a.properties.grid,l=>l["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=c.map(l=>{var f,g;return(g=(f=l["x-component-props"])==null?void 0:f.field)!=null?g:l["x-interface-options"]}),n[i]={type:"custom",title:((d=t["x-component-props"])==null?void 0:d.title)||i,actions:P(a.properties.actions,l=>l["x-component"]==="Action").map(l=>{var f,g;return{status:l["x-decorator-props"].value,values:(g=(f=l["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:g.values,key:l.name}}),collection:t["x-decorator-props"].collection}}),n}},block:{scope:{},components:{CustomFormBlockProvider:X}}};function Ce(){const{name:o,title:n}=e.useCollection(),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:C}),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: "${C}" })}}`,config:{useInitializer({collections:o}){const n=m.useMemo(()=>o.map(a=>({name:G.camelCase(`updateRecordForm-child-${a.name}`),type:"item",title:a.title,label:a.label,schema:{collection:a.name,title:`{{t("Update record", { ns: "${C}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:H})),[o]),[r,t]=m.useState(!1),i=e.useMenuSearch(n,r,!0);return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${C}" })}}`,componentProps:{onOpenChange(a){t(a.length>0)}},children:i}},initializers:{},components:{FilterDynamicComponent:p.FilterDynamicComponent,UpdateFormDesigner:Ce},parseFormOptions(o){const n={};return P(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var c;const[i]=Object.keys(t.properties),a=t.properties[i];n[i]=F(y({},t["x-decorator-props"]),{type:"update",title:((c=t["x-component-props"])==null?void 0:c.title)||i,actions:P(a.properties.actions,d=>d["x-component"]==="Action").map(d=>{var l,f;return{status:d["x-decorator-props"].value,values:(f=(l=d["x-action-settings"])==null?void 0:l.assignedValues)==null?void 0:f.values,key:d.name}})})}),n}},block:{scope:{},components:{}}},V=new T.Registry;V.register("customForm",R),V.register("createForm",pe),V.register("updateForm",ge);function ye(){const{workflow:o}=p.useFlowContext(),n=p.useTrigger();return n.useInitializers?n.useInitializers(o.config):null}const be={customForm:R.title,record:`{{t("Data record", { ns: "${C}" })}}`};function Se(){var t,i;const o=b.useFieldSchema(),n=(i=be[(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 ve=new e.SchemaInitializer({name:"AddBlockButton",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){const o=e.usePlugin(p),n=p.useNodeContext(),r=p.useAvailableUpstreams(n),t=[ye()].filter(Boolean),i=r.map(c=>{var l;const d=o.instructions.get(c.type);return(l=d==null?void 0:d.useInitializers)==null?void 0:l.call(d,c)}).filter(Boolean);return[...t,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${C}" })}}`,children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const{collections:o}=e.useCollectionManager();return Array.from(V.getValues()).map(n=>{const{useInitializer:r}=n.config;return r({collections:o})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});function Fe(){var A,O,z;const o=m.useContext(e.SchemaComponentContext),{t:n}=j.useTranslation(),r=b.useFieldSchema(),t=p.useWorkflowVariableOptions(),[i,a]=m.useState(!1),[c,d]=m.useState((z=(O=(A=r==null?void 0:r["x-action-settings"])==null?void 0:A.assignedValues)==null?void 0:O.schema)!=null?z:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[l,f]=m.useState(null),{components:g}=e.useSchemaOptionsContext();m.useEffect(()=>{f(new b.Schema({properties:{grid:c}}))},[c]);const x=m.useMemo(()=>{var D,N;const w=(N=(D=r==null?void 0:r["x-action-settings"])==null?void 0:D.assignedValues)==null?void 0:N.values;return q.createForm({initialValues:T.lodash.cloneDeep(w),values:T.lodash.cloneDeep(w)})},[r]),u=e.useFormActiveFields(),S=n("Assign field values");function k(){a(!1)}function I(){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=x.values,a(!1),setTimeout(()=>{var w;(w=o.refresh)==null||w.call(o)},300)}return s.jsxs(s.Fragment,{children:[s.jsx(e.SchemaSettingsItem,{title:S,onClick:()=>a(!0),children:S}),s.jsx(v.Modal,{width:"50%",title:S,open:i,onCancel:k,footer:s.jsxs(v.Space,{children:[s.jsx(v.Button,{onClick:k,children:n("Cancel")}),s.jsx(v.Button,{type:"primary",onClick:I,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:u==null?void 0:u.getActiveFieldsName,children:s.jsx(b.FormProvider,{form:x,children:s.jsxs(U.FormLayout,{layout:"vertical",children:[s.jsx(v.Alert,{message:B("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:F(y({},o),{refresh(){d(T.lodash.get(l.toJSON(),"properties.grid"))}}),children:s.jsx(e.SchemaComponent,{schema:l,components:g})})]})})})})})})]})}function ke(o){return s.jsxs(e.GeneralSchemaDesigner,F(y({},o),{disableInitializer:!0,children:[s.jsx(e.Action.Designer.ButtonEditor,{}),s.jsx(Fe,{}),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=M(a,["action","actionProps"]),{insert:i}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,F(y({},t),{onClick:()=>{i({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:n},"x-component":"Action","x-component-props":F(y({},r),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function ee(){const o=e.useSchemaInitializerItem(),i=o,{action:n,actionProps:r}=i,t=M(i,["action","actionProps"]);return s.jsx(e.InitializerWithSwitch,F(y({},t),{item:o,schema:{type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:n},"x-component":"Action","x-component-props":F(y({},r),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${n}`},type:"x-action"}))}const Ae=new e.SchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${C}" })}}`,Component:Ie,action:p.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${C}" })}}`,Component:ee,action:p.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${C}" })}}`,Component:ee,action:p.JOB_STATUS.PENDING}]});function we(){return{run(){}}}function Be({value:o,onChange:n}){const r=e.usePlugin(p),t=m.useContext(e.SchemaComponentContext),i=p.useNodeContext(),a=p.useAvailableUpstreams(i),c=b.useForm(),{workflow:d}=p.useFlowContext(),l={},f={};a.forEach(u=>{const S=r.instructions.get(u.type);Object.assign(l,S.initializers),Object.assign(f,S.components)});const g=m.useMemo(()=>new b.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${C}" })}}`,"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,p,s,U,q,b,S,m,j,T,G,_,se){"use strict";var Re=Object.defineProperty,eo=Object.defineProperties;var oo=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var L=(C,e,p)=>e in C?Re(C,e,{enumerable:!0,configurable:!0,writable:!0,value:p}):C[e]=p,g=(C,e)=>{for(var p in e||(e={}))ne.call(e,p)&&L(C,p,e[p]);if(J)for(var p of J(e))re.call(e,p)&&L(C,p,e[p]);return C},F=(C,e)=>eo(C,oo(e));var M=(C,e)=>{var p={};for(var s in C)ne.call(C,s)&&e.indexOf(s)<0&&(p[s]=C[s]);if(C!=null&&J)for(var s of J(C))e.indexOf(s)<0&&re.call(C,s)&&(p[s]=C[s]);return p};var $=(C,e,p)=>(L(C,typeof e!="symbol"?e+"":e,p),p);var E=(C,e,p)=>new Promise((s,U)=>{var q=m=>{try{S(p.next(m))}catch(j){U(j)}},b=m=>{try{S(p.throw(m))}catch(j){U(j)}},S=m=>m.done?s(m.value):Promise.resolve(m.value).then(q,b);S((p=p.apply(C,e)).next())});const y="workflow-manual";function B(o,n={}){const{t:r}=ie(n);return r(o)}function ie(o){return j.useTranslation(y,o)}function ae(o){const{execution:n,nodes:r}=p.useFlowContext(),t=m.useMemo(()=>r.reduce((l,f)=>Object.assign(l,{[f.id]:f.key}),{}),[r]),i=m.useMemo(()=>{var l;return{$context:n==null?void 0:n.context,$jobsMapByNodeKey:((l=n==null?void 0:n.jobs)!=null?l:[]).reduce((f,u)=>Object.assign(f,{[t[u.nodeId]]:u.result}),{})}},[n==null?void 0:n.context,n==null?void 0:n.jobs,t]);return m.useMemo(()=>T.parse(o)(i),[i,o])}function Q(o){const n=b.useField(),r=m.useRef(null),{getAssociationAppends:t}=e.useAssociationNames(),{appends:i,updateAssociationValues:a}=t(),l=ae(o.dataSource),f=m.useMemo(()=>q.createForm({values:l,readPretty:!0}),[l]),u={appends:i},h={loading:!1,data:{data:l}},c=e.useAPIClient().resource(o.collection),d=m.useContext(e.BlockRequestContext);return s.jsx(e.CollectionProvider,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:l,parent:!1,children:s.jsx(e.BlockRequestContext.Provider,{value:{block:"form",field:n,service:h,resource:c,__parent:d},children:s.jsx(e.FormBlockContext.Provider,{value:{params:u,form:f,field:n,service:h,updateAssociationValues:a,formBlockRef:r},children:o.children})})})})}function Y(o){var w,z,N;const n=e.useRecord(),r=b.useFieldSchema(),t=b.useField(),i=m.useRef(null),{getAssociationAppends:a}=e.useAssociationNames(),{appends:l,updateAssociationValues:f}=a(),[u]=Object.keys((w=r.toJSON().properties)!=null?w:{}),h=(z=n==null?void 0:n.result)==null?void 0:z[u],{findComponent:x}=e.useDesignable(),c=x((N=t.component)==null?void 0:N[0])||m.Fragment,d=m.useMemo(()=>q.createForm({initialValues:h}),[h]),v=m.useMemo(()=>g({appends:l},o.params),[l,o.params]),A=m.useMemo(()=>({loading:!1,data:{data:h}}),[h]),I=e.useAPIClient().resource(o.collection),O=m.useContext(e.BlockRequestContext),D=m.useMemo(()=>({params:v,form:d,field:t,service:A,updateAssociationValues:f,formBlockRef:i}),[t,d,v,A,f]);return!n.status||h?s.jsx(e.CollectionProvider,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:h,parent:!1,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",children:s.jsx(e.BlockRequestContext.Provider,{value:{block:"form",props:o,field:t,service:A,resource:I,__parent:O},children:s.jsx(e.FormBlockContext.Provider,{value:D,children:s.jsxs(c,F(g({},t.componentProps),{children:[s.jsx(e.FormV2.Templates,{style:{marginBottom:18},form:d}),s.jsx("div",{ref:i,children:s.jsx(b.RecursionField,{schema:r,onlyRenderProperties:!0})})]}))})})})})}):null}function ce(r){var t=r,{schema:o}=t,n=M(t,["schema"]);const{getTemplateSchemaByMode:i}=e.useSchemaTemplateManager(),{insert:a}=e.useSchemaInitializer(),l=e.useRecordCollectionDataSourceItems("FormItem");function f(h){return E(this,arguments,function*({item:u}){var A;const x=u.template?yield i(u):null,c=e.createFormBlockSchema(F(g({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${y}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:p.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},o),{template:x}));delete c["x-acl-action-props"],delete c["x-acl-action"];const[d]=Object.keys(c.properties),v=((A=Object.entries(c.properties[d].properties).find(([k,I])=>I["x-component"]==="ActionBar"))==null?void 0:A[0])||"actions";c.properties[d].properties[v]["x-decorator"]="ActionBarProvider",c.properties[d].properties[v]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},p.traverseSchema(c,k=>{k["x-uid"]&&delete k["x-uid"]}),a(c)})}return s.jsx(e.SchemaInitializerItem,F(g({},n),{onClick:f,items:l}))}function H(){var n;const o=e.useSchemaInitializerItem();return s.jsx(e.CollectionProvider,{collection:(n=o.schema)==null?void 0:n.collection,children:s.jsx(ce,g({},o))})}function P(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(...P(o.properties[i],n))}),t):t}function le(){const{name:o,title:n}=e.useCollection();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 pe={title:`{{t("Create record form", { ns: "${y}" })}}`,config:{useInitializer({collections:o}){const n=m.useMemo(()=>o.map(a=>({name:G.camelCase(`createRecordForm-child-${a.name}`),type:"item",title:a.title,label:a.label,schema:{collection:a.name,title:`{{t("Create record", { ns: "${y}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:H})),[o]),[r,t]=m.useState(!1),i=e.useMenuSearch(n,r,!0);return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${y}" })}}`,componentProps:{onOpenChange(a){t(a.length>0)}},children:i}},initializers:{},components:{CreateFormDesigner:le},parseFormOptions(o){const n={};return P(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var f,u;const[i]=Object.keys(t.properties),a=t.properties[i],l=((f=Object.entries(a.properties).find(([h,x])=>x["x-component"]==="ActionBar"))==null?void 0:f[0])||"actions";n[i]={type:"create",title:((u=t["x-component-props"])==null?void 0:u.title)||i,actions:P(a.properties[l],h=>h["x-component"]==="Action").map(h=>{var x,c;return{status:h["x-decorator-props"].value,values:(c=(x=h["x-action-settings"])==null?void 0:x.assignedValues)==null?void 0:c.values,key:h.name}}),collection:t["x-decorator-props"].collection}}),n}},block:{scope:{},components:{}}};function X(o){var h,x,c,d;const[n,r]=m.useState((x=(h=o.collection)==null?void 0:h.fields)!=null?x:[]),t=e.useRecord(),i=b.useField(),a=b.useFieldSchema(),[l]=Object.keys((c=a.toJSON().properties)!=null?c:{}),f=(d=t==null?void 0:t.result)==null?void 0:d[l],u=m.useMemo(()=>q.createForm({initialValues:f}),[f]);return!t.status||f?s.jsx(e.CollectionProvider,{collection:F(g({},o.collection),{fields:n}),children:s.jsx(e.RecordProvider,{record:f,parent:!1,children:s.jsx(e.FormBlockContext.Provider,{value:{form:u,field:i,setCollectionFields:r},children:o.children})})}):null}function de(){const{insert:o}=e.useSchemaInitializer(),n=e.useSchemaInitializerItem();return s.jsx(e.SchemaInitializerItem,F(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:p.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Z={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 ue(o){const n={};return Object.keys(o).forEach(r=>{const t=o[r],{group:i="others"}=t;n[i]=n[i]||{},G.set(n,[i,r],t)}),Object.keys(Z).filter(r=>["basic","choices","datetime","media"].includes(r)).map(r=>({title:Z[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 me(){const{interfaces:o}=e.useCollectionManager();return ue(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:xe,fieldInterface:t.name}))}))}const W=m.createContext({}),fe=o=>{const[n,r]=m.useState(null),[t,i]=m.useState(),a=me(),l=m.useContext(e.CollectionContext),{setCollectionFields:f}=m.useContext(e.FormBlockContext);return s.jsxs(W.Provider,{value:{onAddField(u){const v=G.cloneDeep(u),{properties:A}=v,k=A,{unique:h,type:x}=k,c=M(k,["unique","type"]),d=M(v,["properties"]);delete c.name["x-disabled"],r(F(g({},d),{properties:c}))},setCallback:i},children:[s.jsx(e.SchemaInitializerItems,F(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:F(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 u=b.useForm();return{run(){return E(this,null,function*(){i(null),r(null),u.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:u,query:h}=b.useForm(),x=[B("Field name existed in form")];return{run(){return E(this,null,function*(){var I,O,D,w;const{default:d}=n,v=T.uid();if(d.name=(I=u.name)!=null?I:v,d.uiSchema.title=(D=(O=u.uiSchema)==null?void 0:O.title)!=null?D:v,d.interface=n.name,(w=l.fields)==null?void 0:w.find(z=>z.name===d.name)){h("name").take().setFeedback({type:"error",messages:x});return}const k=T.merge(d,u);f([...l.fields,k]),t({name:d.name,type:d.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:k},"x-collection-field":`${l.name}.${d.name}`,"x-designer":"FormItem.Designer"}),i(null),r(null)})}}}}}}}})},components:{ArrayTable:U.ArrayTable}}):null})]})},he=new e.SchemaInitializer({name:"AddCustomFormField",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:fe});function xe(){const o=e.useSchemaInitializerItem(),{insert:n,setVisible:r}=e.useSchemaInitializer(),{onAddField:t,setCallback:i}=m.useContext(W),{getInterface:a}=e.useCollectionManager(),l=a(o.fieldInterface);return s.jsx(e.SchemaInitializerItem,g({onClick:()=>{i(()=>n),t(l),r(!1)}},o),o.fieldInterface)}const R={title:`{{t("Custom form", { ns: "${y}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${y}" })}}`,Component:de}},initializers:{},components:{CustomFormBlockProvider:X},parseFormOptions(o){const n={};return P(o,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var u,h;const[i]=Object.keys(t.properties),a=t.properties[i],l=P(a.properties.grid,x=>x["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=l.map(x=>{var c,d;return(d=(c=x["x-component-props"])==null?void 0:c.field)!=null?d:x["x-interface-options"]});const f=((u=Object.entries(a.properties).find(([x,c])=>c["x-component"]==="ActionBar"))==null?void 0:u[0])||"actions";n[i]={type:"custom",title:((h=t["x-component-props"])==null?void 0:h.title)||i,actions:P(a.properties[f],x=>x["x-component"]==="Action").map(x=>{var c,d;return{status:x["x-decorator-props"].value,values:(d=(c=x["x-action-settings"])==null?void 0:c.assignedValues)==null?void 0:d.values,key:x.name}}),collection:t["x-decorator-props"].collection}}),n}},block:{scope:{},components:{CustomFormBlockProvider:X}}};function Ce(){const{name:o,title:n}=e.useCollection(),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 l;return{options:e.useCollectionFilterOptions((l=r==null?void 0:r["x-decorator-props"])==null?void 0:l.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 ye={title:`{{t("Update record form", { ns: "${y}" })}}`,config:{useInitializer({collections:o}){const n=m.useMemo(()=>o.map(a=>({name:G.camelCase(`updateRecordForm-child-${a.name}`),type:"item",title:a.title,label:a.label,schema:{collection:a.name,title:`{{t("Update record", { ns: "${y}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:H})),[o]),[r,t]=m.useState(!1),i=e.useMenuSearch(n,r,!0);return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${y}" })}}`,componentProps:{onOpenChange(a){t(a.length>0)}},children:i}},initializers:{},components:{FilterDynamicComponent:p.FilterDynamicComponent,UpdateFormDesigner:Ce},parseFormOptions(o){const n={};return P(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var f,u;const[i]=Object.keys(t.properties),a=t.properties[i],l=((f=Object.entries(a.properties).find(([h,x])=>x["x-component"]==="ActionBar"))==null?void 0:f[0])||"actions";n[i]=F(g({},t["x-decorator-props"]),{type:"update",title:((u=t["x-component-props"])==null?void 0:u.title)||i,actions:P(a.properties[l],h=>h["x-component"]==="Action").map(h=>{var x,c;return{status:h["x-decorator-props"].value,values:(c=(x=h["x-action-settings"])==null?void 0:x.assignedValues)==null?void 0:c.values,key:h.name}})})}),n}},block:{scope:{},components:{}}},V=new T.Registry;V.register("customForm",R),V.register("createForm",pe),V.register("updateForm",ye);function ge(){const{workflow:o}=p.useFlowContext(),n=p.useTrigger();return n.useInitializers?n.useInitializers(o.config):null}const be={customForm:R.title,record:`{{t("Data record", { ns: "${y}" })}}`};function Se(){var t,i;const o=b.useFieldSchema(),n=(i=be[(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 ve=new e.SchemaInitializer({name:"AddBlockButton",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',checkChildrenLength:!0,useChildren(){const o=e.usePlugin(p),n=p.useNodeContext(),r=p.useAvailableUpstreams(n),t=[ge()].filter(Boolean),i=r.map(l=>{var u;const f=o.instructions.get(l.type);return(u=f==null?void 0:f.useInitializers)==null?void 0:u.call(f,l)}).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{collections:o}=e.useCollectionManager();return Array.from(V.getValues()).map(n=>{const{useInitializer:r}=n.config;return r({collections:o})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]});function Fe(){var I,O,D;const o=m.useContext(e.SchemaComponentContext),{t:n}=j.useTranslation(),r=b.useFieldSchema(),t=p.useWorkflowVariableOptions(),[i,a]=m.useState(!1),[l,f]=m.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:{}}),[u,h]=m.useState(null),{components:x}=e.useSchemaOptionsContext();m.useEffect(()=>{h(new b.Schema({properties:{grid:l}}))},[l]);const c=m.useMemo(()=>{var z,N;const w=(N=(z=r==null?void 0:r["x-action-settings"])==null?void 0:z.assignedValues)==null?void 0:N.values;return q.createForm({initialValues:T.lodash.cloneDeep(w),values:T.lodash.cloneDeep(w)})},[r]),d=e.useFormActiveFields(),v=n("Assign field values");function A(){a(!1)}function k(){r["x-action-settings"]||(r["x-action-settings"]={}),r["x-action-settings"].assignedValues||(r["x-action-settings"].assignedValues={}),r["x-action-settings"].assignedValues.schema=l,r["x-action-settings"].assignedValues.values=c.values,a(!1),setTimeout(()=>{var w;(w=o.refresh)==null||w.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:k,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:d==null?void 0:d.getActiveFieldsName,children:s.jsx(b.FormProvider,{form:c,children:s.jsxs(U.FormLayout,{layout:"vertical",children:[s.jsx(S.Alert,{message:B("Values preset in this form will override user submitted ones when continue or reject.")}),s.jsx("br",{}),i&&u&&s.jsx(e.SchemaComponentContext.Provider,{value:F(g({},o),{refresh(){f(T.lodash.get(u.toJSON(),"properties.grid"))}}),children:s.jsx(e.SchemaComponent,{schema:u,components:x})})]})})})})})})]})}function ke(o){return s.jsxs(e.GeneralSchemaDesigner,F(g({},o),{disableInitializer:!0,children:[s.jsx(e.Action.Designer.ButtonEditor,{}),s.jsx(Fe,{}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function Ae(){const a=e.useSchemaInitializerItem(),{action:n,actionProps:r}=a,t=M(a,["action","actionProps"]),{insert:i}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,F(g({},t),{onClick:()=>{i({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:n},"x-component":"Action","x-component-props":F(g({},r),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function ee(){const o=e.useSchemaInitializerItem(),i=o,{action:n,actionProps:r}=i,t=M(i,["action","actionProps"]);return s.jsx(e.InitializerWithSwitch,F(g({},t),{item:o,schema:{type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:n},"x-component":"Action","x-component-props":F(g({},r),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${n}`},type:"x-action"}))}const Ie=new e.SchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${y}" })}}`,Component:Ae,action:p.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${y}" })}}`,Component:ee,action:p.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${y}" })}}`,Component:ee,action:p.JOB_STATUS.PENDING}]});function we(){return{run(){}}}function Be({value:o,onChange:n}){const r=e.usePlugin(p),t=m.useContext(e.SchemaComponentContext),i=p.useNodeContext(),a=p.useAvailableUpstreams(i),l=b.useForm(),{workflow:f}=p.useFlowContext(),u={};a.forEach(c=>{const d=r.instructions.get(c.type);Object.assign(u,d.components)});const h=m.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`
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:"AddBlockButton"},properties:o!=null?o:{tab1:{type:"void",title:`{{t("Manual", { ns: "${C}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]),x=m.useCallback(function(){const{tabs:S}=T.lodash.get(g.toJSON(),"properties.drawer.properties"),k=Array.from(V.getValues()).reduce((I,A)=>Object.assign(I,A.config.parseFormOptions(S)),{});c.setValuesIn("forms",k),n(S.properties)},[c,n,g]);return s.jsx(e.SchemaComponentContext.Provider,{value:F(y({},t),{designable:!d.executed,refresh:x}),children:s.jsx(e.SchemaComponent,{schema:g,components:F(y(y({},f),Array.from(V.getValues()).reduce((u,S)=>Object.assign(u,S.config.components),{})),{FormBlockProvider:Y,DetailsBlockProvider:Q,ManualActionStatusProvider(u){return u.children},ActionBarProvider(u){return u.children},SimpleDesigner:Se,ManualActionDesigner:ke}),scope:{useSubmit:we,useDetailsBlockProps:e.useFormBlockContext}})})}function Te(o){const{workflow:n}=p.useFlowContext(),[r,t]=m.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(v.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:B(n.executed?"View user interface":"Configure user interface")}),s.jsx(e.ActionContextProvider,{value:{visible:r,setVisible:t,formValueChanged:!1},children:o.children})]})}function Oe({value:o,onChange:n}){const r=s.jsx("fieldset",{children:s.jsx(U.FormLayout,{layout:"vertical",children:s.jsx(e.FormItem,{label:B("Negotiation"),children:s.jsxs(v.Radio.Group,{value:o,onChange:n,children:[s.jsx(v.Radio,{value:1,children:s.jsxs(v.Tooltip,{title:B("Everyone should pass"),placement:"bottom",children:[s.jsx("span",{children:B("All pass")}),s.jsx(_.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(v.Radio,{value:-1,children:s.jsxs(v.Tooltip,{title:B("Anyone pass"),placement:"bottom",children:[s.jsx("span",{children:B("Any pass")}),s.jsx(_.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return s.jsxs("fieldset",{className:e.css`
5
+ `},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:o!=null?o:{tab1:{type:"void",title:`{{t("Manual", { ns: "${y}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]),x=m.useCallback(function(){const{tabs:d}=T.lodash.get(h.toJSON(),"properties.drawer.properties"),v=Array.from(V.getValues()).reduce((A,k)=>Object.assign(A,k.config.parseFormOptions(d)),{});l.setValuesIn("forms",v),n(d.properties)},[l,n,h]);return s.jsx(e.SchemaComponentContext.Provider,{value:F(g({},t),{designable:!f.executed,refresh:x}),children:s.jsx(e.SchemaComponent,{schema:h,components:F(g(g({},u),Array.from(V.getValues()).reduce((c,d)=>Object.assign(c,d.config.components),{})),{FormBlockProvider:Y,DetailsBlockProvider:Q,ManualActionStatusProvider(c){return c.children},ActionBarProvider(c){return c.children},SimpleDesigner:Se,ManualActionDesigner:ke}),scope:{useSubmit:we,useDetailsBlockProps:e.useFormBlockContext}})})}function Te(o){const{workflow:n}=p.useFlowContext(),[r,t]=m.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(S.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:B(n.executed?"View user interface":"Configure user interface")}),s.jsx(e.ActionContextProvider,{value:{visible:r,setVisible:t,formValueChanged:!1},children:o.children})]})}function Oe({value:o,onChange:n}){const r=s.jsx("fieldset",{children:s.jsx(U.FormLayout,{layout:"vertical",children:s.jsx(e.FormItem,{label:B("Negotiation"),children:s.jsxs(S.Radio.Group,{value:o,onChange:n,children:[s.jsx(S.Radio,{value:1,children:s.jsxs(S.Tooltip,{title:B("Everyone should pass"),placement:"bottom",children:[s.jsx("span",{children:B("All pass")}),s.jsx(_.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:-1,children:s.jsxs(S.Tooltip,{title:B("Anyone pass"),placement:"bottom",children:[s.jsx("span",{children:B("Any pass")}),s.jsx(_.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(v.Form.Item,{children:s.jsxs(v.Radio.Group,{value:!!o,onChange:({target:{value:t}})=>{console.log(t),n(Number(t))},children:[s.jsx(v.Radio,{value:!0,children:s.jsxs(v.Tooltip,{title:B("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:B("Separately")}),s.jsx(_.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(v.Radio,{value:!1,children:s.jsxs(v.Tooltip,{title:B("Everyone shares one task"),placement:"bottom",children:[s.jsx("span",{children:B("Collaboratively")}),s.jsx(_.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),o?r:null]})}function ze(o){return o.isForeignKey?o.target==="users":o.collectionName==="users"&&o.name==="id"}function De({multiple:o=!1,value:n=[],onChange:r}){const t=p.useWorkflowVariableOptions({types:[ze]});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 Me extends p.Instruction{constructor(){super(...arguments);$(this,"title",`{{t("Manual", { ns: "${C}" })}}`);$(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: "${C}" })}}`);$(this,"fieldset",{assignees:{type:"array",title:`{{t("Assignees", { ns: "${C}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${C}" })}}`,"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: "${C}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}});$(this,"components",{SchemaConfigButton:Te,SchemaConfig:Be,ModeConfig:Oe,AssigneesSelect:De})}useVariables({key:r,title:t,config:i},{types:a,fieldNames:c=p.defaultFieldNames}){var x;const d=e.useCompile(),{getCollectionFields:l}=e.useCollectionManager(),f=Object.keys((x=i.forms)!=null?x:{});if(!f.length)return null;const g=f.map(u=>{var A;const S=i.forms[u],k=p.getCollectionFieldOptions({fields:(A=S.collection)==null?void 0:A.fields,collection:S.collection,types:a,compile:d,getCollectionFields:l}),I=d(S.title)||u;return k.length?{key:u,value:u,label:I,title:I,children:k}:null}).filter(Boolean);return g.length?{[c.value]:r,[c.label]:t,[c.children]:g}:null}useInitializers(r){var c;const{getCollection:t}=e.useCollectionManager(),i=Object.keys((c=r.config.forms)!=null?c:{});if(!i.length||r.config.mode)return null;const a=i.map(d=>{var g,x;const l=r.config.forms[d],{fields:f=[]}=t(l.collection);return f.length?{name:(g=l.title)!=null?g:d,type:"item",title:(x=l.title)!=null?x:d,Component:p.CollectionBlockInitializer,collection:l.collection,dataSource:`{{$jobsMapByNodeKey.${r.key}.${d}}}`}:null}).filter(Boolean);return a.length?{name:`#${r.id}`,key:"forms",type:"subMenu",title:r.title,children:a}:null}}const Pe={title:`{{t("Task", { ns: "${C}" })}}`,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"}}]},Ve={title:`{{t("Workflow", { ns: "${C}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},je={title:`{{t("Workflow todos", { ns: "${C}" })}}`,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: "${C}" })}}`,"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: "${C}" })}}`,"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: "${C}" })}}`,"x-component":"Select",enum:p.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Ne=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"}),K=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:Ne,WorkflowColumn:$e,UserColumn:Ee},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-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${C}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${C}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${C}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function qe(o){var f;const{data:n}=e.useCurrentUserContext(),{userJob:r}=p.useFlowContext(),{status:t,result:i,userId:a}=r,c=b.useFieldSchema(),{name:d}=c.parent.toJSON();let{children:l}=o;return t?i[d]||(l=null):((f=n==null?void 0:n.data)==null?void 0:f.id)!==a&&(l=null),l}const Ue=m.createContext(null);function _e({value:o,children:n}){const{userJob:r}=p.useFlowContext(),t=b.useField(),i=b.useFieldSchema();return m.useEffect(()=>{r.status&&(t.disabled=!0,t.visible=r.status===o&&r.result._===i.name)},[r,o,t,i.name]),s.jsx(Ue.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}=p.useFlowContext(),{name:d}=i,{name:l}=i.parent.parent;return{run(){return E(this,null,function*(){c.status||(yield t(),yield o.resource("users_jobs").submit({filterByTk:c.id,values:{result:{[l]:r,_:d}}}),n(!1),a.refresh())})}}}function Je(o){var g;const n=e.usePlugin(p),r=e.useAPIClient(),{id:t}=e.useRecord(),[i,a]=m.useState(null),[c,d]=m.useState(null);m.useEffect(()=>{var x,u;t&&((u=(x=r.resource("users_jobs")).get)==null||u.call(x,{filterByTk:t,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:S})=>{var w;const D=(w=S==null?void 0:S.data)!=null?w:{},{node:k,workflow:N={}}=D,oe=N,{nodes:I=[]}=oe,A=M(oe,["nodes"]),te=D,{execution:O}=te,z=M(te,["node","workflow","execution"]);p.linkNodes(I),d(k),a({userJob:z,workflow:A,nodes:I,execution:O})}))},[r,t]);const f=p.useAvailableUpstreams(i==null?void 0:i.nodes.find(x=>x.id===c.id)).reduce((x,{type:u})=>Object.assign(x,n.instructions.get(u).components),{});return c&&i?s.jsx(p.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:y(y({FormBlockProvider:Y,DetailsBlockProvider:Q,ActionBarProvider:qe,ManualActionStatusProvider:_e},Array.from(V.getValues()).reduce((x,u)=>Object.assign(x,u.block.components),{})),f),scope:y({useSubmit:Ge,useFormBlockProps:Ke,useDetailsBlockProps:Le},Array.from(V.getValues()).reduce((x,u)=>Object.assign(x,u.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(g=c.config)==null?void 0:g.schema}})}):s.jsx(v.Spin,{})}function Ke(){var a;const{userJob:o}=p.useFlowContext(),n=e.useRecord(),{data:r}=e.useCurrentUserContext(),{form:t}=e.useFormBlockContext(),i=o.status?n?"readPretty":"disabled":((a=r==null?void 0:r.data)==null?void 0:a.id)!==o.userId?"disabled":"editable";return m.useEffect(()=>{t==null||t.setPattern(i)},[i,t]),{form:t}}function Le(){const{form:o}=e.useFormBlockContext();return{form:o}}function Qe(){const o=e.useCompile(),{status:n,updatedAt:r}=e.useRecord(),t=p.JobStatusOptionsMap[n];return n?s.jsxs(v.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),n(Number(t))},children:[s.jsx(S.Radio,{value:!0,children:s.jsxs(S.Tooltip,{title:B("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:B("Separately")}),s.jsx(_.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:!1,children:s.jsxs(S.Tooltip,{title:B("Everyone shares one task"),placement:"bottom",children:[s.jsx("span",{children:B("Collaboratively")}),s.jsx(_.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),o?r:null]})}function De(o){return o.isForeignKey?o.target==="users":o.collectionName==="users"&&o.name==="id"}function ze({multiple:o=!1,value:n=[],onChange:r}){const t=p.useWorkflowVariableOptions({types:[De]});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 Me extends p.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:Te,SchemaConfig:Be,ModeConfig:Oe,AssigneesSelect:ze})}useVariables({key:r,title:t,config:i},{types:a,fieldNames:l=p.defaultFieldNames}){var c;const f=e.useCompile(),{getCollectionFields:u}=e.useCollectionManager(),h=Object.keys((c=i.forms)!=null?c:{});if(!h.length)return null;const x=h.map(d=>{var I;const v=i.forms[d],A=p.getCollectionFieldOptions({fields:(I=v.collection)==null?void 0:I.fields,collection:v.collection,types:a,compile:f,getCollectionFields:u}),k=f(v.title)||d;return A.length?{key:d,value:d,label:k,title:k,children:A}:null}).filter(Boolean);return x.length?{[l.value]:r,[l.label]:t,[l.children]:x}:null}useInitializers(r){var l;const{getCollection:t}=e.useCollectionManager(),i=Object.keys((l=r.config.forms)!=null?l:{});if(!i.length||r.config.mode)return null;const a=i.map(f=>{var x,c;const u=r.config.forms[f],{fields:h=[]}=t(u.collection);return h.length?{name:(x=u.title)!=null?x:f,type:"item",title:(c=u.title)!=null?c:f,Component:p.CollectionBlockInitializer,collection:u.collection,dataSource:`{{$jobsMapByNodeKey.${r.key}.${f}}}`}: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 Pe={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"}}]},Ve={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}}]},je={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:p.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Ne=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=B("Unprocessed");return n.execution.status&&!n.status?s.jsx(S.Tag,{children:r}):o.children}const K=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:Ne,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-designer":"Action.Designer","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 qe(o){var h;const{data:n}=e.useCurrentUserContext(),{userJob:r}=p.useFlowContext(),{status:t,result:i,userId:a}=r,l=b.useFieldSchema(),{name:f}=l.parent.toJSON();let{children:u}=o;return t?i[f]||(u=null):((h=n==null?void 0:n.data)==null?void 0:h.id)!==a&&(u=null),u}const _e=m.createContext(null);function Ge({value:o,children:n}){const{userJob:r,execution:t}=p.useFlowContext(),i=b.useField(),a=b.useFieldSchema();return m.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(_e.Provider,{value:o,children:n})}function Je(){const o=e.useAPIClient(),{setVisible:n}=e.useActionContext(),{values:r,submit:t}=b.useForm(),i=b.useFieldSchema(),{service:a}=e.useTableBlockContext(),{userJob:l,execution:f}=p.useFlowContext(),{name:u}=i,{name:h}=i.parent.parent;return{run(){return E(this,null,function*(){f.status||l.status||(yield t(),yield o.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[h]:r,_:u}}}),n(!1),a.refresh())})}}}function Ke(o){var x;const n=e.usePlugin(p),r=e.useAPIClient(),{id:t}=e.useRecord(),[i,a]=m.useState(null),[l,f]=m.useState(null);m.useEffect(()=>{var c,d;t&&((d=(c=r.resource("users_jobs")).get)==null||d.call(c,{filterByTk:t,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:v})=>{var w;const z=(w=v==null?void 0:v.data)!=null?w:{},{node:A,workflow:N={}}=z,oe=N,{nodes:k=[]}=oe,I=M(oe,["nodes"]),te=z,{execution:O}=te,D=M(te,["node","workflow","execution"]);p.linkNodes(k),f(A),a({userJob:D,workflow:I,nodes:k,execution:O})}))},[r,t]);const h=p.useAvailableUpstreams(i==null?void 0:i.nodes.find(c=>c.id===l.id)).reduce((c,{type:d})=>Object.assign(c,n.instructions.get(d).components),{});return l&&i?s.jsx(p.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:g(g({FormBlockProvider:Y,DetailsBlockProvider:Q,ActionBarProvider:qe,ManualActionStatusProvider:Ge},Array.from(V.getValues()).reduce((c,d)=>Object.assign(c,d.block.components),{})),h),scope:g({useSubmit:Je,useFormBlockProps:Le,useDetailsBlockProps:Qe},Array.from(V.getValues()).reduce((c,d)=>Object.assign(c,d.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(x=l.config)==null?void 0:x.schema}})}):s.jsx(S.Spin,{})}function Le(){var l;const{userJob:o,execution:n}=p.useFlowContext(),r=e.useRecord(),{data:t}=e.useCurrentUserContext(),{form:i}=e.useFormBlockContext(),a=n.status||o.status?r?"readPretty":"disabled":((l=t==null?void 0:t.data)==null?void 0:l.id)!==o.userId?"disabled":"editable";return m.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Qe(){const{form:o}=e.useFormBlockContext();return{form:o}}function Ye(){const o=e.useCompile(),{status:n,updatedAt:r}=e.useRecord(),t=p.JobStatusOptionsMap[n];return n?s.jsxs(S.Space,{children:[s.jsx("time",{className:e.css`
12
12
  margin-right: 0.5em;
13
- `,children:se(r).format("YYYY-MM-DD HH:mm:ss")}),s.jsx(v.Tag,{icon:t.icon,color:t.color,children:o(t.label)})]}):null}function Ye(){var a;const o=m.useContext(e.SchemaComponentContext),{id:n,node:r,workflow:t,status:i}=e.useRecord();return s.jsx(e.SchemaComponentContext.Provider,{value:F(y({},o),{reset(){},designable:!1}),children:s.jsx(e.SchemaComponent,{components:{FooterStatus:Qe,FlowContextProvider:Je},schema:{type:"void",name:`drawer-${n}-${i}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${t.title} - ${(a=r.title)!=null?a:`#${r.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function He({params:o={},children:n}){const a=e.useCollectionManager(),{collections:r}=a,t=M(a,["collections"]),i={collection:"users_jobs",resource:"users_jobs",action:"list",params:F(y({pageSize:20,sort:["-createdAt"]},o),{appends:["user","node","workflow"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return s.jsx(e.CollectionManagerProvider,F(y({},t),{collections:[...r,Pe,Ve,je],children:s.jsx(e.TableBlockProvider,F(y({name:"workflow-todo"},i),{children:n}))}))}K.Drawer=Ye,K.Decorator=He;const Xe=()=>{const o=e.useSchemaInitializerItem(),{insert:n}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,F(y({icon:s.jsx(_.TableOutlined,{})},o),{onClick:()=>{n({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class Ze extends e.Plugin{afterAdd(){return E(this,null,function*(){})}load(){return E(this,null,function*(){this.addComponents();const n=this.app.pm.get("workflow"),r=new Me;n.instructions.register(r.type,r),this.app.schemaInitializerManager.add(ve),this.app.schemaInitializerManager.add(Ae),this.app.schemaInitializerManager.add(he),this.app.schemaInitializerManager.get("BlockInitializers").add("otherBlocks.workflowTodos",{title:`{{t("Workflow todos", { ns: "${C}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"})})}addComponents(){this.app.addComponents({WorkflowTodo:K,WorkflowTodoBlockInitializer:Xe})}}h.default=Ze,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
13
+ `,children:se(r).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=m.useContext(e.SchemaComponentContext),{id:n,node:r,workflow:t,status:i}=e.useRecord();return s.jsx(e.SchemaComponentContext.Provider,{value:F(g({},o),{reset(){},designable:!1}),children:s.jsx(e.SchemaComponent,{components:{FooterStatus:Ye,FlowContextProvider:Ke},schema:{type:"void",name:`drawer-${n}-${i}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${t.title} - ${(a=r.title)!=null?a:`#${r.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:n}){const a=e.useCollectionManager(),{collections:r}=a,t=M(a,["collections"]),i={collection:"users_jobs",resource:"users_jobs",action:"list",params:F(g({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.CollectionManagerProvider,F(g({},t),{collections:[...r,Pe,Ve,je],children:s.jsx(e.TableBlockProvider,F(g({name:"workflow-todo"},i),{children:n}))}))}K.Drawer=He,K.Decorator=Xe;const Ze=()=>{const o=e.useSchemaInitializerItem(),{insert:n}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,F(g({icon:s.jsx(_.TableOutlined,{})},o),{onClick:()=>{n({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class We extends e.Plugin{afterAdd(){return E(this,null,function*(){})}load(){return E(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",Me),this.app.schemaInitializerManager.add(ve),this.app.schemaInitializerManager.add(Ie),this.app.schemaInitializerManager.add(he),this.app.schemaInitializerManager.get("BlockInitializers").add("otherBlocks.workflowTodos",{title:`{{t("Workflow todos", { ns: "${y}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"})})}addComponents(){this.app.addComponents({WorkflowTodo:K,WorkflowTodoBlockInitializer:Ze})}}C.default=We,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import { ISchema } from '@formily/react';
2
+ import React from 'react';
3
3
  import { SchemaInitializer, SchemaInitializerItemType } from '@nocobase/client';
4
4
  import { JOB_STATUS } from '@nocobase/plugin-workflow/client';
5
5
  type ValueOf<T> = T[keyof T];
@@ -39,8 +39,8 @@ export type ManualFormType = {
39
39
  };
40
40
  };
41
41
  export declare const manualFormTypes: any;
42
- export declare const addBlockButton: SchemaInitializer<import("antd").ButtonProps, {}>;
43
- export declare const addActionButton: SchemaInitializer<import("antd").ButtonProps, {}>;
42
+ export declare const addBlockButton: SchemaInitializer;
43
+ export declare const addActionButton: SchemaInitializer;
44
44
  export declare function SchemaConfig({ value, onChange }: {
45
45
  value: any;
46
46
  onChange: any;
@@ -1,5 +1,5 @@
1
1
  import { SchemaInitializer } from '@nocobase/client';
2
2
  import { ManualFormType } from '../SchemaConfig';
3
- export declare const addCustomFormField: SchemaInitializer<import("antd").ButtonProps, any>;
3
+ export declare const addCustomFormField: SchemaInitializer;
4
4
  declare const _default: ManualFormType;
5
5
  export default _default;
@@ -80,4 +80,10 @@ export default class extends Instruction {
80
80
  }[];
81
81
  };
82
82
  useInitializers(node: any): SchemaInitializerItemType | null;
83
+ isAvailable({ engine, workflow, upstream, branchIndex }: {
84
+ engine: any;
85
+ workflow: any;
86
+ upstream: any;
87
+ branchIndex: any;
88
+ }): boolean;
83
89
  }
@@ -1,18 +1,20 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
3
  "@formily/react": "2.3.0",
4
- "antd": "5.12.2",
4
+ "antd": "5.12.8",
5
5
  "dayjs": "1.11.10",
6
- "@nocobase/client": "0.18.0-alpha.9",
7
- "@nocobase/plugin-workflow": "0.18.0-alpha.9",
6
+ "@nocobase/client": "0.19.0-alpha.10",
7
+ "@nocobase/plugin-workflow": "0.19.0-alpha.10",
8
8
  "@ant-design/icons": "5.2.6",
9
9
  "react-i18next": "11.18.6",
10
- "@nocobase/utils": "0.18.0-alpha.9",
11
- "@nocobase/server": "0.18.0-alpha.9",
12
- "@nocobase/actions": "0.18.0-alpha.9",
13
- "@nocobase/resourcer": "0.18.0-alpha.9",
10
+ "@nocobase/utils": "0.19.0-alpha.10",
11
+ "@nocobase/server": "0.19.0-alpha.10",
12
+ "@nocobase/actions": "0.19.0-alpha.10",
13
+ "@nocobase/resourcer": "0.19.0-alpha.10",
14
+ "@nocobase/plugin-workflow-test": "0.19.0-alpha.10",
15
+ "@nocobase/test": "0.19.0-alpha.10",
14
16
  "@formily/core": "2.3.0",
15
17
  "@formily/antd-v5": "1.1.9",
16
- "@nocobase/database": "0.18.0-alpha.9",
18
+ "@nocobase/database": "0.19.0-alpha.10",
17
19
  "lodash": "4.17.21"
18
20
  };
@@ -0,0 +1,32 @@
1
+ {
2
+ "Manual": "수동",
3
+ "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.":
4
+ "수동으로 데이터를 제출하고 계속 진행할지 종료할지를 결정하는 데 사용될 수 있습니다. 워크플로우가 수동 노드에 도달하면 지정된 사용자에 대해 할 일 항목을 생성하고 사용자가 양식을 제출한 후 처리를 계속합니다.",
5
+ "Values preset in this form will override user submitted ones when continue or reject.":
6
+ "이 양식에 사전 설정된 값은 계속 또는 거부될 때 사용자가 제출한 값이 덮어씁니다.",
7
+ "Assignee": "담당자",
8
+ "Assignees": "담당자",
9
+ "User interface": "사용자 인터페이스",
10
+ "Configure user interface": "사용자 인터페이스 구성",
11
+ "View user interface": "사용자 인터페이스 보기",
12
+ "Separately": "별도로",
13
+ "Each user has own task": "각 사용자는 고유한 작업을 갖습니다.",
14
+ "Collaboratively": "협력하여",
15
+ "Everyone shares one task": "모두가 하나의 작업을 공유합니다.",
16
+ "Negotiation": "협상",
17
+ "All pass": "모두 통과",
18
+ "Everyone should pass": "모든 사람이 통과해야 합니다.",
19
+ "Any pass": "어떤 통과",
20
+ "Anyone pass": "누구든 통과하면 됩니다.",
21
+ "Field name existed in form": "양식에 이미 존재하는 필드 이름",
22
+ "Continue the process": "프로세스 계속 진행",
23
+ "Terminate the process": "프로세스 종료",
24
+ "Save temporarily": "임시로 저장",
25
+ "Custom form": "사용자 정의 양식",
26
+ "Data record": "데이터 레코드",
27
+ "Create record form": "레코드 생성 양식",
28
+ "Update record form": "레코드 업데이트 양식",
29
+ "Filter settings": "필터 설정",
30
+ "Workflow todos": "워크플로우 할 일",
31
+ "Task node": "작업 노드"
32
+ }
@@ -26,5 +26,6 @@
26
26
  "Update record form": "更新数据表单",
27
27
  "Filter settings": "筛选设置",
28
28
  "Workflow todos": "工作流待办",
29
- "Task": "任务"
29
+ "Task node": "任务节点",
30
+ "Unprocessed": "未处理"
30
31
  }
@@ -105,6 +105,7 @@ class ManualInstruction_default extends import_plugin_workflow.Instruction {
105
105
  status: import_plugin_workflow.JOB_STATUS.PENDING,
106
106
  result: mode ? [] : null,
107
107
  nodeId: node.id,
108
+ nodeKey: node.key,
108
109
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
109
110
  });
110
111
  const UserJobModel = this.workflow.app.db.getModel("users_jobs");
@@ -33,16 +33,12 @@ module.exports = __toCommonJS(Plugin_exports);
33
33
  var import_server = require("@nocobase/server");
34
34
  var import_actions = __toESM(require("@nocobase/actions"));
35
35
  var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
36
- var import_jobs = __toESM(require("./collections/jobs"));
37
- var import_users = __toESM(require("./collections/users"));
38
- var import_users_jobs = __toESM(require("./collections/users_jobs"));
36
+ var import_path = __toESM(require("path"));
39
37
  var import_actions2 = require("./actions");
40
38
  var import_ManualInstruction = __toESM(require("./ManualInstruction"));
41
39
  class Plugin_default extends import_server.Plugin {
42
40
  async load() {
43
- this.app.db.collection(import_users_jobs.default);
44
- this.app.db.extendCollection(import_users.default);
45
- this.app.db.extendCollection(import_jobs.default);
41
+ await this.importCollections(import_path.default.resolve(__dirname, "collections"));
46
42
  this.app.resource({
47
43
  name: "users_jobs",
48
44
  actions: {
@@ -66,7 +62,7 @@ class Plugin_default extends import_server.Plugin {
66
62
  }
67
63
  });
68
64
  this.app.acl.allow("users_jobs", ["list", "get", "submit"], "loggedIn");
69
- const workflowPlugin = this.app.getPlugin(import_plugin_workflow.default);
65
+ const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
70
66
  workflowPlugin.registerInstruction("manual", import_ManualInstruction.default);
71
67
  }
72
68
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@nocobase/database").CollectionOptions;
2
+ export default _default;
@@ -20,10 +20,13 @@ __export(users_jobs_exports, {
20
20
  default: () => users_jobs_default
21
21
  });
22
22
  module.exports = __toCommonJS(users_jobs_exports);
23
- var users_jobs_default = {
24
- namespace: "workflow.executionLogs",
23
+ var import_database = require("@nocobase/database");
24
+ var users_jobs_default = (0, import_database.defineCollection)({
25
25
  name: "users_jobs",
26
- duplicator: "optional",
26
+ dumpRules: {
27
+ group: "log"
28
+ },
29
+ shared: true,
27
30
  fields: [
28
31
  {
29
32
  type: "bigInt",
@@ -67,4 +70,4 @@ var users_jobs_default = {
67
70
  name: "result"
68
71
  }
69
72
  ]
70
- };
73
+ });
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ collectionOptions: import("@nocobase/database").CollectionOptions;
3
+ mergeOptions: import("deepmerge").Options;
4
+ extend: boolean;
5
+ };
6
+ export default _default;
@@ -20,7 +20,8 @@ __export(jobs_exports, {
20
20
  default: () => jobs_default
21
21
  });
22
22
  module.exports = __toCommonJS(jobs_exports);
23
- var jobs_default = {
23
+ var import_database = require("@nocobase/database");
24
+ var jobs_default = (0, import_database.extendCollection)({
24
25
  name: "jobs",
25
26
  fields: [
26
27
  {
@@ -36,4 +37,4 @@ var jobs_default = {
36
37
  onDelete: "CASCADE"
37
38
  }
38
39
  ]
39
- };
40
+ });
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ collectionOptions: import("@nocobase/database").CollectionOptions;
3
+ mergeOptions: import("deepmerge").Options;
4
+ extend: boolean;
5
+ };
6
+ export default _default;
@@ -20,7 +20,8 @@ __export(users_exports, {
20
20
  default: () => users_default
21
21
  });
22
22
  module.exports = __toCommonJS(users_exports);
23
- var users_default = {
23
+ var import_database = require("@nocobase/database");
24
+ var users_default = (0, import_database.extendCollection)({
24
25
  name: "users",
25
26
  fields: [
26
27
  {
@@ -34,4 +35,4 @@ var users_default = {
34
35
  target: "users_jobs"
35
36
  }
36
37
  ]
37
- };
38
+ });
package/package.json CHANGED
@@ -4,9 +4,11 @@
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.18.0-alpha.9",
7
+ "version": "0.19.0-alpha.10",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
+ "homepage": "https://docs.nocobase.com/plugins/workflow-manual",
11
+ "homepage.zh-CN": "https://docs-cn.nocobase.com/plugins/workflow-manual",
10
12
  "devDependencies": {
11
13
  "@ant-design/icons": "5.x",
12
14
  "@formily/antd-v5": "1.x",
@@ -28,5 +30,8 @@
28
30
  "@nocobase/test": "0.x",
29
31
  "@nocobase/utils": "0.x"
30
32
  },
31
- "gitHead": "34ca0df4eede2e83fc86297b0fe19eba970e2b1b"
33
+ "gitHead": "d09d81eba67339da36bcec27939a85b35d180770",
34
+ "keywords": [
35
+ "Workflow"
36
+ ]
32
37
  }