@nocobase/plugin-workflow-manual 0.21.0-alpha.9 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/WorkflowTodo.d.ts +8 -0
- package/dist/client/WorkflowTodoBlockInitializer.d.ts +8 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +13 -4
- package/dist/client/instruction/AssigneesSelect.d.ts +8 -0
- package/dist/client/instruction/FormBlockInitializer.d.ts +8 -0
- package/dist/client/instruction/FormBlockProvider.d.ts +8 -0
- package/dist/client/instruction/ModeConfig.d.ts +8 -0
- package/dist/client/instruction/SchemaConfig.d.ts +8 -0
- package/dist/client/instruction/createManualFormBlockUISchema.d.ts +8 -0
- package/dist/client/instruction/forms/create.d.ts +8 -0
- package/dist/client/instruction/forms/custom.d.ts +8 -0
- package/dist/client/instruction/forms/update.d.ts +8 -0
- package/dist/client/instruction/index.d.ts +8 -0
- package/dist/client/instruction/utils.d.ts +8 -0
- package/dist/externalVersion.js +18 -9
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/locale/index.d.ts +8 -0
- package/dist/locale/index.js +9 -0
- package/dist/server/ManualInstruction.d.ts +8 -0
- package/dist/server/ManualInstruction.js +16 -3
- package/dist/server/Plugin.d.ts +8 -0
- package/dist/server/Plugin.js +9 -0
- package/dist/server/actions.d.ts +8 -0
- package/dist/server/actions.js +10 -1
- package/dist/server/collections/1-users_jobs.d.ts +8 -0
- package/dist/server/collections/1-users_jobs.js +9 -0
- package/dist/server/collections/2-jobs.d.ts +8 -0
- package/dist/server/collections/2-jobs.js +9 -0
- package/dist/server/collections/3-users.d.ts +8 -0
- package/dist/server/collections/3-users.js +9 -0
- package/dist/server/forms/create.d.ts +8 -0
- package/dist/server/forms/create.js +9 -0
- package/dist/server/forms/index.d.ts +8 -0
- package/dist/server/forms/index.js +9 -0
- package/dist/server/forms/update.d.ts +8 -0
- package/dist/server/forms/update.js +9 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +9 -0
- package/dist/server/migrations/20240325213145-fix-schema.d.ts +9 -0
- package/dist/server/migrations/20240325213145-fix-schema.js +10 -0
- package/package.json +9 -9
- package/src/client/WorkflowTodo.tsx +0 -647
- package/src/client/WorkflowTodoBlockInitializer.tsx +0 -32
- package/src/client/__e2e__/assignees.test.ts +0 -0
- package/src/client/__e2e__/createRecordForm.test.ts +0 -2287
- package/src/client/__e2e__/customFormBlocks.test.ts +0 -1933
- package/src/client/__e2e__/datablocks.test.ts +0 -1208
- package/src/client/__e2e__/updateRecordForm.test.ts +0 -2338
- package/src/client/__e2e__/workflowTodo.test.ts +0 -242
- package/src/client/index.ts +0 -51
- package/src/client/instruction/AssigneesSelect.tsx +0 -39
- package/src/client/instruction/FormBlockInitializer.tsx +0 -79
- package/src/client/instruction/FormBlockProvider.tsx +0 -97
- package/src/client/instruction/ModeConfig.tsx +0 -85
- package/src/client/instruction/SchemaConfig.tsx +0 -659
- package/src/client/instruction/createManualFormBlockUISchema.ts +0 -5
- package/src/client/instruction/forms/create.tsx +0 -123
- package/src/client/instruction/forms/custom.tsx +0 -439
- package/src/client/instruction/forms/update.tsx +0 -167
- package/src/client/instruction/index.tsx +0 -160
- package/src/client/instruction/utils.ts +0 -19
- package/src/index.ts +0 -2
- package/src/locale/en-US.json +0 -30
- package/src/locale/index.ts +0 -14
- package/src/locale/ko_KR.json +0 -32
- package/src/locale/zh-CN.json +0 -32
- package/src/server/ManualInstruction.ts +0 -152
- package/src/server/Plugin.ts +0 -43
- package/src/server/__tests__/collections/categories.ts +0 -15
- package/src/server/__tests__/collections/comments.ts +0 -24
- package/src/server/__tests__/collections/posts.ts +0 -40
- package/src/server/__tests__/collections/replies.ts +0 -9
- package/src/server/__tests__/collections/tags.ts +0 -15
- package/src/server/__tests__/data-source.test.ts +0 -223
- package/src/server/__tests__/form.test.ts +0 -637
- package/src/server/__tests__/mode.test.ts +0 -561
- package/src/server/actions.ts +0 -100
- package/src/server/collections/1-users_jobs.ts +0 -52
- package/src/server/collections/2-jobs.ts +0 -19
- package/src/server/collections/3-users.ts +0 -17
- package/src/server/forms/create.ts +0 -30
- package/src/server/forms/index.ts +0 -13
- package/src/server/forms/update.ts +0 -30
- package/src/server/index.ts +0 -1
- package/src/server/migrations/20240325213145-fix-schema.ts +0 -81
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import React from 'react';
|
|
2
10
|
export declare const WorkflowTodo: React.FC & {
|
|
3
11
|
Drawer: React.FC;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { FC } from 'react';
|
|
2
10
|
export declare const WorkflowTodoBlockInitializer: FC<any>;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Plugin } from '@nocobase/client';
|
|
2
10
|
export default class extends Plugin {
|
|
3
11
|
afterAdd(): Promise<void>;
|
package/dist/client/index.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
(function(x,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):(x=typeof globalThis!="undefined"?globalThis:x||self,e(x["@nocobase/plugin-workflow-manual"]={},x["@nocobase/client"],x["@nocobase/plugin-workflow"],x.jsxRuntime,x["@formily/antd-v5"],x["@formily/core"],x["@formily/react"],x.antd,x.react,x["react-i18next"],x["@nocobase/utils"],x.lodash,x["@ant-design/icons"],x.dayjs))})(this,function(x,e,c,s,_,K,b,S,h,N,D,J,q,ue){"use strict";var eo=Object.defineProperty,oo=Object.defineProperties;var to=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var X=(x,e,c)=>e in x?eo(x,e,{enumerable:!0,configurable:!0,writable:!0,value:c}):x[e]=c,y=(x,e)=>{for(var c in e||(e={}))pe.call(e,c)&&X(x,c,e[c]);if(Y)for(var c of Y(e))de.call(e,c)&&X(x,c,e[c]);return x},w=(x,e)=>oo(x,to(e));var $=(x,e)=>{var c={};for(var s in x)pe.call(x,s)&&e.indexOf(s)<0&&(c[s]=x[s]);if(x!=null&&Y)for(var s of Y(x))e.indexOf(s)<0&&de.call(x,s)&&(c[s]=x[s]);return c};var E=(x,e,c)=>(X(x,typeof e!="symbol"?e+"":e,c),c);var U=(x,e,c)=>new Promise((s,_)=>{var K=h=>{try{S(c.next(h))}catch(N){_(N)}},b=h=>{try{S(c.throw(h))}catch(N){_(N)}},S=h=>h.done?s(h.value):Promise.resolve(h.value).then(K,b);S((c=c.apply(x,e)).next())});const g="workflow-manual";function B(t,r={}){const{t:n}=Q(r);return n(t)}function Q(t){return N.useTranslation(g,t)}function Z(t){var P,z,G;const r=e.useRecord(),n=b.useFieldSchema(),o=b.useField(),i=h.useRef(null),a=t.dataSource||e.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:l}=e.useAssociationNames(a),{appends:p,updateAssociationValues:u}=l(),[m]=Object.keys((P=n.toJSON().properties)!=null?P:{}),f=(z=r==null?void 0:r.result)==null?void 0:z[m],{findComponent:d}=e.useDesignable(),C=d((G=o.component)==null?void 0:G[0])||h.Fragment,k=h.useMemo(()=>K.createForm({initialValues:f}),[f]),v=h.useMemo(()=>y({appends:p},t.params),[p,t.params]),F=h.useMemo(()=>({loading:!1,data:{data:f}}),[f]),I=e.useAPIClient(),T=e.useDataSourceHeaders(a),A=I.resource(t.collection,void 0,T),V=e.useBlockRequestContext(),M=h.useMemo(()=>({params:v,form:k,field:o,service:F,updateAssociationValues:u,formBlockRef:i}),[o,k,v,F,u]);return!r.status||f?s.jsx(e.CollectionManagerProvider,{dataSource:a,children:s.jsx(e.CollectionProvider_deprecated,{collection:t.collection,children:s.jsx(e.RecordProvider,{record:f,parent:null,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",children:s.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:t,field:o,service:F,resource:A,__parent:V},children:s.jsx(e.FormBlockContext.Provider,{value:M,children:s.jsxs(C,w(y({},o.componentProps),{children:[s.jsx(e.FormV2.Templates,{style:{marginBottom:18},form:k}),s.jsx("div",{ref:i,children:s.jsx(b.RecursionField,{schema:n,onlyRenderProperties:!0})})]}))})})})})})}):null}function me(t){return e.createFormBlockSchema(t)}function fe(n){var o=n,{schema:t}=o,r=$(o,["schema"]);const{getTemplateSchemaByMode:i}=e.useSchemaTemplateManager(),{insert:a}=e.useSchemaInitializer(),l=e.useRecordCollectionDataSourceItems("FormItem");function p(m){return U(this,arguments,function*({item:u}){var v;const f=u.template?yield i(u):null,d=me(w(y({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${g}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:c.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:f}));delete d["x-acl-action-props"],delete d["x-acl-action"];const[C]=Object.keys(d.properties),k=((v=Object.entries(d.properties[C].properties).find(([F,I])=>I["x-component"]==="ActionBar"))==null?void 0:v[0])||"actions";d.properties[C].properties[k]["x-decorator"]="ActionBarProvider",d.properties[C].properties[k]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},c.traverseSchema(d,F=>{F["x-uid"]&&delete F["x-uid"]}),a(d)})}return s.jsx(e.SchemaInitializerItem,w(y({},r),{onClick:p,items:l}))}function W(){var r,n;const t=e.useSchemaInitializerItem();return s.jsx(e.CollectionProvider_deprecated,{dataSource:(r=t.schema)==null?void 0:r.dataSource,collection:(n=t.schema)==null?void 0:n.collection,children:s.jsx(fe,y({},t))})}function j(t,r,n=!1){const o=[];return t?r(t)&&(!n||!t.properties)?(o.push(t),o):(t.properties&&Object.keys(t.properties).forEach(i=>{o.push(...j(t.properties[i],r))}),o):o}function he(){const{name:t,title:r}=e.useCollection_deprecated();return s.jsxs(e.GeneralSchemaDesigner,{title:r||t,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:t}),s.jsx(e.SchemaSettingsDataTemplates,{collectionName:t}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const xe={title:`{{t("Create record form", { ns: "${g}" })}}`,config:{useInitializer({allCollections:t}){const r=h.useMemo(()=>t.map(({key:a,displayName:l,collections:p})=>({key:a,name:a,label:l,type:"subMenu",children:p.map(u=>({name:J.camelCase(`createRecordForm-child-${u.name}`),type:"item",title:u.title||u.tableName,schema:{collection:u.name,dataSource:a,title:`{{t("Create record", { ns: "${g}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:W}))})),[t]),[n,o]=h.useState([]),i=e.useMenuSearch({data:r,openKeys:n});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${g}" })}}`,componentProps:{onOpenChange(a){o(a)}},children:i}},initializers:{},components:{CreateFormDesigner:he},parseFormOptions(t){const r={};return j(t,o=>o["x-decorator"]==="FormBlockProvider"&&o["x-decorator-props"].formType==="create").forEach(o=>{var p,u;const[i]=Object.keys(o.properties),a=o.properties[i],l=((p=Object.entries(a.properties).find(([m,f])=>f["x-component"]==="ActionBar"))==null?void 0:p[0])||"actions";r[i]={type:"create",title:((u=o["x-component-props"])==null?void 0:u.title)||i,actions:j(a.properties[l],m=>m["x-component"]==="Action").map(m=>{var f,d;return{status:m["x-decorator-props"].value,values:(d=(f=m["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:d.values,key:m.name}}),collection:o["x-decorator-props"].collection}}),r}},block:{scope:{},components:{}}};function R(t){var m,f,d,C;const[r,n]=h.useState((f=(m=t.collection)==null?void 0:m.fields)!=null?f:[]),o=e.useRecord(),i=b.useField(),a=b.useFieldSchema(),[l]=Object.keys((d=a.toJSON().properties)!=null?d:{}),p=(C=o==null?void 0:o.result)==null?void 0:C[l],u=h.useMemo(()=>K.createForm({initialValues:p}),[p]);return!o.status||p?s.jsx(e.CollectionProvider_deprecated,{collection:w(y({},t.collection),{fields:r}),children:s.jsx(e.RecordProvider,{record:p,parent:null,children:s.jsx(e.FormBlockContext.Provider,{value:{form:u,field:i,setCollectionFields:n},children:t.children})})}):null}function Ce(){const{insert:t}=e.useSchemaInitializer(),r=e.useSchemaInitializerItem();return s.jsx(e.SchemaInitializerItem,w(y({},r),{onClick:()=>{t({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:D.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[D.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${g}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:c.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const ee={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function ge(t){const r={};return Object.keys(t).forEach(n=>{const o=t[n],{group:i="others"}=o;r[i]=r[i]||{},J.set(r,[i,n],o)}),Object.keys(ee).filter(n=>["basic","choices","datetime","media"].includes(n)).map(n=>({title:ee[n],children:Object.keys(r[n]||{}).map(o=>{const i=r[n][o];return y({value:o,title:i.title,name:o},r[n][o])}).sort((o,i)=>o.order-i.order)}))}function ye(){const{interfaces:t}=e.useCollectionManager_deprecated();return ge(t).map(n=>({name:n.title,type:"itemGroup",title:n.title,children:n.children.map(o=>({name:o.name,type:"item",title:o.title,Component:Se,fieldInterface:o.name}))}))}const oe=h.createContext({}),te=t=>{const[r,n]=h.useState(null),[o,i]=h.useState(),a=ye(),l=e.useCollection_deprecated(),{setCollectionFields:p}=h.useContext(e.FormBlockContext),u=h.useMemo(()=>K.createForm(),[r]);return s.jsxs(oe.Provider,{value:{onAddField(m){const f=J.pick(m,["name","group","title","default","validateSchema"]),{properties:T}=m,A=T,{unique:d,type:C,layout:k,autoIncrement:v}=A,F=$(A,["unique","type","layout","autoIncrement"]);f.properties=F;const I=J.cloneDeep(f);delete I.properties.name["x-disabled"],n(I)},setCallback:i},children:[s.jsx(e.SchemaInitializerItems,w(y({},t),{items:a})),s.jsx(e.ActionContextProvider,{value:{visible:!!r,setVisible(m){m||n(null)}},children:r?s.jsx(e.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:u},"x-component":"Action.Drawer",properties:w(y({},r.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const m=b.useForm();return{run(){return U(this,null,function*(){i(null),n(null),m.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:m,query:f,reset:d}=b.useForm(),C=[B("Field name existed in form")];return{run(){return U(this,null,function*(){var A,V,M,P;const{default:v}=r,F=D.uid();if(v.name=(A=m.name)!=null?A:F,v.uiSchema.title=(M=(V=m.uiSchema)==null?void 0:V.title)!=null?M:F,v.interface=r.name,(P=l.fields)==null?void 0:P.find(z=>z.name===v.name)){f("name").take().setFeedback({type:"error",messages:C});return}const T=D.merge(v,m);p([...l.fields,T]),o({name:v.name,type:v.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:T},"x-collection-field":`${l.name}.${v.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),d(),i(null),n(null)})}}}}}}}})},components:{ArrayTable:_.ArrayTable}}):null})]})},ne=new e.CompatibleSchemaInitializer({name:"AddCustomFormField",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:te}),be=new e.CompatibleSchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:te},ne);function Se(){const t=e.useSchemaInitializerItem(),{insert:r,setVisible:n}=e.useSchemaInitializer(),{onAddField:o,setCallback:i}=h.useContext(oe),{getInterface:a}=e.useCollectionManager_deprecated(),l=a(t.fieldInterface);return s.jsx(e.SchemaInitializerItem,y({onClick:()=>{i(()=>r),o(l),n(!1)}},t),t.fieldInterface)}const re={title:`{{t("Custom form", { ns: "${g}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${g}" })}}`,Component:Ce}},initializers:{},components:{CustomFormBlockProvider:R},parseFormOptions(t){const r={};return j(t,o=>o["x-decorator"]==="CustomFormBlockProvider").forEach(o=>{var u,m;const[i]=Object.keys(o.properties),a=o.properties[i],l=j(a.properties.grid,f=>f["x-component"]==="CollectionField",!0);o["x-decorator-props"].collection.fields=l.map(f=>{var d,C;return(C=(d=f["x-component-props"])==null?void 0:d.field)!=null?C:f["x-interface-options"]});const p=((u=Object.entries(a.properties).find(([f,d])=>d["x-component"]==="ActionBar"))==null?void 0:u[0])||"actions";r[i]={type:"custom",title:((m=o["x-component-props"])==null?void 0:m.title)||i,actions:j(a.properties[p],f=>f["x-component"]==="Action").map(f=>{var d,C;return{status:f["x-decorator-props"].value,values:(C=(d=f["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:C.values,key:f.name}}),collection:o["x-decorator-props"].collection}}),r}},block:{scope:{},components:{CustomFormBlockProvider:R}}};function ve(){const{name:t,title:r}=e.useCollection_deprecated(),n=b.useFieldSchema(),{t:o}=N.useTranslation(),{dn:i}=e.useDesignable();return s.jsxs(e.GeneralSchemaDesigner,{title:r||t,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsActionModalItem,{title:o("Filter settings",{ns:g}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var l;return{options:e.useCollectionFilterOptions((l=n==null?void 0:n["x-decorator-props"])==null?void 0:l.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:n==null?void 0:n["x-decorator-props"],onSubmit:({filter:a})=>{n["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":n["x-decorator-props"]}}),i.refresh()}}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:t}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Fe={title:`{{t("Update record form", { ns: "${g}" })}}`,config:{useInitializer({allCollections:t}){const r=h.useMemo(()=>t.map(({key:a,displayName:l,collections:p})=>({key:a,name:a,label:l,type:"subMenu",children:p.map(u=>({name:J.camelCase(`updateRecordForm-child-${u.name}`),type:"item",title:u.title||u.tableName,schema:{collection:u.name,dataSource:a,title:`{{t("Update record", { ns: "${g}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:W}))})),[t]),[n,o]=h.useState([]),i=e.useMenuSearch({data:r,openKeys:n});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${g}" })}}`,componentProps:{onOpenChange(a){o(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:c.FilterDynamicComponent,UpdateFormDesigner:ve},parseFormOptions(t){const r={};return j(t,o=>o["x-decorator"]==="FormBlockProvider"&&o["x-decorator-props"].formType==="update").forEach(o=>{var p,u;const[i]=Object.keys(o.properties),a=o.properties[i],l=((p=Object.entries(a.properties).find(([m,f])=>f["x-component"]==="ActionBar"))==null?void 0:p[0])||"actions";r[i]=w(y({},o["x-decorator-props"]),{type:"update",title:((u=o["x-component-props"])==null?void 0:u.title)||i,actions:j(a.properties[l],m=>m["x-component"]==="Action").map(m=>{var f,d;return{status:m["x-decorator-props"].value,values:(d=(f=m["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:d.values,key:m.name}})})}),r}},block:{scope:{},components:{}},validate({filter:t}){return!t||!D.isValidFilter(t)?"Please check one of your update record form, and add at least one filter condition in form settings.":null}},O=new D.Registry;O.register("custom",re),O.register("create",xe),O.register("update",Fe);function se(){const{workflow:t}=c.useFlowContext(),r=c.useTrigger();return r.useInitializers?r.useInitializers(t.config):null}re.title,`${g}`;const ie=new e.CompatibleSchemaInitializer({name:"AddBlockButton",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const t=e.usePlugin(c),r=c.useNodeContext(),n=c.useAvailableUpstreams(r),o=[se()].filter(Boolean),i=n.map(l=>{var u;const p=t.instructions.get(l.type);return(u=p==null?void 0:p.useInitializers)==null?void 0:u.call(p,l)}).filter(Boolean);return[...o,...i.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const r=e.useDataSourceManager().getAllCollections();return Array.from(O.getValues()).map(n=>{const{useInitializer:o}=n.config;return o({allCollections:r})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]}),ke=new e.CompatibleSchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const t=e.usePlugin(c),r=c.useNodeContext(),n=c.useAvailableUpstreams(r),o=[se()].filter(Boolean),i=n.map(l=>{var u;const p=t.instructions.get(l.type);return(u=p==null?void 0:p.useInitializers)==null?void 0:u.call(p,l)}).filter(Boolean);return[...o,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${g}" })}}`,children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const r=e.useDataSourceManager().getAllCollections();return Array.from(O.getValues()).map(n=>{const{useInitializer:o}=n.config;return o({allCollections:r})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},ie);function we(){var T,A,V;const t=h.useContext(e.SchemaComponentContext),{t:r}=N.useTranslation(),{t:n}=Q(),o=b.useFieldSchema(),i=c.useWorkflowVariableOptions(),[a,l]=h.useState(!1),[p,u]=h.useState((V=(A=(T=o==null?void 0:o["x-action-settings"])==null?void 0:T.assignedValues)==null?void 0:A.schema)!=null?V:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[m,f]=h.useState(null),{components:d}=e.useSchemaOptionsContext();h.useEffect(()=>{f(new b.Schema({properties:{grid:p}}))},[p]);const C=h.useMemo(()=>{var P,z;const M=(z=(P=o==null?void 0:o["x-action-settings"])==null?void 0:P.assignedValues)==null?void 0:z.values;return K.createForm({initialValues:D.lodash.cloneDeep(M),values:D.lodash.cloneDeep(M)})},[o]),k=e.useFormActiveFields(),v=r("Assign field values");function F(){l(!1)}function I(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=p,o["x-action-settings"].assignedValues.values=C.values,l(!1),setTimeout(()=>{var M;(M=t.refresh)==null||M.call(t)},300)}return s.jsxs(s.Fragment,{children:[s.jsx(e.SchemaSettingsItem,{title:v,onClick:()=>l(!0),children:v}),s.jsx(S.Modal,{width:"50%",title:v,open:a,onCancel:F,footer:s.jsxs(S.Space,{children:[s.jsx(S.Button,{onClick:F,children:n("Cancel")}),s.jsx(S.Button,{type:"primary",onClick:I,children:n("Submit")})]}),children:s.jsx(e.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:s.jsx(e.VariableScopeProvider,{scope:i,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:k==null?void 0:k.getActiveFieldsName,children:s.jsx(b.FormProvider,{form:C,children:s.jsxs(_.FormLayout,{layout:"vertical",children:[s.jsx(S.Alert,{message:n("Values preset in this form will override user submitted ones when continue or reject.")}),s.jsx("br",{}),a&&m&&s.jsx(e.SchemaComponentContext.Provider,{value:w(y({},t),{refresh(){u(D.lodash.get(m.toJSON(),"properties.grid"))}}),children:s.jsx(e.SchemaComponent,{schema:m,components:d})})]})})})})})})]})}function Ie(t){return s.jsxs(e.GeneralSchemaDesigner,w(y({},t),{disableInitializer:!0,children:[s.jsx(e.Action.Designer.ButtonEditor,{}),s.jsx(we,{}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function ae(){const a=e.useSchemaInitializerItem(),{action:r,actionProps:n}=a,o=$(a,["action","actionProps"]),{insert:i}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,w(y({},o),{onClick:()=>{i({type:"void",title:o.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":w(y({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function L(){const t=e.useSchemaInitializerItem(),i=t,{action:r,actionProps:n}=i,o=$(i,["action","actionProps"]);return s.jsx(e.InitializerWithSwitch,w(y({},o),{item:t,schema:{type:"void",title:o.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":w(y({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${r}`},type:"x-action"}))}const ce=new e.CompatibleSchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${g}" })}}`,Component:ae,action:c.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.PENDING}]}),Ae=new e.CompatibleSchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${g}" })}}`,Component:ae,action:c.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${g}" })}}`,Component:L,action:c.JOB_STATUS.PENDING}]},ce);function Be(){return{run(){}}}function Te({value:t,onChange:r}){const n=e.usePlugin(c),o=h.useContext(e.SchemaComponentContext),i=c.useNodeContext(),a=c.useAvailableUpstreams(i),l=b.useForm(),{workflow:p}=c.useFlowContext(),u={};a.forEach(d=>{const C=n.instructions.get(d.type);Object.assign(u,C.components)});const m=h.useMemo(()=>new b.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${g}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:e.css`
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
(function(C,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react/jsx-runtime"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@nocobase/utils/client"),require("lodash"),require("@ant-design/icons"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","react/jsx-runtime","@formily/antd-v5","@formily/core","@formily/react","antd","react","react-i18next","@nocobase/utils/client","lodash","@ant-design/icons","dayjs"],e):(C=typeof globalThis!="undefined"?globalThis:C||self,e(C["@nocobase/plugin-workflow-manual"]={},C["@nocobase/client"],C["@nocobase/plugin-workflow"],C.jsxRuntime,C["@formily/antd-v5"],C["@formily/core"],C["@formily/react"],C.antd,C.react,C["react-i18next"],C["@nocobase/utils"],C.lodash,C["@ant-design/icons"],C.dayjs))})(this,function(C,e,c,s,_,K,b,S,h,j,D,J,q,ue){"use strict";var eo=Object.defineProperty,oo=Object.defineProperties;var to=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var H=(C,e,c)=>e in C?eo(C,e,{enumerable:!0,configurable:!0,writable:!0,value:c}):C[e]=c,y=(C,e)=>{for(var c in e||(e={}))pe.call(e,c)&&H(C,c,e[c]);if(L)for(var c of L(e))de.call(e,c)&&H(C,c,e[c]);return C},w=(C,e)=>oo(C,to(e));var $=(C,e)=>{var c={};for(var s in C)pe.call(C,s)&&e.indexOf(s)<0&&(c[s]=C[s]);if(C!=null&&L)for(var s of L(C))e.indexOf(s)<0&&de.call(C,s)&&(c[s]=C[s]);return c};var E=(C,e,c)=>(H(C,typeof e!="symbol"?e+"":e,c),c);var U=(C,e,c)=>new Promise((s,_)=>{var K=h=>{try{S(c.next(h))}catch(j){_(j)}},b=h=>{try{S(c.throw(h))}catch(j){_(j)}},S=h=>h.done?s(h.value):Promise.resolve(h.value).then(K,b);S((c=c.apply(C,e)).next())});const g="workflow-manual";function T(o,r={}){const{t:n}=Y(r);return n(o)}function Y(o){return j.useTranslation(g,o)}function X(o){var z,B;const r=e.useRecord(),n=b.useFieldSchema(),t=b.useField(),i=h.useRef(null),a=o.dataSource||e.DEFAULT_DATA_SOURCE_KEY,{getAssociationAppends:p}=e.useAssociationNames(a),{appends:d,updateAssociationValues:u}=p(),[m]=Object.keys((z=n.toJSON().properties)!=null?z:{}),f=(B=r==null?void 0:r.result)==null?void 0:B[m];e.useDesignable();const l=h.useMemo(()=>K.createForm({initialValues:f}),[f]),x=h.useMemo(()=>y({appends:d},o.params),[d,o.params]),F=h.useMemo(()=>({loading:!1,data:{data:f}}),[f]),v=e.useAPIClient(),k=e.useDataSourceHeaders(a),I=v.resource(o.collection,void 0,k),M=e.useBlockRequestContext(),A=h.useMemo(()=>({params:x,form:l,field:t,service:F,updateAssociationValues:u,formBlockRef:i}),[t,l,x,F,u]);return!r.status||f?s.jsx(e.CollectionManagerProvider,{dataSource:a,children:s.jsx(e.CollectionProvider_deprecated,{collection:o.collection,children:s.jsx(e.RecordProvider,{record:f,parent:null,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",children:s.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:o,field:t,service:F,resource:I,__parent:M},children:s.jsxs(e.FormBlockContext.Provider,{value:A,children:[s.jsx(e.FormV2.Templates,{style:{marginBottom:18},form:l}),s.jsx("div",{ref:i,children:o.children})]})})})})})}):null}function me(o){return e.createFormBlockSchema(o)}function fe(n){var t=n,{schema:o}=t,r=$(t,["schema"]);const{getTemplateSchemaByMode:i}=e.useSchemaTemplateManager(),{insert:a}=e.useSchemaInitializer(),p=e.useRecordCollectionDataSourceItems("FormItem");function d(m){return U(this,arguments,function*({item:u}){var v;const f=u.template?yield i(u):null,l=me(w(y({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${g}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:c.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},o),{template:f}));delete l["x-acl-action-props"],delete l["x-acl-action"];const[x]=Object.keys(l.properties),F=((v=Object.entries(l.properties[x].properties).find(([k,I])=>I["x-component"]==="ActionBar"))==null?void 0:v[0])||"actions";l.properties[x].properties[F]["x-decorator"]="ActionBarProvider",l.properties[x].properties[F]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},c.traverseSchema(l,k=>{k["x-uid"]&&delete k["x-uid"]}),a(l)})}return s.jsx(e.SchemaInitializerItem,w(y({},r),{onClick:d,items:p}))}function Z(){var r,n;const o=e.useSchemaInitializerItem();return s.jsx(e.CollectionProvider_deprecated,{dataSource:(r=o.schema)==null?void 0:r.dataSource,collection:(n=o.schema)==null?void 0:n.collection,children:s.jsx(fe,y({},o))})}function V(o,r,n=!1){const t=[];return o?r(o)&&(!n||!o.properties)?(t.push(o),t):(o.properties&&Object.keys(o.properties).forEach(i=>{t.push(...V(o.properties[i],r))}),t):t}function he(){const{name:o,title:r}=e.useCollection_deprecated();return s.jsxs(e.GeneralSchemaDesigner,{title:r||o,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:o}),s.jsx(e.SchemaSettingsDataTemplates,{collectionName:o}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const xe={title:`{{t("Create record form", { ns: "${g}" })}}`,config:{useInitializer({allCollections:o}){const r=h.useMemo(()=>o.map(({key:a,displayName:p,collections:d})=>({key:a,name:a,label:p,type:"subMenu",children:d.map(u=>({name:J.camelCase(`createRecordForm-child-${u.name}`),type:"item",title:u.title||u.tableName,schema:{collection:u.name,dataSource:a,title:`{{t("Create record", { ns: "${g}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},Component:Z}))})),[o]),[n,t]=h.useState([]),i=e.useMenuSearch({data:r,openKeys:n});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${g}" })}}`,componentProps:{onOpenChange(a){t(a)}},children:i}},initializers:{},components:{CreateFormDesigner:he},parseFormOptions(o){const r={};return V(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var d,u;const[i]=Object.keys(t.properties),a=t.properties[i],p=((d=Object.entries(a.properties).find(([m,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";r[i]={type:"create",title:((u=t["x-component-props"])==null?void 0:u.title)||i,actions:V(a.properties[p],m=>m["x-component"]==="Action").map(m=>{var f,l;return{status:m["x-decorator-props"].value,values:(l=(f=m["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:l.values,key:m.name}}),collection:t["x-decorator-props"].collection}}),r}},block:{scope:{},components:{}}};function W(o){var m,f,l,x;const[r,n]=h.useState((f=(m=o.collection)==null?void 0:m.fields)!=null?f:[]),t=e.useRecord(),i=b.useField(),a=b.useFieldSchema(),[p]=Object.keys((l=a.toJSON().properties)!=null?l:{}),d=(x=t==null?void 0:t.result)==null?void 0:x[p],u=h.useMemo(()=>K.createForm({initialValues:d}),[d]);return!t.status||d?s.jsx(e.CollectionProvider_deprecated,{collection:w(y({},o.collection),{fields:r}),children:s.jsx(e.RecordProvider,{record:d,parent:null,children:s.jsx(e.FormBlockContext.Provider,{value:{form:u,field:i,setCollectionFields:n},children:o.children})})}):null}function Ce(){const{insert:o}=e.useSchemaInitializer(),r=e.useSchemaInitializerItem();return s.jsx(e.SchemaInitializerItem,w(y({},r),{onClick:()=>{o({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:D.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[D.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:customForm:configureFields"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"workflowManual:form:configureActions",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${g}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:c.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const R={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function ge(o){const r={};return Object.keys(o).forEach(n=>{const t=o[n],{group:i="others"}=t;r[i]=r[i]||{},J.set(r,[i,n],t)}),Object.keys(R).filter(n=>["basic","choices","datetime","media"].includes(n)).map(n=>({title:R[n],children:Object.keys(r[n]||{}).map(t=>{const i=r[n][t];return y({value:t,title:i.title,name:t},r[n][t])}).sort((t,i)=>t.order-i.order)}))}function ye(){const{interfaces:o}=e.useCollectionManager_deprecated();return ge(o).map(n=>({name:n.title,type:"itemGroup",title:n.title,children:n.children.map(t=>({name:t.name,type:"item",title:t.title,Component:Se,fieldInterface:t.name}))}))}const ee=h.createContext({}),oe=o=>{const[r,n]=h.useState(null),[t,i]=h.useState(),a=ye(),p=e.useCollection_deprecated(),{setCollectionFields:d}=h.useContext(e.FormBlockContext),u=h.useMemo(()=>K.createForm(),[r]);return s.jsxs(ee.Provider,{value:{onAddField(m){const f=J.pick(m,["name","group","title","default","validateSchema"]),{properties:M}=m,A=M,{unique:l,type:x,layout:F,autoIncrement:v}=A,k=$(A,["unique","type","layout","autoIncrement"]);f.properties=k;const I=J.cloneDeep(f);delete I.properties.name["x-disabled"],n(I)},setCallback:i},children:[s.jsx(e.SchemaInitializerItems,w(y({},o),{items:a})),s.jsx(e.ActionContextProvider,{value:{visible:!!r,setVisible(m){m||n(null)}},children:r?s.jsx(e.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:u},"x-component":"Action.Drawer",properties:w(y({},r.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const m=b.useForm();return{run(){return U(this,null,function*(){i(null),n(null),m.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:m,query:f,reset:l}=b.useForm(),x=[T("Field name existed in form")];return{run(){return U(this,null,function*(){var A,z,B,N;const{default:v}=r,k=D.uid();if(v.name=(A=m.name)!=null?A:k,v.uiSchema.title=(B=(z=m.uiSchema)==null?void 0:z.title)!=null?B:k,v.interface=r.name,(N=p.fields)==null?void 0:N.find(P=>P.name===v.name)){f("name").take().setFeedback({type:"error",messages:x});return}const M=D.merge(v,m);d([...p.fields,M]),t({name:v.name,type:v.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:M},"x-collection-field":`${p.name}.${v.name}`,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),l(),i(null),n(null)})}}}}}}}})},components:{ArrayTable:_.ArrayTable}}):null})]})},te=new e.CompatibleSchemaInitializer({name:"AddCustomFormField",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:oe}),be=new e.CompatibleSchemaInitializer({name:"workflowManual:customForm:configureFields",wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:oe},te);function Se(){const o=e.useSchemaInitializerItem(),{insert:r,setVisible:n}=e.useSchemaInitializer(),{onAddField:t,setCallback:i}=h.useContext(ee),{getInterface:a}=e.useCollectionManager_deprecated(),p=a(o.fieldInterface);return s.jsx(e.SchemaInitializerItem,y({onClick:()=>{i(()=>r),t(p),n(!1)}},o),o.fieldInterface)}const ne={title:`{{t("Custom form", { ns: "${g}" })}}`,config:{useInitializer(){return{name:"customForm",type:"item",title:`{{t("Custom form", { ns: "${g}" })}}`,Component:Ce}},initializers:{},components:{CustomFormBlockProvider:W},parseFormOptions(o){const r={};return V(o,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var u,m;const[i]=Object.keys(t.properties),a=t.properties[i],p=V(a.properties.grid,f=>f["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=p.map(f=>{var l,x;return(x=(l=f["x-component-props"])==null?void 0:l.field)!=null?x:f["x-interface-options"]});const d=((u=Object.entries(a.properties).find(([f,l])=>l["x-component"]==="ActionBar"))==null?void 0:u[0])||"actions";r[i]={type:"custom",title:((m=t["x-component-props"])==null?void 0:m.title)||i,actions:V(a.properties[d],f=>f["x-component"]==="Action").map(f=>{var l,x;return{status:f["x-decorator-props"].value,values:(x=(l=f["x-action-settings"])==null?void 0:l.assignedValues)==null?void 0:x.values,key:f.name}}),collection:t["x-decorator-props"].collection}}),r}},block:{scope:{},components:{CustomFormBlockProvider:W}}};function ve(){const{name:o,title:r}=e.useCollection_deprecated(),n=b.useFieldSchema(),{t}=j.useTranslation(),{dn:i}=e.useDesignable();return s.jsxs(e.GeneralSchemaDesigner,{title:r||o,children:[s.jsx(e.SchemaSettingsBlockTitleItem,{}),s.jsx(e.SchemaSettingsActionModalItem,{title:t("Filter settings",{ns:g}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":()=>{var p;return{options:e.useCollectionFilterOptions((p=n==null?void 0:n["x-decorator-props"])==null?void 0:p.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:n==null?void 0:n["x-decorator-props"],onSubmit:({filter:a})=>{n["x-decorator-props"].filter=a,i.emit("patch",{schema:{"x-decorator-props":n["x-decorator-props"]}}),i.refresh()}}),s.jsx(e.SchemaSettingsLinkageRules,{collectionName:o}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Fe={title:`{{t("Update record form", { ns: "${g}" })}}`,config:{useInitializer({allCollections:o}){const r=h.useMemo(()=>o.map(({key:a,displayName:p,collections:d})=>({key:a,name:a,label:p,type:"subMenu",children:d.map(u=>({name:J.camelCase(`updateRecordForm-child-${u.name}`),type:"item",title:u.title||u.tableName,schema:{collection:u.name,dataSource:a,title:`{{t("Update record", { ns: "${g}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},Component:Z}))})),[o]),[n,t]=h.useState([]),i=e.useMenuSearch({data:r,openKeys:n});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${g}" })}}`,componentProps:{onOpenChange(a){t(a)}},children:i}},initializers:{},components:{FilterDynamicComponent:c.FilterDynamicComponent,UpdateFormDesigner:ve},parseFormOptions(o){const r={};return V(o,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var d,u;const[i]=Object.keys(t.properties),a=t.properties[i],p=((d=Object.entries(a.properties).find(([m,f])=>f["x-component"]==="ActionBar"))==null?void 0:d[0])||"actions";r[i]=w(y({},t["x-decorator-props"]),{type:"update",title:((u=t["x-component-props"])==null?void 0:u.title)||i,actions:V(a.properties[p],m=>m["x-component"]==="Action").map(m=>{var f,l;return{status:m["x-decorator-props"].value,values:(l=(f=m["x-action-settings"])==null?void 0:f.assignedValues)==null?void 0:l.values,key:m.name}})})}),r}},block:{scope:{},components:{}},validate({filter:o}){return!o||!D.isValidFilter(o)?"Please check one of your update record form, and add at least one filter condition in form settings.":null}},O=new D.Registry;O.register("custom",ne),O.register("create",xe),O.register("update",Fe);function re(){const{workflow:o}=c.useFlowContext(),r=c.useTrigger();return r.useInitializers?r.useInitializers(o.config):null}ne.title,`${g}`;const se=new e.CompatibleSchemaInitializer({name:"AddBlockButton",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const o=e.usePlugin(c),r=c.useNodeContext(),n=c.useAvailableUpstreams(r),t=[re()].filter(Boolean),i=n.map(p=>{var u;const d=o.instructions.get(p.type);return(u=d==null?void 0:d.useInitializers)==null?void 0:u.call(d,p)}).filter(Boolean);return[...t,...i.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const r=e.useDataSourceManager().getAllCollections();return Array.from(O.getValues()).map(n=>{const{useInitializer:t}=n.config;return t({allCollections:r})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]}),ke=new e.CompatibleSchemaInitializer({name:"workflowManual:popup:configureUserInterface:addBlock",wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren(){const o=e.usePlugin(c),r=c.useNodeContext(),n=c.useAvailableUpstreams(r),t=[re()].filter(Boolean),i=n.map(p=>{var u;const d=o.instructions.get(p.type);return(u=d==null?void 0:d.useInitializers)==null?void 0:u.call(d,p)}).filter(Boolean);return[...t,...i.length?[{name:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${g}" })}}`,children:i}]:[]].filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren(){const r=e.useDataSourceManager().getAllCollections();return Array.from(O.getValues()).map(n=>{const{useInitializer:t}=n.config;return t({allCollections:r})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},se);function we(){var M,A,z;const o=h.useContext(e.SchemaComponentContext),{t:r}=j.useTranslation(),{t:n}=Y(),t=b.useFieldSchema(),i=c.useWorkflowVariableOptions(),[a,p]=h.useState(!1),[d,u]=h.useState((z=(A=(M=t==null?void 0:t["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:A.schema)!=null?z:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),[m,f]=h.useState(null),{components:l}=e.useSchemaOptionsContext();h.useEffect(()=>{f(new b.Schema({properties:{grid:d}}))},[d]);const x=h.useMemo(()=>{var N,P;const B=(P=(N=t==null?void 0:t["x-action-settings"])==null?void 0:N.assignedValues)==null?void 0:P.values;return K.createForm({initialValues:D.lodash.cloneDeep(B),values:D.lodash.cloneDeep(B)})},[t]),F=e.useFormActiveFields(),v=r("Assign field values");function k(){p(!1)}function I(){t["x-action-settings"]||(t["x-action-settings"]={}),t["x-action-settings"].assignedValues||(t["x-action-settings"].assignedValues={}),t["x-action-settings"].assignedValues.schema=d,t["x-action-settings"].assignedValues.values=x.values,p(!1),setTimeout(()=>{var B;(B=o.refresh)==null||B.call(o)},300)}return s.jsxs(s.Fragment,{children:[s.jsx(e.SchemaSettingsItem,{title:v,onClick:()=>p(!0),children:v}),s.jsx(S.Modal,{width:"50%",title:v,open:a,onCancel:k,footer:s.jsxs(S.Space,{children:[s.jsx(S.Button,{onClick:k,children:n("Cancel")}),s.jsx(S.Button,{type:"primary",onClick:I,children:n("Submit")})]}),children:s.jsx(e.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:s.jsx(e.VariableScopeProvider,{scope:i,children:s.jsx(e.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:F==null?void 0:F.getActiveFieldsName,children:s.jsx(b.FormProvider,{form:x,children:s.jsxs(_.FormLayout,{layout:"vertical",children:[s.jsx(S.Alert,{message:n("Values preset in this form will override user submitted ones when continue or reject.")}),s.jsx("br",{}),a&&m&&s.jsx(e.SchemaComponentContext.Provider,{value:w(y({},o),{refresh(){u(D.lodash.get(m.toJSON(),"properties.grid"))}}),children:s.jsx(e.SchemaComponent,{schema:m,components:l})})]})})})})})})]})}function Ie(o){return s.jsxs(e.GeneralSchemaDesigner,w(y({},o),{disableInitializer:!0,children:[s.jsx(e.Action.Designer.ButtonEditor,{}),s.jsx(we,{}),s.jsx(e.SchemaSettingsDivider,{}),s.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function ie(){const a=e.useSchemaInitializerItem(),{action:r,actionProps:n}=a,t=$(a,["action","actionProps"]),{insert:i}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,w(y({},t),{onClick:()=>{i({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":w(y({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function G(){const o=e.useSchemaInitializerItem(),i=o,{action:r,actionProps:n}=i,t=$(i,["action","actionProps"]);return s.jsx(e.InitializerWithSwitch,w(y({},t),{item:o,schema:{type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":w(y({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${r}`},type:"x-action"}))}const ae=new e.CompatibleSchemaInitializer({name:"AddActionButton",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${g}" })}}`,Component:ie,action:c.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${g}" })}}`,Component:G,action:c.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${g}" })}}`,Component:G,action:c.JOB_STATUS.PENDING}]}),Ae=new e.CompatibleSchemaInitializer({name:"workflowManual:form:configureActions",title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:`{{t("Continue the process", { ns: "${g}" })}}`,Component:ie,action:c.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:`{{t("Terminate the process", { ns: "${g}" })}}`,Component:G,action:c.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:`{{t("Save temporarily", { ns: "${g}" })}}`,Component:G,action:c.JOB_STATUS.PENDING}]},ae);function Be(){return{run(){}}}function Te({value:o,onChange:r}){const n=e.usePlugin(c),t=h.useContext(e.SchemaComponentContext),i=c.useNodeContext(),a=c.useAvailableUpstreams(i),p=b.useForm(),{workflow:d}=c.useFlowContext(),u={};a.forEach(l=>{const x=n.instructions.get(l.type);Object.assign(u,x.components)});const m=h.useMemo(()=>new b.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${g}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:e.css`
|
|
2
11
|
.ant-drawer-body {
|
|
3
12
|
background: var(--nb-box-bg);
|
|
4
13
|
}
|
|
5
|
-
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:
|
|
14
|
+
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:o!=null?o:{tab1:{type:"void",title:`{{t("Manual", { ns: "${g}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}}),[]),f=h.useCallback(function(){const{tabs:x}=D.lodash.get(m.toJSON(),"properties.drawer.properties"),F=Array.from(O.getValues()).reduce((v,k)=>Object.assign(v,k.config.parseFormOptions(x)),{});p.setValuesIn("forms",F),r(x.properties)},[p,r,m]);return s.jsx(e.SchemaComponentContext.Provider,{value:w(y({},t),{designable:!d.executed,refresh:f}),children:s.jsx(e.SchemaComponent,{schema:m,components:w(y(y({},u),Array.from(O.getValues()).reduce((l,x)=>Object.assign(l,x.config.components),{})),{FormBlockProvider:X,DetailsBlockProvider:c.DetailsBlockProvider,ManualActionStatusProvider(l){return l.children},ActionBarProvider(l){return l.children},SimpleDesigner:c.SimpleDesigner,ManualActionDesigner:Ie}),scope:{useSubmit:Be,useDetailsBlockProps:e.useFormBlockContext}})})}function Me(o={}){for(const r of Object.values(o)){const n=O.get(r.type);if(typeof n.validate=="function"){const t=n.validate(r);if(t)return t}}}function ze(o){const{workflow:r}=c.useFlowContext(),[n,t]=h.useState(!1),{values:i}=b.useForm(),{t:a}=Y(),p=h.useCallback(d=>{if(!d){const u=Me(i.forms);if(u){S.message.error({title:a("Validation failed"),content:a(u)});return}}t(d)},[i.forms]);return s.jsxs(s.Fragment,{children:[s.jsx(S.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:a(r.executed?"View user interface":"Configure user interface")}),s.jsx(e.ActionContextProvider,{value:{visible:n,setVisible:p,formValueChanged:!1},children:o.children})]})}function De({value:o,onChange:r}){const n=s.jsx("fieldset",{children:s.jsx(_.FormLayout,{layout:"vertical",children:s.jsx(e.FormItem,{label:T("Negotiation"),children:s.jsxs(S.Radio.Group,{value:o,onChange:r,children:[s.jsx(S.Radio,{value:1,children:s.jsxs(S.Tooltip,{title:T("Everyone should pass"),placement:"bottom",children:[s.jsx("span",{children:T("All pass")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:-1,children:s.jsxs(S.Tooltip,{title:T("Anyone pass"),placement:"bottom",children:[s.jsx("span",{children:T("Any pass")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return s.jsxs("fieldset",{className:e.css`
|
|
6
15
|
.ant-radio-group {
|
|
7
16
|
.anticon {
|
|
8
17
|
margin-left: 0.5em;
|
|
9
18
|
}
|
|
10
19
|
}
|
|
11
|
-
`,children:[s.jsx(S.Form.Item,{children:s.jsxs(S.Radio.Group,{value:!!t,onChange:({target:{value:o}})=>{console.log(o),r(Number(o))},children:[s.jsx(S.Radio,{value:!0,children:s.jsxs(S.Tooltip,{title:B("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:B("Separately")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:!1,children:s.jsxs(S.Tooltip,{title:B("Everyone shares one task"),placement:"bottom",children:[s.jsx("span",{children:B("Collaboratively")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),t?n:null]})}function Oe(t){return t.isForeignKey?t.target==="users":t.collectionName==="users"&&t.name==="id"}function Ve({multiple:t=!1,value:r=[],onChange:n}){const o=c.useWorkflowVariableOptions({types:[Oe]});return s.jsx(e.Variable.Input,{scope:o,value:r[0],onChange:i=>{n([i])},children:s.jsx(e.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:r[0],onChange:i=>{n(i!=null?[i]:[])}})})}class Pe extends c.Instruction{constructor(){super(...arguments);E(this,"title",`{{t("Manual", { ns: "${g}" })}}`);E(this,"type","manual");E(this,"group","manual");E(this,"description",`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${g}" })}}`);E(this,"fieldset",{assignees:{type:"array",title:`{{t("Assignees", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}});E(this,"components",{SchemaConfigButton:ze,SchemaConfig:Te,ModeConfig:De,AssigneesSelect:Ve})}useVariables({key:n,title:o,config:i},{types:a,fieldNames:l=c.defaultFieldNames}){var d;const p=e.useCompile(),{getCollectionFields:u}=e.useCollectionManager_deprecated(),m=Object.keys((d=i.forms)!=null?d:{});if(!m.length)return null;const f=m.map(C=>{var I;const k=i.forms[C],v=c.getCollectionFieldOptions({fields:(I=k.collection)==null?void 0:I.fields,collection:k.collection,types:a,compile:p,getCollectionFields:u}),F=p(k.title)||C;return v.length?{key:C,value:C,label:F,title:F,children:v}:null}).filter(Boolean);return f.length?{[l.value]:n,[l.label]:o,[l.children]:f}:null}useInitializers(n){var l;const{getCollection:o}=e.useCollectionManager_deprecated(),i=Object.keys((l=n.config.forms)!=null?l:{});if(!i.length||n.config.mode)return null;const a=i.map(p=>{var f,d;const u=n.config.forms[p],{fields:m=[]}=o(u.collection);return m.length?{name:(f=u.title)!=null?f:p,type:"item",title:(d=u.title)!=null?d:p,Component:c.CollectionBlockInitializer,collection:u.collection,dataPath:`$jobsMapByNodeKey.${n.key}.${p}`}:null}).filter(Boolean);return a.length?{name:`#${n.id}`,key:"forms",type:"subMenu",title:n.title,children:a}:null}isAvailable({engine:n,workflow:o,upstream:i,branchIndex:a}){return!n.isWorkflowSync(o)}}const je={title:`{{t("Task", { ns: "${g}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Ne={title:`{{t("Workflow", { ns: "${g}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},$e={title:`{{t("Workflow todos", { ns: "${g}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${g}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${g}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${g}" })}}`,"x-component":"Select",enum:c.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Ee=b.observer(()=>{var r,n,o;const t=b.useField();return(o=(r=t==null?void 0:t.value)==null?void 0:r.title)!=null?o:`#${(n=t.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),Ue=b.observer(()=>{var r,n,o;const t=b.useField();return(o=(r=t==null?void 0:t.value)==null?void 0:r.title)!=null?o:`#${(n=t.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),_e=b.observer(()=>{var r,n,o;const t=b.useField();return(o=(r=t==null?void 0:t.value)==null?void 0:r.nickname)!=null?o:(n=t.value)==null?void 0:n.id},{displayName:"UserColumn"});function Ke(t){const r=e.useRecord(),n=B("Unprocessed");return r.execution.status&&!r.status?s.jsx(S.Tag,{children:n}):t.children}const H=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:Ee,WorkflowColumn:Ue,UserColumn:_e,UserJobStatusColumn:Ke},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: "${g}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${g}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Je(t){var m;const{data:r}=e.useCurrentUserContext(),{userJob:n}=c.useFlowContext(),{status:o,result:i,userId:a}=n,l=b.useFieldSchema(),{name:p}=l.parent.toJSON();let{children:u}=t;return o?i[p]||(u=null):((m=r==null?void 0:r.data)==null?void 0:m.id)!==a&&(u=null),u}const le=h.createContext(null);le.displayName="ManualActionStatusContext";function qe({value:t,children:r}){const{userJob:n,execution:o}=c.useFlowContext(),i=b.useField(),a=b.useFieldSchema();return h.useEffect(()=>{(o.status||n.status)&&(i.disabled=!0,i.visible=n.status===t&&n.result._===a.name)},[o,n,t,i,a.name]),s.jsx(le.Provider,{value:t,children:r})}function Ge(){const t=e.useAPIClient(),{setVisible:r}=e.useActionContext(),{values:n,submit:o}=b.useForm(),i=b.useFieldSchema(),{service:a}=e.useTableBlockContext(),{userJob:l,execution:p}=c.useFlowContext(),{name:u}=i,{name:m}=i.parent.parent;return{run(){return U(this,null,function*(){p.status||l.status||(yield o(),yield t.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[m]:n,_:u}}}),r(!1),a.refresh())})}}}function Le(t){var f;const r=e.usePlugin(c),n=e.useAPIClient(),{id:o}=e.useRecord(),[i,a]=h.useState(null),[l,p]=h.useState(null);h.useEffect(()=>{var d,C;o&&((C=(d=n.resource("users_jobs")).get)==null||C.call(d,{filterByTk:o,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:k})=>{var V;const M=(V=k==null?void 0:k.data)!=null?V:{},{node:v,workflow:P={}}=M,z=P,{nodes:F=[]}=z,I=$(z,["nodes"]),G=M,{execution:T}=G,A=$(G,["node","workflow","execution"]);c.linkNodes(F),p(v),a({userJob:A,workflow:I,nodes:F,execution:T})}))},[n,o]);const m=c.useAvailableUpstreams(i==null?void 0:i.nodes.find(d=>d.id===l.id)).reduce((d,{type:C})=>Object.assign(d,r.instructions.get(C).components),{});return l&&i?s.jsx(c.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:y(y({FormBlockProvider:Z,DetailsBlockProvider:c.DetailsBlockProvider,ActionBarProvider:Je,ManualActionStatusProvider:qe},Array.from(O.getValues()).reduce((d,C)=>Object.assign(d,C.block.components),{})),m),scope:y({useSubmit:Ge,useFormBlockProps:Ye,useDetailsBlockProps:Qe},Array.from(O.getValues()).reduce((d,C)=>Object.assign(d,C.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(f=l.config)==null?void 0:f.schema}})}):s.jsx(S.Spin,{})}function Ye(){var l;const{userJob:t,execution:r}=c.useFlowContext(),n=e.useRecord(),{data:o}=e.useCurrentUserContext(),{form:i}=e.useFormBlockContext(),a=r.status||t.status?n?"readPretty":"disabled":((l=o==null?void 0:o.data)==null?void 0:l.id)!==t.userId?"disabled":"editable";return h.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Qe(){const{form:t}=e.useFormBlockContext();return{form:t}}function He(){const t=e.useCompile(),{status:r,updatedAt:n}=e.useRecord(),o=c.JobStatusOptionsMap[r];return r?s.jsxs(S.Space,{children:[s.jsx("time",{className:e.css`
|
|
20
|
+
`,children:[s.jsx(S.Form.Item,{children:s.jsxs(S.Radio.Group,{value:!!o,onChange:({target:{value:t}})=>{console.log(t),r(Number(t))},children:[s.jsx(S.Radio,{value:!0,children:s.jsxs(S.Tooltip,{title:T("Each user has own task"),placement:"bottom",children:[s.jsx("span",{children:T("Separately")}),s.jsx(q.QuestionCircleOutlined,{style:{color:"#999"}})]})}),s.jsx(S.Radio,{value:!1,children:s.jsxs(S.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 Oe(o){return o.isForeignKey?o.target==="users":o.collectionName==="users"&&o.name==="id"}function Ve({multiple:o=!1,value:r=[],onChange:n}){const t=c.useWorkflowVariableOptions({types:[Oe]});return s.jsx(e.Variable.Input,{scope:t,value:r[0],onChange:i=>{n([i])},children:s.jsx(e.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:r[0],onChange:i=>{n(i!=null?[i]:[])}})})}class Pe extends c.Instruction{constructor(){super(...arguments);E(this,"title",`{{t("Manual", { ns: "${g}" })}}`);E(this,"type","manual");E(this,"group","manual");E(this,"description",`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${g}" })}}`);E(this,"fieldset",{assignees:{type:"array",title:`{{t("Assignees", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${g}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}});E(this,"components",{SchemaConfigButton:ze,SchemaConfig:Te,ModeConfig:De,AssigneesSelect:Ve})}useVariables({key:n,title:t,config:i},{types:a,fieldNames:p=c.defaultFieldNames}){var l;const d=e.useCompile(),{getCollectionFields:u}=e.useCollectionManager_deprecated(),m=Object.keys((l=i.forms)!=null?l:{});if(!m.length)return null;const f=m.map(x=>{var I;const F=i.forms[x],v=c.getCollectionFieldOptions({fields:(I=F.collection)==null?void 0:I.fields,collection:F.collection,types:a,compile:d,getCollectionFields:u}),k=d(F.title)||x;return v.length?{key:x,value:x,label:k,title:k,children:v}:null}).filter(Boolean);return f.length?{[p.value]:n,[p.label]:t,[p.children]:f}:null}useInitializers(n){var p;const{getCollection:t}=e.useCollectionManager_deprecated(),i=Object.keys((p=n.config.forms)!=null?p:{});if(!i.length||n.config.mode)return null;const a=i.map(d=>{var f,l;const u=n.config.forms[d],{fields:m=[]}=t(u.collection);return m.length?{name:(f=u.title)!=null?f:d,type:"item",title:(l=u.title)!=null?l:d,Component:c.CollectionBlockInitializer,collection:u.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 je={title:`{{t("Task", { ns: "${g}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Ne={title:`{{t("Workflow", { ns: "${g}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},$e={title:`{{t("Workflow todos", { ns: "${g}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${g}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${g}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${g}" })}}`,"x-component":"Select",enum:c.JobStatusOptions}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Ee=b.observer(()=>{var r,n,t;const o=b.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),Ue=b.observer(()=>{var r,n,t;const o=b.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.title)!=null?t:`#${(n=o.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),_e=b.observer(()=>{var r,n,t;const o=b.useField();return(t=(r=o==null?void 0:o.value)==null?void 0:r.nickname)!=null?t:(n=o.value)==null?void 0:n.id},{displayName:"UserColumn"});function Ke(o){const r=e.useRecord(),n=T("Unprocessed");return r.execution.status&&!r.status?s.jsx(S.Tag,{children:n}):o.children}const Q=()=>s.jsx(e.SchemaComponent,{components:{NodeColumn:Ee,WorkflowColumn:Ue,UserColumn:_e,UserJobStatusColumn:Ke},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: "${g}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status", { ns: "workflow" })}}',properties:{status:{type:"number","x-decorator":"UserJobStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:`{{t("Assignee", { ns: "${g}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}}});function Je(o){var m;const{data:r}=e.useCurrentUserContext(),{userJob:n}=c.useFlowContext(),{status:t,result:i,userId:a}=n,p=b.useFieldSchema(),{name:d}=p.parent.toJSON();let{children:u}=o;return t?i[d]||(u=null):((m=r==null?void 0:r.data)==null?void 0:m.id)!==a&&(u=null),u}const ce=h.createContext(null);ce.displayName="ManualActionStatusContext";function qe({value:o,children:r}){const{userJob:n,execution:t}=c.useFlowContext(),i=b.useField(),a=b.useFieldSchema();return h.useEffect(()=>{(t.status||n.status)&&(i.disabled=!0,i.visible=n.status===o&&n.result._===a.name)},[t,n,o,i,a.name]),s.jsx(ce.Provider,{value:o,children:r})}function Ge(){const o=e.useAPIClient(),{setVisible:r}=e.useActionContext(),{values:n,submit:t}=b.useForm(),i=b.useFieldSchema(),{service:a}=e.useTableBlockContext(),{userJob:p,execution:d}=c.useFlowContext(),{name:u}=i,{name:m}=i.parent.parent;return{run(){return U(this,null,function*(){d.status||p.status||(yield t(),yield o.resource("users_jobs").submit({filterByTk:p.id,values:{result:{[m]:n,_:u}}}),r(!1),a.refresh())})}}}function Le(o){var f;const r=e.usePlugin(c),n=e.useAPIClient(),{id:t}=e.useRecord(),[i,a]=h.useState(null),[p,d]=h.useState(null);h.useEffect(()=>{var l,x;t&&((x=(l=n.resource("users_jobs")).get)==null||x.call(l,{filterByTk:t,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:F})=>{var z;const B=(z=F==null?void 0:F.data)!=null?z:{},{node:v,workflow:N={}}=B,P=N,{nodes:k=[]}=P,I=$(P,["nodes"]),le=B,{execution:M}=le,A=$(le,["node","workflow","execution"]);c.linkNodes(k),d(v),a({userJob:A,workflow:I,nodes:k,execution:M})}))},[n,t]);const m=c.useAvailableUpstreams(i==null?void 0:i.nodes.find(l=>l.id===p.id)).reduce((l,{type:x})=>Object.assign(l,r.instructions.get(x).components),{});return p&&i?s.jsx(c.FlowContext.Provider,{value:i,children:s.jsx(e.SchemaComponent,{components:y(y({FormBlockProvider:X,DetailsBlockProvider:c.DetailsBlockProvider,ActionBarProvider:Je,ManualActionStatusProvider:qe},Array.from(O.getValues()).reduce((l,x)=>Object.assign(l,x.block.components),{})),m),scope:y({useSubmit:Ge,useFormBlockProps:Ye,useDetailsBlockProps:Qe},Array.from(O.getValues()).reduce((l,x)=>Object.assign(l,x.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(f=p.config)==null?void 0:f.schema}})}):s.jsx(S.Spin,{})}function Ye(){var p;const{userJob:o,execution:r}=c.useFlowContext(),n=e.useRecord(),{data:t}=e.useCurrentUserContext(),{form:i}=e.useFormBlockContext(),a=r.status||o.status?n?"readPretty":"disabled":((p=t==null?void 0:t.data)==null?void 0:p.id)!==o.userId?"disabled":"editable";return h.useEffect(()=>{i==null||i.setPattern(a)},[a,i]),{form:i}}function Qe(){const{form:o}=e.useFormBlockContext();return{form:o}}function He(){const o=e.useCompile(),{status:r,updatedAt:n}=e.useRecord(),t=c.JobStatusOptionsMap[r];return r?s.jsxs(S.Space,{children:[s.jsx("time",{className:e.css`
|
|
12
21
|
margin-right: 0.5em;
|
|
13
|
-
`,children:ue(n).format("YYYY-MM-DD HH:mm:ss")}),s.jsx(S.Tag,{icon:
|
|
22
|
+
`,children:ue(n).format("YYYY-MM-DD HH:mm:ss")}),s.jsx(S.Tag,{icon:t.icon,color:t.color,children:o(t.label)})]}):null}function Xe(){var a;const o=h.useContext(e.SchemaComponentContext),{id:r,node:n,workflow:t,status:i}=e.useRecord();return s.jsx(e.SchemaComponentContext.Provider,{value:w(y({},o),{reset(){},designable:!1}),children:s.jsx(e.SchemaComponent,{components:{FooterStatus:He,FlowContextProvider:Le},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 Ze({params:o={},children:r}){const n={collection:"users_jobs",resource:"users_jobs",action:"list",params:w(y({pageSize:20,sort:["-createdAt"]},o),{appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return s.jsx(e.ExtendCollectionsProvider,{collections:[je,Ne,$e],children:s.jsx(e.TableBlockProvider,w(y({name:"workflow-todo"},n),{children:r}))})}Q.Drawer=Xe,Q.Decorator=Ze;const We=()=>{const o=e.useSchemaInitializerItem(),{insert:r}=e.useSchemaInitializer();return s.jsx(e.SchemaInitializerItem,w(y({icon:s.jsx(q.TableOutlined,{})},o),{onClick:()=>{r({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class Re extends e.Plugin{afterAdd(){return U(this,null,function*(){})}load(){return U(this,null,function*(){this.addComponents(),this.app.pm.get("workflow").registerInstruction("manual",Pe),this.app.schemaInitializerManager.add(se),this.app.schemaInitializerManager.add(ke),this.app.schemaInitializerManager.add(ae),this.app.schemaInitializerManager.add(Ae),this.app.schemaInitializerManager.add(te),this.app.schemaInitializerManager.add(be),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflowTodos",{title:`{{t("Workflow todos", { ns: "${g}" })}}`,Component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"})})}addComponents(){this.app.addComponents({WorkflowTodo:Q,WorkflowTodoBlockInitializer:We})}}C.default=Re,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import React from 'react';
|
|
2
10
|
export declare function AssigneesSelect({ multiple, value, onChange }: {
|
|
3
11
|
multiple?: boolean;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import React from 'react';
|
|
2
10
|
export declare function FormBlockInitializer(): React.JSX.Element;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import React from 'react';
|
|
2
10
|
export declare function FormBlockProvider(props: any): React.JSX.Element;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import React from 'react';
|
|
2
10
|
export declare function ModeConfig({ value, onChange }: {
|
|
3
11
|
value: any;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { ISchema } from '@formily/react';
|
|
2
10
|
import React from 'react';
|
|
3
11
|
import { CompatibleSchemaInitializer, SchemaInitializerItemType } from '@nocobase/client';
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export declare function createManualFormBlockUISchema(options: any): import("@formily/json-schema").Stringify<{
|
|
2
10
|
[key: symbol]: any;
|
|
3
11
|
[key: `x-${string}`]: any;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { ManualFormType } from '../SchemaConfig';
|
|
2
10
|
declare const _default: ManualFormType;
|
|
3
11
|
export default _default;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { CompatibleSchemaInitializer } from '@nocobase/client';
|
|
2
10
|
import { ManualFormType } from '../SchemaConfig';
|
|
3
11
|
/**
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { ManualFormType } from '../SchemaConfig';
|
|
2
10
|
declare const _default: ManualFormType;
|
|
3
11
|
export default _default;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { SchemaInitializerItemType } from '@nocobase/client';
|
|
2
10
|
import { Instruction } from '@nocobase/plugin-workflow/client';
|
|
3
11
|
import { SchemaConfig, SchemaConfigButton } from './SchemaConfig';
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export declare function findSchema(schema: any, filter: any, onlyLeaf?: boolean): any[];
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
module.exports = {
|
|
2
11
|
"@formily/react": "2.3.0",
|
|
3
12
|
"antd": "5.12.8",
|
|
4
13
|
"dayjs": "1.11.10",
|
|
5
14
|
"react": "18.2.0",
|
|
6
|
-
"@nocobase/client": "0.
|
|
7
|
-
"@nocobase/plugin-workflow": "0.
|
|
15
|
+
"@nocobase/client": "1.0.0-alpha.10",
|
|
16
|
+
"@nocobase/plugin-workflow": "1.0.0-alpha.10",
|
|
8
17
|
"@ant-design/icons": "5.2.6",
|
|
9
18
|
"react-i18next": "11.18.6",
|
|
10
|
-
"@nocobase/utils": "0.
|
|
11
|
-
"@nocobase/server": "0.
|
|
12
|
-
"@nocobase/actions": "0.
|
|
13
|
-
"@nocobase/resourcer": "0.
|
|
14
|
-
"@nocobase/plugin-workflow-test": "0.
|
|
15
|
-
"@nocobase/test": "0.
|
|
19
|
+
"@nocobase/utils": "1.0.0-alpha.10",
|
|
20
|
+
"@nocobase/server": "1.0.0-alpha.10",
|
|
21
|
+
"@nocobase/actions": "1.0.0-alpha.10",
|
|
22
|
+
"@nocobase/resourcer": "1.0.0-alpha.10",
|
|
23
|
+
"@nocobase/plugin-workflow-test": "1.0.0-alpha.10",
|
|
24
|
+
"@nocobase/test": "1.0.0-alpha.10",
|
|
16
25
|
"@formily/core": "2.3.0",
|
|
17
26
|
"@formily/antd-v5": "1.1.9",
|
|
18
|
-
"@nocobase/database": "0.
|
|
27
|
+
"@nocobase/database": "1.0.0-alpha.10",
|
|
19
28
|
"lodash": "4.17.21"
|
|
20
29
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export * from './server';
|
|
2
10
|
export { default } from './server';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
export declare const NAMESPACE = "workflow-manual";
|
|
2
10
|
export declare function useLang(key: string, options?: {}): string;
|
|
3
11
|
export declare const lang: typeof useLang;
|
package/dist/locale/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __defProp = Object.defineProperty;
|
|
2
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Registry } from '@nocobase/utils';
|
|
2
10
|
import WorkflowPlugin, { Processor, Instruction } from '@nocobase/plugin-workflow';
|
|
3
11
|
import { FormHandler } from './forms';
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -100,14 +109,17 @@ class ManualInstruction_default extends import_plugin_workflow.Instruction {
|
|
|
100
109
|
formTypes = new import_utils.Registry();
|
|
101
110
|
async run(node, prevJob, processor) {
|
|
102
111
|
const { mode, ...config } = node.config;
|
|
103
|
-
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id)
|
|
112
|
+
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id).flat().filter(Boolean))];
|
|
104
113
|
const job = await processor.saveJob({
|
|
105
|
-
status: import_plugin_workflow.JOB_STATUS.PENDING,
|
|
114
|
+
status: assignees.length ? import_plugin_workflow.JOB_STATUS.PENDING : import_plugin_workflow.JOB_STATUS.RESOLVED,
|
|
106
115
|
result: mode ? [] : null,
|
|
107
116
|
nodeId: node.id,
|
|
108
117
|
nodeKey: node.key,
|
|
109
118
|
upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
|
|
110
119
|
});
|
|
120
|
+
if (!assignees.length) {
|
|
121
|
+
return job;
|
|
122
|
+
}
|
|
111
123
|
const UserJobModel = this.workflow.app.db.getModel("users_jobs");
|
|
112
124
|
await UserJobModel.bulkCreate(
|
|
113
125
|
assignees.map((userId) => ({
|
|
@@ -126,7 +138,8 @@ class ManualInstruction_default extends import_plugin_workflow.Instruction {
|
|
|
126
138
|
}
|
|
127
139
|
async resume(node, job, processor) {
|
|
128
140
|
var _a;
|
|
129
|
-
const {
|
|
141
|
+
const { mode } = node.config;
|
|
142
|
+
const assignees = [...new Set(processor.getParsedValue(node.config.assignees, node.id).flat().filter(Boolean))];
|
|
130
143
|
const UserJobModel = this.workflow.app.db.getModel("users_jobs");
|
|
131
144
|
const distribution = await UserJobModel.count({
|
|
132
145
|
where: {
|
package/dist/server/Plugin.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Plugin } from '@nocobase/server';
|
|
2
10
|
export default class extends Plugin {
|
|
3
11
|
load(): Promise<void>;
|
package/dist/server/Plugin.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
var __create = Object.create;
|
|
2
11
|
var __defProp = Object.defineProperty;
|
|
3
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
package/dist/server/actions.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
1
9
|
import { Context } from '@nocobase/actions';
|
|
2
10
|
export declare function submit(context: Context, next: any): Promise<never>;
|