@nocobase/plugin-workflow-manual 0.18.0-alpha.9 → 0.19.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 +3 -3
- package/dist/client/instruction/forms/custom.d.ts +1 -1
- package/dist/externalVersion.js +8 -8
- package/dist/locale/zh-CN.json +1 -1
- package/dist/server/Plugin.js +2 -6
- package/dist/server/collections/1-users_jobs.d.ts +2 -0
- package/dist/server/collections/{users_jobs.js → 1-users_jobs.js} +7 -4
- package/dist/server/collections/2-jobs.d.ts +6 -0
- package/dist/server/collections/{jobs.js → 2-jobs.js} +3 -2
- package/dist/server/collections/3-users.d.ts +6 -0
- package/dist/server/collections/{users.js → 3-users.js} +3 -2
- package/package.json +2 -2
- package/src/client/WorkflowTodo.tsx +44 -25
- package/src/client/instruction/SchemaConfig.tsx +6 -6
- package/src/client/instruction/forms/custom.tsx +4 -4
- package/src/locale/zh-CN.json +1 -1
- package/src/server/Plugin.ts +2 -6
- package/src/server/__tests__/instruction.test.ts +5 -7
- package/src/server/collections/{users_jobs.ts → 1-users_jobs.ts} +7 -5
- package/src/server/collections/{jobs.ts → 2-jobs.ts} +4 -2
- package/src/server/collections/{users.ts → 3-users.ts} +4 -2
- package/dist/server/collections/jobs.d.ts +0 -19
- package/dist/server/collections/users.d.ts +0 -15
- package/dist/server/collections/users_jobs.d.ts +0 -3
package/dist/client/index.js
CHANGED
|
@@ -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(h,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):(h=typeof globalThis!="undefined"?globalThis:h||self,e(h["@nocobase/plugin-workflow-manual"]={},h["@nocobase/client"],h["@nocobase/plugin-workflow"],h.jsxRuntime,h["@formily/antd-v5"],h["@formily/core"],h["@formily/react"],h.antd,h.react,h["react-i18next"],h["@nocobase/utils"],h.lodash,h["@ant-design/icons"],h.dayjs))})(this,function(h,e,p,s,q,U,S,v,u,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,q)=>{var U=u=>{try{v(p.next(u))}catch(j){q(j)}},S=u=>{try{v(p.throw(u))}catch(j){q(j)}},v=u=>u.done?s(u.value):Promise.resolve(u.value).then(U,S);v((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=u.useMemo(()=>r.reduce((c,d)=>Object.assign(c,{[d.id]:d.key}),{}),[r]),i=u.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 u.useMemo(()=>T.parse(o)(i),[i,o])}function Q(o){const n=S.useField(),r=u.useRef(null),{getAssociationAppends:t}=e.useAssociationNames(),{appends:i,updateAssociationValues:a}=t(),c=ae(o.dataSource),d=u.useMemo(()=>U.createForm({values:c,readPretty:!0}),[c]),l={appends:i},f={loading:!1,data:{data:c}},x=e.useAPIClient().resource(o.collection),m=u.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:m},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 A,D,N;const n=e.useRecord(),r=S.useFieldSchema(),t=S.useField(),i=u.useRef(null),{getAssociationAppends:a}=e.useAssociationNames(),{appends:c,updateAssociationValues:d}=a(),[l]=Object.keys((A=r.toJSON().properties)!=null?A:{}),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])||u.Fragment,m=u.useMemo(()=>U.createForm({initialValues:f}),[f]),b=u.useMemo(()=>y({appends:c},o.params),[c,o.params]),k=u.useMemo(()=>({loading:!1,data:{data:f}}),[f]),w=e.useAPIClient().resource(o.collection),O=u.useContext(e.BlockRequestContext),z=u.useMemo(()=>({params:b,form:m,field:t,service:k,updateAssociationValues:d,formBlockRef:i}),[t,m,b,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:w,__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:m}),s.jsx("div",{ref:i,children:s.jsx(S.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[m]=Object.keys(x.properties);x.properties[m].properties.actions["x-decorator"]="ActionBarProvider",x.properties[m].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},p.traverseSchema(x,b=>{b["x-uid"]&&delete b["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=u.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]=u.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,m;const[n,r]=u.useState((g=(f=o.collection)==null?void 0:f.fields)!=null?g:[]),t=e.useRecord(),i=S.useField(),a=S.useFieldSchema(),[c]=Object.keys((x=a.toJSON().properties)!=null?x:{}),d=(m=t==null?void 0:t.result)==null?void 0:m[c],l=u.useMemo(()=>U.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=u.createContext({}),fe=o=>{const[n,r]=u.useState(null),[t,i]=u.useState(),a=me(),c=u.useContext(e.CollectionContext),{setCollectionFields:d}=u.useContext(e.FormBlockContext);return s.jsxs(W.Provider,{value:{onAddField(l){const b=G.cloneDeep(l),{properties:k}=b,I=k,{unique:f,type:g}=I,x=M(I,["unique","type"]),m=M(b,["properties"]);delete x.name["x-disabled"],r(F(y({},m),{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=S.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}=S.useForm(),g=[B("Field name existed in form")];return{run(){return E(this,null,function*(){var w,O,z,A;const{default:m}=n,b=T.uid();if(m.name=(w=l.name)!=null?w:b,m.uiSchema.title=(z=(O=l.uiSchema)==null?void 0:O.title)!=null?z:b,m.interface=n.name,(A=c.fields)==null?void 0:A.find(D=>D.name===m.name)){f("name").take().setFeedback({type:"error",messages:g});return}const I=T.merge(m,l);d([...c.fields,I]),t({name:m.name,type:m.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:I},"x-collection-field":`${c.name}.${m.name}`,"x-designer":"FormItem.Designer"}),i(null),r(null)})}}}}}}}})},components:{ArrayTable:q.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}=u.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=S.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=u.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]=u.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=S.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 w,O,z;const o=u.useContext(e.SchemaComponentContext),{t:n}=j.useTranslation(),r=S.useFieldSchema(),t=p.useWorkflowVariableOptions(),[i,a]=u.useState(!1),[c,d]=u.useState((z=(O=(w=r==null?void 0:r["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:O.schema)!=null?z:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[l,f]=u.useState(null),{components:g}=e.useSchemaOptionsContext();u.useEffect(()=>{f(new S.Schema({properties:{grid:c}}))},[c]);const x=u.useMemo(()=>{var D,N;const A=(N=(D=r==null?void 0:r["x-action-settings"])==null?void 0:D.assignedValues)==null?void 0:N.values;return U.createForm({initialValues:T.lodash.cloneDeep(A),values:T.lodash.cloneDeep(A)})},[r]),m=e.useFormActiveFields(),b=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 A;(A=o.refresh)==null||A.call(o)},300)}return s.jsxs(s.Fragment,{children:[s.jsx(e.SchemaSettingsItem,{title:b,onClick:()=>a(!0),children:b}),s.jsx(v.Modal,{width:"50%",title:b,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:m==null?void 0:m.getActiveFieldsName,children:s.jsx(S.FormProvider,{form:x,children:s.jsxs(q.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 we=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 Ae(){return{run(){}}}function Be({value:o,onChange:n}){const r=e.usePlugin(p),t=u.useContext(e.SchemaComponentContext),i=p.useNodeContext(),a=p.useAvailableUpstreams(i),c=S.useForm(),{workflow:d}=p.useFlowContext(),l={},f={};a.forEach(m=>{const b=r.instructions.get(m.type);Object.assign(l,b.initializers),Object.assign(f,b.components)});const g=u.useMemo(()=>new S.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${C}" })}}`,"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=
|
|
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=u.useCallback(function(){const{tabs:b}=T.lodash.get(g.toJSON(),"properties.drawer.properties"),k=Array.from(V.getValues()).reduce((I,w)=>Object.assign(I,w.config.parseFormOptions(b)),{});c.setValuesIn("forms",k),n(b.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((m,b)=>Object.assign(m,b.config.components),{})),{FormBlockProvider:Y,DetailsBlockProvider:Q,ManualActionStatusProvider(m){return m.children},ActionBarProvider(m){return m.children},SimpleDesigner:Se,ManualActionDesigner:ke}),scope:{useSubmit:Ae,useDetailsBlockProps:e.useFormBlockContext}})})}function Te(o){const{workflow:n}=p.useFlowContext(),[r,t]=u.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(q.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`
|
|
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(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(m=>{var w;const b=i.forms[m],k=p.getCollectionFieldOptions({fields:(w=b.collection)==null?void 0:w.fields,collection:b.collection,types:a,compile:d,getCollectionFields:l}),I=d(b.title)||m;return k.length?{key:m,value:m,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=S.observer(()=>{var n,r,t;const o=S.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=S.observer(()=>{var n,r,t;const o=S.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=S.observer(()=>{var n,r,t;const o=S.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:{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: "${C}" })}}`,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:{"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: "${C}" })}}`,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 f;const{data:n}=e.useCurrentUserContext(),{userJob:r}=p.useFlowContext(),{status:t,result:i,userId:a}=r,c=S.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=u.createContext(null);function _e({value:o,children:n}){const{userJob:r}=p.useFlowContext(),t=S.useField(),i=S.useFieldSchema();return u.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}=S.useForm(),i=S.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]=u.useState(null),[c,d]=u.useState(null);u.useEffect(()=>{var x,m;t&&((m=(x=r.resource("users_jobs")).get)==null||m.call(x,{filterByTk:t,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:b})=>{var A;const D=(A=b==null?void 0:b.data)!=null?A:{},{node:k,workflow:N={}}=D,oe=N,{nodes:I=[]}=oe,w=M(oe,["nodes"]),te=D,{execution:O}=te,z=M(te,["node","workflow","execution"]);p.linkNodes(I),d(k),a({userJob:z,workflow:w,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:m})=>Object.assign(x,n.instructions.get(m).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,m)=>Object.assign(x,m.block.components),{})),f),scope:y({useSubmit:Ge,useFormBlockProps:Ke,useDetailsBlockProps:Le},Array.from(V.getValues()).reduce((x,m)=>Object.assign(x,m.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 u.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`
|
|
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=
|
|
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=u.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(we),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"}})});
|
|
@@ -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
|
|
43
|
-
export declare const addActionButton: SchemaInitializer
|
|
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
|
|
3
|
+
export declare const addCustomFormField: SchemaInitializer;
|
|
4
4
|
declare const _default: ManualFormType;
|
|
5
5
|
export default _default;
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.2.0",
|
|
3
3
|
"@formily/react": "2.3.0",
|
|
4
|
-
"antd": "5.12.
|
|
4
|
+
"antd": "5.12.8",
|
|
5
5
|
"dayjs": "1.11.10",
|
|
6
|
-
"@nocobase/client": "0.
|
|
7
|
-
"@nocobase/plugin-workflow": "0.
|
|
6
|
+
"@nocobase/client": "0.19.0-alpha.1",
|
|
7
|
+
"@nocobase/plugin-workflow": "0.19.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.
|
|
10
|
+
"@nocobase/utils": "0.19.0-alpha.1",
|
|
11
|
+
"@nocobase/server": "0.19.0-alpha.1",
|
|
12
|
+
"@nocobase/actions": "0.19.0-alpha.1",
|
|
13
|
+
"@nocobase/resourcer": "0.19.0-alpha.1",
|
|
14
14
|
"@formily/core": "2.3.0",
|
|
15
15
|
"@formily/antd-v5": "1.1.9",
|
|
16
|
-
"@nocobase/database": "0.
|
|
16
|
+
"@nocobase/database": "0.19.0-alpha.1",
|
|
17
17
|
"lodash": "4.17.21"
|
|
18
18
|
};
|
package/dist/locale/zh-CN.json
CHANGED
package/dist/server/Plugin.js
CHANGED
|
@@ -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
|
|
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.
|
|
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: {
|
|
@@ -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
|
|
24
|
-
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var users_jobs_default = (0, import_database.defineCollection)({
|
|
25
25
|
name: "users_jobs",
|
|
26
|
-
|
|
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
|
+
});
|
|
@@ -20,7 +20,8 @@ __export(jobs_exports, {
|
|
|
20
20
|
default: () => jobs_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(jobs_exports);
|
|
23
|
-
var
|
|
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
|
+
});
|
|
@@ -20,7 +20,8 @@ __export(users_exports, {
|
|
|
20
20
|
default: () => users_default
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(users_exports);
|
|
23
|
-
var
|
|
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,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.19.0-alpha.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"@nocobase/test": "0.x",
|
|
29
29
|
"@nocobase/utils": "0.x"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "64601944412fc4d2e2bd05f4b982118dd28247dc"
|
|
32
32
|
}
|
|
@@ -265,11 +265,35 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
265
265
|
useProps: '{{ useTableBlockProps }}',
|
|
266
266
|
},
|
|
267
267
|
properties: {
|
|
268
|
+
actions: {
|
|
269
|
+
type: 'void',
|
|
270
|
+
'x-decorator': 'TableV2.Column.Decorator',
|
|
271
|
+
'x-component': 'TableV2.Column',
|
|
272
|
+
'x-component-props': {
|
|
273
|
+
width: 60,
|
|
274
|
+
},
|
|
275
|
+
title: '{{t("Actions")}}',
|
|
276
|
+
properties: {
|
|
277
|
+
view: {
|
|
278
|
+
type: 'void',
|
|
279
|
+
'x-component': 'Action.Link',
|
|
280
|
+
title: '{{t("View")}}',
|
|
281
|
+
properties: {
|
|
282
|
+
drawer: {
|
|
283
|
+
'x-component': 'WorkflowTodo.Drawer',
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
},
|
|
268
289
|
node: {
|
|
269
290
|
type: 'void',
|
|
270
291
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
271
292
|
'x-component': 'TableV2.Column',
|
|
272
|
-
|
|
293
|
+
'x-component-props': {
|
|
294
|
+
width: null,
|
|
295
|
+
},
|
|
296
|
+
title: `{{t("Task node", { ns: "${NAMESPACE}" })}}`,
|
|
273
297
|
properties: {
|
|
274
298
|
node: {
|
|
275
299
|
'x-component': 'NodeColumn',
|
|
@@ -281,7 +305,10 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
281
305
|
type: 'void',
|
|
282
306
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
283
307
|
'x-component': 'TableV2.Column',
|
|
284
|
-
|
|
308
|
+
'x-component-props': {
|
|
309
|
+
width: null,
|
|
310
|
+
},
|
|
311
|
+
title: `{{t("Workflow", { ns: "workflow" })}}`,
|
|
285
312
|
properties: {
|
|
286
313
|
workflow: {
|
|
287
314
|
'x-component': 'WorkflowColumn',
|
|
@@ -289,13 +316,16 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
289
316
|
},
|
|
290
317
|
},
|
|
291
318
|
},
|
|
292
|
-
|
|
319
|
+
status: {
|
|
293
320
|
type: 'void',
|
|
294
321
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
295
322
|
'x-component': 'TableV2.Column',
|
|
323
|
+
'x-component-props': {
|
|
324
|
+
width: 100,
|
|
325
|
+
},
|
|
326
|
+
title: `{{t("Status", { ns: "workflow" })}}`,
|
|
296
327
|
properties: {
|
|
297
|
-
|
|
298
|
-
type: 'string',
|
|
328
|
+
status: {
|
|
299
329
|
'x-component': 'CollectionField',
|
|
300
330
|
'x-read-pretty': true,
|
|
301
331
|
},
|
|
@@ -305,6 +335,9 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
305
335
|
type: 'void',
|
|
306
336
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
307
337
|
'x-component': 'TableV2.Column',
|
|
338
|
+
'x-component-props': {
|
|
339
|
+
width: 140,
|
|
340
|
+
},
|
|
308
341
|
title: `{{t("Assignee", { ns: "${NAMESPACE}" })}}`,
|
|
309
342
|
properties: {
|
|
310
343
|
user: {
|
|
@@ -313,35 +346,21 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
313
346
|
},
|
|
314
347
|
},
|
|
315
348
|
},
|
|
316
|
-
|
|
349
|
+
createdAt: {
|
|
317
350
|
type: 'void',
|
|
318
351
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
319
352
|
'x-component': 'TableV2.Column',
|
|
353
|
+
'x-component-props': {
|
|
354
|
+
width: 160,
|
|
355
|
+
},
|
|
320
356
|
properties: {
|
|
321
|
-
|
|
357
|
+
createdAt: {
|
|
358
|
+
type: 'string',
|
|
322
359
|
'x-component': 'CollectionField',
|
|
323
360
|
'x-read-pretty': true,
|
|
324
361
|
},
|
|
325
362
|
},
|
|
326
363
|
},
|
|
327
|
-
actions: {
|
|
328
|
-
type: 'void',
|
|
329
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
330
|
-
'x-component': 'TableV2.Column',
|
|
331
|
-
title: '{{t("Actions")}}',
|
|
332
|
-
properties: {
|
|
333
|
-
view: {
|
|
334
|
-
type: 'void',
|
|
335
|
-
'x-component': 'Action.Link',
|
|
336
|
-
title: '{{t("View")}}',
|
|
337
|
-
properties: {
|
|
338
|
-
drawer: {
|
|
339
|
-
'x-component': 'WorkflowTodo.Drawer',
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
364
|
},
|
|
346
365
|
},
|
|
347
366
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
2
1
|
import { FormLayout } from '@formily/antd-v5';
|
|
3
2
|
import { createForm } from '@formily/core';
|
|
4
3
|
import { FormProvider, ISchema, Schema, useFieldSchema, useForm } from '@formily/react';
|
|
5
4
|
import { Alert, Button, Modal, Space } from 'antd';
|
|
5
|
+
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
|
|
8
8
|
import {
|
|
@@ -33,15 +33,15 @@ import {
|
|
|
33
33
|
useSchemaInitializerItem,
|
|
34
34
|
useSchemaOptionsContext,
|
|
35
35
|
} from '@nocobase/client';
|
|
36
|
-
import { Registry, lodash } from '@nocobase/utils/client';
|
|
37
36
|
import WorkflowPlugin, {
|
|
37
|
+
JOB_STATUS,
|
|
38
38
|
useAvailableUpstreams,
|
|
39
|
-
useNodeContext,
|
|
40
39
|
useFlowContext,
|
|
41
|
-
|
|
40
|
+
useNodeContext,
|
|
42
41
|
useTrigger,
|
|
43
42
|
useWorkflowVariableOptions,
|
|
44
43
|
} from '@nocobase/plugin-workflow/client';
|
|
44
|
+
import { Registry, lodash } from '@nocobase/utils/client';
|
|
45
45
|
|
|
46
46
|
import { NAMESPACE, useLang } from '../../locale';
|
|
47
47
|
import { DetailsBlockProvider } from './DetailsBlockProvider';
|
|
@@ -122,7 +122,7 @@ function SimpleDesigner() {
|
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
export const addBlockButton = new SchemaInitializer({
|
|
125
|
+
export const addBlockButton: SchemaInitializer = new SchemaInitializer({
|
|
126
126
|
name: 'AddBlockButton',
|
|
127
127
|
wrap: gridRowColWrap,
|
|
128
128
|
title: '{{t("Add block")}}',
|
|
@@ -364,7 +364,7 @@ function ActionInitializer() {
|
|
|
364
364
|
);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
export const addActionButton = new SchemaInitializer({
|
|
367
|
+
export const addActionButton: SchemaInitializer = new SchemaInitializer({
|
|
368
368
|
name: 'AddActionButton',
|
|
369
369
|
title: '{{t("Configure actions")}}',
|
|
370
370
|
items: [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useContext, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import lodash from 'lodash';
|
|
4
3
|
import { ArrayTable } from '@formily/antd-v5';
|
|
5
4
|
import { Field, createForm } from '@formily/core';
|
|
6
5
|
import { useField, useFieldSchema, useForm } from '@formily/react';
|
|
6
|
+
import lodash from 'lodash';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
ActionContextProvider,
|
|
@@ -22,12 +22,12 @@ import {
|
|
|
22
22
|
useSchemaInitializer,
|
|
23
23
|
useSchemaInitializerItem,
|
|
24
24
|
} from '@nocobase/client';
|
|
25
|
-
import { merge, uid } from '@nocobase/utils/client';
|
|
26
25
|
import { JOB_STATUS } from '@nocobase/plugin-workflow/client';
|
|
26
|
+
import { merge, uid } from '@nocobase/utils/client';
|
|
27
27
|
|
|
28
|
+
import { NAMESPACE, useLang } from '../../../locale';
|
|
28
29
|
import { ManualFormType } from '../SchemaConfig';
|
|
29
30
|
import { findSchema } from '../utils';
|
|
30
|
-
import { NAMESPACE, useLang } from '../../../locale';
|
|
31
31
|
|
|
32
32
|
function CustomFormBlockProvider(props) {
|
|
33
33
|
const [fields, setCollectionFields] = useState(props.collection?.fields ?? []);
|
|
@@ -320,7 +320,7 @@ const CustomItemsComponent = (props) => {
|
|
|
320
320
|
);
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
-
export const addCustomFormField = new SchemaInitializer({
|
|
323
|
+
export const addCustomFormField: SchemaInitializer = new SchemaInitializer({
|
|
324
324
|
name: 'AddCustomFormField',
|
|
325
325
|
wrap: gridRowColWrap,
|
|
326
326
|
insertPosition: 'beforeEnd',
|
package/src/locale/zh-CN.json
CHANGED
package/src/server/Plugin.ts
CHANGED
|
@@ -3,18 +3,14 @@ import actions from '@nocobase/actions';
|
|
|
3
3
|
import { HandlerType } from '@nocobase/resourcer';
|
|
4
4
|
import WorkflowPlugin, { JOB_STATUS } from '@nocobase/plugin-workflow';
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import usersCollection from './collections/users';
|
|
8
|
-
import usersJobsCollection from './collections/users_jobs';
|
|
6
|
+
import path from 'path';
|
|
9
7
|
import { submit } from './actions';
|
|
10
8
|
|
|
11
9
|
import ManualInstruction from './ManualInstruction';
|
|
12
10
|
|
|
13
11
|
export default class extends Plugin {
|
|
14
12
|
async load() {
|
|
15
|
-
this.
|
|
16
|
-
this.app.db.extendCollection(usersCollection);
|
|
17
|
-
this.app.db.extendCollection(jobsCollection);
|
|
13
|
+
await this.importCollections(path.resolve(__dirname, 'collections'));
|
|
18
14
|
|
|
19
15
|
this.app.resource({
|
|
20
16
|
name: 'users_jobs',
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import Database from '@nocobase/database';
|
|
2
|
-
import { MockServer } from '@nocobase/test';
|
|
3
2
|
import { EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
|
|
4
3
|
import { getApp, sleep } from '@nocobase/plugin-workflow-test';
|
|
5
|
-
|
|
6
|
-
import Plugin from '..';
|
|
4
|
+
import { MockServer } from '@nocobase/test';
|
|
7
5
|
|
|
8
6
|
// NOTE: skipped because time is not stable on github ci, but should work in local
|
|
9
7
|
describe('workflow > instructions > manual', () => {
|
|
@@ -21,9 +19,9 @@ describe('workflow > instructions > manual', () => {
|
|
|
21
19
|
|
|
22
20
|
beforeEach(async () => {
|
|
23
21
|
app = await getApp({
|
|
24
|
-
plugins: ['users', 'auth',
|
|
22
|
+
plugins: ['users', 'auth', 'workflow-manual'],
|
|
25
23
|
});
|
|
26
|
-
await app.getPlugin('auth').install();
|
|
24
|
+
// await app.getPlugin('auth').install();
|
|
27
25
|
agent = app.agent();
|
|
28
26
|
db = app.db;
|
|
29
27
|
WorkflowModel = db.getCollection('workflows').model;
|
|
@@ -33,8 +31,8 @@ describe('workflow > instructions > manual', () => {
|
|
|
33
31
|
UserJobModel = db.getModel('users_jobs');
|
|
34
32
|
|
|
35
33
|
users = await UserModel.bulkCreate([
|
|
36
|
-
{ id:
|
|
37
|
-
{ id:
|
|
34
|
+
{ id: 2, nickname: 'a' },
|
|
35
|
+
{ id: 3, nickname: 'b' },
|
|
38
36
|
]);
|
|
39
37
|
|
|
40
38
|
userAgents = users.map((user) => app.agent().login(user));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineCollection } from '@nocobase/database';
|
|
2
2
|
|
|
3
|
-
export default {
|
|
4
|
-
namespace: 'workflow.executionLogs',
|
|
3
|
+
export default defineCollection({
|
|
5
4
|
name: 'users_jobs',
|
|
6
|
-
|
|
5
|
+
dumpRules: {
|
|
6
|
+
group: 'log',
|
|
7
|
+
},
|
|
8
|
+
shared: true,
|
|
7
9
|
fields: [
|
|
8
10
|
{
|
|
9
11
|
type: 'bigInt',
|
|
@@ -47,4 +49,4 @@ export default {
|
|
|
47
49
|
name: 'result',
|
|
48
50
|
},
|
|
49
51
|
],
|
|
50
|
-
}
|
|
52
|
+
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
name: string;
|
|
3
|
-
fields: ({
|
|
4
|
-
type: string;
|
|
5
|
-
name: string;
|
|
6
|
-
through: string;
|
|
7
|
-
target?: undefined;
|
|
8
|
-
foreignKey?: undefined;
|
|
9
|
-
onDelete?: undefined;
|
|
10
|
-
} | {
|
|
11
|
-
type: string;
|
|
12
|
-
name: string;
|
|
13
|
-
target: string;
|
|
14
|
-
foreignKey: string;
|
|
15
|
-
onDelete: string;
|
|
16
|
-
through?: undefined;
|
|
17
|
-
})[];
|
|
18
|
-
};
|
|
19
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
name: string;
|
|
3
|
-
fields: ({
|
|
4
|
-
type: string;
|
|
5
|
-
name: string;
|
|
6
|
-
through: string;
|
|
7
|
-
target?: undefined;
|
|
8
|
-
} | {
|
|
9
|
-
type: string;
|
|
10
|
-
name: string;
|
|
11
|
-
target: string;
|
|
12
|
-
through?: undefined;
|
|
13
|
-
})[];
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|