@nocobase/plugin-workflow-manual 1.2.4-alpha → 1.2.5-alpha
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 +1 -1
- package/dist/externalVersion.js +9 -9
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
margin-left: 0.5em;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
`,children:[s.jsx(b.Form.Item,{children:s.jsxs(b.Radio.Group,{value:!!o,onChange:({target:{value:t}})=>{console.log(t),r(Number(t))},children:[s.jsx(b.Radio,{value:!0,children:s.jsxs(b.Tooltip,{title:T("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:T("Separately")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(b.Radio,{value:!1,children:s.jsxs(b.Tooltip,{title:T("Everyone shares one task"),placement:"bottom",children:[s.jsx("span",{children:T("Collaboratively")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),o?n:null]})}function Ne(o){return o.isForeignKey?o.target==="users":o.collectionName==="users"&&o.name==="id"}function $e({multiple:o=!1,value:r=[],onChange:n}){const t=l.useWorkflowVariableOptions({types:[Ne]});return s.jsx(e.Variable.Input,{scope:t,value:r[0],onChange:i=>{n([i])},children:s.jsx(e.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:r[0],onChange:i=>{n(i!=null?[i]:[])}})})}function Ue({key:o,title:r,config:n},{types:t,fieldNames:i=l.defaultFieldNames}){var m;const a=e.useCompile(),{getCollectionFields:u}=e.useCollectionManager_deprecated(),d=Object.keys((m=n.forms)!=null?m:{});if(!d.length)return null;const p=d.map(f=>{var v;const c=n.forms[f],x=l.getCollectionFieldOptions({fields:(v=c.collection)==null?void 0:v.fields,collection:c.collection,types:t,compile:a,getCollectionFields:u}),F=a(c.title)||f;return x.length?{key:f,value:f,label:F,title:F,children:x}:null}).filter(Boolean);return p.length?{[i.value]:o,[i.label]:r,[i.children]:p}:null}class _e extends l.Instruction{constructor(){super(...arguments);P(this,"title",`{{t("Manual", { ns: "${y}" })}}`);P(this,"type","manual");P(this,"group","manual");P(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}" })}}`);P(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:{}}});P(this,"components",{SchemaConfigButton:Pe,SchemaConfig:De,ModeConfig:je,AssigneesSelect:$e});P(this,"useVariables",Ue)}useInitializers(n){var u;const{getCollection:t}=e.useCollectionManager_deprecated(),i=Object.keys((u=n.config.forms)!=null?u:{});if(!i.length||n.config.mode)return null;const a=i.map(d=>{var f,c;const p=n.config.forms[d],{fields:m=[]}=t(p.collection);return m.length?{name:(f=p.title)!=null?f:d,type:"item",title:(c=p.title)!=null?c:d,Component:l.CollectionBlockInitializer,collection:p.collection,dataPath:`$jobsMapByNodeKey.${n.key}.${d}`}:null}).filter(Boolean);return a.length?{name:`#${n.id}`,key:"forms",type:"subMenu",title:n.title,children:a}:null}isAvailable({engine:n,workflow:t,upstream:i,branchIndex:a}){return!n.isWorkflowSync(t)}}const Ee={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"}}]},Ke={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}}]},qe={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:l.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Je=S.observer(()=>{var r,n,t;const o=S.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),Ge=S.observer(()=>{var r,n,t;const o=S.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),Le=S.observer(()=>{var r,n,t;const o=S.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.nickname)!=null?t:(n=o.value)==null?void 0:n.id},{displayName:"UserColumn"});function Ye(o){const r=e.useRecord(),n=T("Unprocessed");return r.execution.status&&!r.status?s.jsx(b.Tag,{children:n}):o.children}const Q=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:Je,WorkflowColumn:Ge,UserColumn:Le,UserJobStatusColumn:Ye},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-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},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 m;const{data:r}=e.useCurrentUserContext(),{userJob:n}=l.useFlowContext(),{status:t,result:i,userId:a}=n,u=S.useFieldSchema(),{name:d}=u.parent.toJSON();let{children:p}=o;return t?i[d]||(p=null):((m=r==null?void 0:r.data)==null?void 0:m.id)!==a&&(p=null),p}const ae=h.createContext(null);ae.displayName="ManualActionStatusContext";function He({value:o,children:r}){const{userJob:n,execution:t}=l.useFlowContext(),i=S.useField(),a=S.useFieldSchema();return h.useEffect(()=>{(t.status||n.status)&&(i.disabled=!0,i.visible=n.status===o&&n.result._===a.name)},[t,n,o,i,a.name]),s.jsx(ae.Provider,{value:o,children:r})}function Xe(){const o=e.useAPIClient(),{setVisible:r}=e.useActionContext(),{values:n,submit:t}=S.useForm(),i=S.useFieldSchema(),{service:a}=e.useTableBlockContext(),{userJob:u,execution:d}=l.useFlowContext(),{name:p}=i,{name:m}=i.parent.parent;return{run(){return U(this,null,function*(){d.status||u.status||(yield t(),yield o.resource("users_jobs").submit({filterByTk:u.id,values:{result:{[m]:n,_:p}}}),r(!1),a.refresh())})}}}function Ze(o){var f;const r=e.usePlugin(l),n=e.useAPIClient(),{id:t}=e.useRecord(),[i,a]=h.useState(null),[u,d]=h.useState(null);h.useEffect(()=>{var c,x;t&&((x=(c=n.resource("users_jobs")).get)==null||x.call(c,{filterByTk:t,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:F})=>{var O;const D=(O=F==null?void 0:F.data)!=null?O:{},{node:v,workflow:N={}}=D,J=N,{nodes:w=[]}=J,I=$(J,["nodes"]),ce=D,{execution:B}=ce,A=$(ce,["node","workflow","execution"]);l.linkNodes(w),d(v),a({userJob:A,workflow:I,nodes:w,execution:B})}))},[n,t]);const m=l.useAvailableUpstreams(i==null?void 0:i.nodes.find(c=>c.id===u.id)).reduce((c,{type:x})=>Object.assign(c,r.instructions.get(x).components),{});return u&&i?s.jsx(l.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:g(g({FormBlockProvider:X,DetailsBlockProvider:l.DetailsBlockProvider,ActionBarProvider:Qe,ManualActionStatusProvider:He},Array.from(z.getValues()).reduce((c,x)=>Object.assign(c,x.block.components),{})),m),scope:g({useSubmit:Xe,useFormBlockProps:We,useDetailsBlockProps:Re},Array.from(z.getValues()).reduce((c,x)=>Object.assign(c,x.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(f=u.config)==null?void 0:f.schema}})}):s.jsx(b.Spin,{})}function We(){var u;const{userJob:o,execution:r}=l.useFlowContext(),n=e.useRecord(),{data:t}=e.useCurrentUserContext(),{form:i}=e.useFormBlockContext(),a=r.status||o.status?n?"readPretty":"disabled":((u=t==null?void 0:t.data)==null?void 0:u.id)!==o.userId?"disabled":"editable";return h.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Re(){const{form:o}=e.useFormBlockContext();return{form:o}}function eo(){const o=e.useCompile(),{status:r,updatedAt:n}=e.useRecord(),t=l.JobStatusOptionsMap[r];return r?s.jsxs(b.Space,{children:[s.jsx("time",{className:e.css`
|
|
20
|
+
`,children:[s.jsx(b.Form.Item,{children:s.jsxs(b.Radio.Group,{value:!!o,onChange:({target:{value:t}})=>{console.log(t),r(Number(t))},children:[s.jsx(b.Radio,{value:!0,children:s.jsxs(b.Tooltip,{title:T("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:T("Separately")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(b.Radio,{value:!1,children:s.jsxs(b.Tooltip,{title:T("Everyone shares one task"),placement:"bottom",children:[s.jsx("span",{children:T("Collaboratively")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),o?n:null]})}function Ne(o){return o.isForeignKey?o.target==="users":o.collectionName==="users"&&o.name==="id"}function $e({multiple:o=!1,value:r=[],onChange:n}){const t=l.useWorkflowVariableOptions({types:[Ne]});return s.jsx(e.Variable.Input,{scope:t,value:r[0],onChange:i=>{n([i])},children:s.jsx(e.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:r[0],onChange:i=>{n(i!=null?[i]:[])}})})}function Ue({key:o,title:r,config:n},{types:t,fieldNames:i=l.defaultFieldNames}){var m;const a=e.useCompile(),{getCollectionFields:u}=e.useCollectionManager_deprecated(),d=Object.keys((m=n.forms)!=null?m:{});if(!d.length)return null;const p=d.map(f=>{var v;const c=n.forms[f],x=l.getCollectionFieldOptions({fields:(v=c.collection)==null?void 0:v.fields,collection:c.collection,types:t,compile:a,getCollectionFields:u}),F=a(c.title)||f;return x.length?{key:f,value:f,label:F,title:F,children:x}:null}).filter(Boolean);return p.length?{[i.value]:o,[i.label]:r,[i.children]:p}:null}class _e extends l.Instruction{constructor(){super(...arguments);P(this,"title",`{{t("Manual", { ns: "${y}" })}}`);P(this,"type","manual");P(this,"group","manual");P(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}" })}}`);P(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:{}}});P(this,"components",{SchemaConfigButton:Pe,SchemaConfig:De,ModeConfig:je,AssigneesSelect:$e});P(this,"useVariables",Ue)}useInitializers(n){var u;const{getCollection:t}=e.useCollectionManager_deprecated(),i=Object.keys((u=n.config.forms)!=null?u:{});if(!i.length||n.config.mode)return null;const a=i.map(d=>{var f,c;const p=n.config.forms[d],{fields:m=[]}=t(p.collection);return m.length?{name:(f=p.title)!=null?f:d,type:"item",title:(c=p.title)!=null?c:d,Component:l.CollectionBlockInitializer,collection:p.collection,dataPath:`$jobsMapByNodeKey.${n.key}.${d}`}:null}).filter(Boolean);return a.length?{name:`#${n.id}`,key:"forms",type:"subMenu",title:n.title,children:a}:null}isAvailable({engine:n,workflow:t,upstream:i,branchIndex:a}){return!n.isWorkflowSync(t)}}const Ee={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"}}]},Ke={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}}]},qe={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:l.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Je=S.observer(()=>{var r,n,t;const o=S.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),Ge=S.observer(()=>{var r,n,t;const o=S.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),Le=S.observer(()=>{var r,n,t;const o=S.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.nickname)!=null?t:(n=o.value)==null?void 0:n.id},{displayName:"UserColumn"});function Ye(o){const r=e.useRecord(),n=T("Unprocessed");return r.execution.status&&!r.status?s.jsx(b.Tag,{children:n}):o.children}const Q=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:Je,WorkflowColumn:Ge,UserColumn:Le,UserJobStatusColumn:Ye},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},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 m;const{data:r}=e.useCurrentUserContext(),{userJob:n}=l.useFlowContext(),{status:t,result:i,userId:a}=n,u=S.useFieldSchema(),{name:d}=u.parent.toJSON();let{children:p}=o;return t?i[d]||(p=null):((m=r==null?void 0:r.data)==null?void 0:m.id)!==a&&(p=null),p}const ae=h.createContext(null);ae.displayName="ManualActionStatusContext";function He({value:o,children:r}){const{userJob:n,execution:t}=l.useFlowContext(),i=S.useField(),a=S.useFieldSchema();return h.useEffect(()=>{(t.status||n.status)&&(i.disabled=!0,i.visible=n.status===o&&n.result._===a.name)},[t,n,o,i,a.name]),s.jsx(ae.Provider,{value:o,children:r})}function Xe(){const o=e.useAPIClient(),{setVisible:r}=e.useActionContext(),{values:n,submit:t}=S.useForm(),i=S.useFieldSchema(),{service:a}=e.useTableBlockContext(),{userJob:u,execution:d}=l.useFlowContext(),{name:p}=i,{name:m}=i.parent.parent;return{run(){return U(this,null,function*(){d.status||u.status||(yield t(),yield o.resource("users_jobs").submit({filterByTk:u.id,values:{result:{[m]:n,_:p}}}),r(!1),a.refresh())})}}}function Ze(o){var f;const r=e.usePlugin(l),n=e.useAPIClient(),{id:t}=e.useRecord(),[i,a]=h.useState(null),[u,d]=h.useState(null);h.useEffect(()=>{var c,x;t&&((x=(c=n.resource("users_jobs")).get)==null||x.call(c,{filterByTk:t,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:F})=>{var O;const D=(O=F==null?void 0:F.data)!=null?O:{},{node:v,workflow:N={}}=D,J=N,{nodes:w=[]}=J,I=$(J,["nodes"]),ce=D,{execution:B}=ce,A=$(ce,["node","workflow","execution"]);l.linkNodes(w),d(v),a({userJob:A,workflow:I,nodes:w,execution:B})}))},[n,t]);const m=l.useAvailableUpstreams(i==null?void 0:i.nodes.find(c=>c.id===u.id)).reduce((c,{type:x})=>Object.assign(c,r.instructions.get(x).components),{});return u&&i?s.jsx(l.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:g(g({FormBlockProvider:X,DetailsBlockProvider:l.DetailsBlockProvider,ActionBarProvider:Qe,ManualActionStatusProvider:He},Array.from(z.getValues()).reduce((c,x)=>Object.assign(c,x.block.components),{})),m),scope:g({useSubmit:Xe,useFormBlockProps:We,useDetailsBlockProps:Re},Array.from(z.getValues()).reduce((c,x)=>Object.assign(c,x.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(f=u.config)==null?void 0:f.schema}})}):s.jsx(b.Spin,{})}function We(){var u;const{userJob:o,execution:r}=l.useFlowContext(),n=e.useRecord(),{data:t}=e.useCurrentUserContext(),{form:i}=e.useFormBlockContext(),a=r.status||o.status?n?"readPretty":"disabled":((u=t==null?void 0:t.data)==null?void 0:u.id)!==o.userId?"disabled":"editable";return h.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Re(){const{form:o}=e.useFormBlockContext();return{form:o}}function eo(){const o=e.useCompile(),{status:r,updatedAt:n}=e.useRecord(),t=l.JobStatusOptionsMap[r];return r?s.jsxs(b.Space,{children:[s.jsx("time",{className:e.css`
|
|
21
21
|
margin-right: 0.5em;
|
|
22
22
|
`,children:de(n).format("YYYY-MM-DD HH:mm:ss")}),s.jsx(b.Tag,{icon:t.icon,color:t.color,children:o(t.label)})]}):null}function oo(){var a;const o=h.useContext(e.SchemaComponentContext),{id:r,node:n,workflow:t,status:i}=e.useRecord();return s.jsx(e.SchemaComponentContext.Provider,{value:k(g({},o),{reset(){},designable:!1}),children:s.jsx(e.SchemaComponent,{components:{FooterStatus:eo,FlowContextProvider:Ze},schema:{type:"void",name:`drawer-${r}-${i}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${t.title} - ${(a=n.title)!=null?a:`#${n.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function to({params:o={},children:r}){const n={collection:"users_jobs",resource:"users_jobs",action:"list",params:k(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.ExtendCollectionsProvider,{collections:[Ee,Ke,qe],children:s.jsx(e.TableBlockProvider,k(g({name:"workflow-todo"},n),{children:r}))})}Q.Drawer=oo,Q.Decorator=to;const no=()=>{const o=e.useSchemaInitializerItem(),{insert:r}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,k(g({icon:s.jsx(q.TableOutlined,{})},o),{onClick:()=>{r({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class ro extends e.Plugin{afterAdd(){return U(this,null,function*(){})}load(){return U(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",_e),this.app.schemaInitializerManager.add(ne),this.app.schemaInitializerManager.add(Ae),this.app.schemaInitializerManager.add(ie),this.app.schemaInitializerManager.add(Oe),this.app.schemaInitializerManager.add(oe),this.app.schemaInitializerManager.add(Se),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflowTodos",{title:`{{t("Workflow todos", { ns: "${y}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"})})}addComponents(){this.app.addComponents({WorkflowTodo:Q,WorkflowTodoBlockInitializer:no})}}C.default=ro,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -12,18 +12,18 @@ module.exports = {
|
|
|
12
12
|
"antd": "5.12.8",
|
|
13
13
|
"dayjs": "1.11.10",
|
|
14
14
|
"react": "18.2.0",
|
|
15
|
-
"@nocobase/client": "1.2.
|
|
16
|
-
"@nocobase/plugin-workflow": "1.2.
|
|
15
|
+
"@nocobase/client": "1.2.5-alpha",
|
|
16
|
+
"@nocobase/plugin-workflow": "1.2.5-alpha",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
18
18
|
"react-i18next": "11.18.6",
|
|
19
|
-
"@nocobase/utils": "1.2.
|
|
20
|
-
"@nocobase/server": "1.2.
|
|
21
|
-
"@nocobase/actions": "1.2.
|
|
22
|
-
"@nocobase/resourcer": "1.2.
|
|
23
|
-
"@nocobase/test": "1.2.
|
|
24
|
-
"@nocobase/plugin-workflow-test": "1.2.
|
|
19
|
+
"@nocobase/utils": "1.2.5-alpha",
|
|
20
|
+
"@nocobase/server": "1.2.5-alpha",
|
|
21
|
+
"@nocobase/actions": "1.2.5-alpha",
|
|
22
|
+
"@nocobase/resourcer": "1.2.5-alpha",
|
|
23
|
+
"@nocobase/test": "1.2.5-alpha",
|
|
24
|
+
"@nocobase/plugin-workflow-test": "1.2.5-alpha",
|
|
25
25
|
"@formily/core": "2.3.0",
|
|
26
26
|
"@formily/antd-v5": "1.1.9",
|
|
27
|
-
"@nocobase/database": "1.2.
|
|
27
|
+
"@nocobase/database": "1.2.5-alpha",
|
|
28
28
|
"lodash": "4.17.21"
|
|
29
29
|
};
|
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": "1.2.
|
|
7
|
+
"version": "1.2.5-alpha",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow-manual",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@nocobase/test": "1.x",
|
|
31
31
|
"@nocobase/utils": "1.x"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "ca7baa2d4dffe0e2c02f676b96ff841f3ee31e7e",
|
|
34
34
|
"keywords": [
|
|
35
35
|
"Workflow"
|
|
36
36
|
]
|