@nocobase/plugin-workflow-manual 1.7.0-beta.9 → 1.8.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/WorkflowTodo.d.ts +5 -2
- package/dist/client/index.js +1 -1
- package/dist/common/constants.js +1 -1
- package/dist/externalVersion.js +10 -9
- package/dist/locale/en-US.json +6 -1
- package/dist/server/Plugin.d.ts +10 -0
- package/dist/server/Plugin.js +216 -13
- package/dist/server/actions.d.ts +1 -0
- package/dist/server/actions.js +26 -1
- package/dist/server/collections/workflowManualTasks.js +3 -1
- package/dist/server/migrations/20250426134102-tasks-stats.d.ts +13 -0
- package/dist/server/migrations/20250426134102-tasks-stats.js +124 -0
- package/package.json +2 -2
|
@@ -37,6 +37,7 @@ export declare function getWorkflowTodoViewActionSchema({ defaultOpenMode, colle
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
declare function Drawer(): React.JSX.Element;
|
|
40
41
|
declare function TaskItem(): React.JSX.Element;
|
|
41
42
|
declare function useTodoActionParams(status: any): {
|
|
42
43
|
filter: any;
|
|
@@ -46,8 +47,10 @@ declare function TodoExtraActions(): React.JSX.Element;
|
|
|
46
47
|
export declare const manualTodo: {
|
|
47
48
|
title: string;
|
|
48
49
|
collection: string;
|
|
50
|
+
action: string;
|
|
49
51
|
useActionParams: typeof useTodoActionParams;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
Actions: typeof TodoExtraActions;
|
|
53
|
+
Item: typeof TaskItem;
|
|
54
|
+
Detail: typeof Drawer;
|
|
52
55
|
};
|
|
53
56
|
export {};
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/plugin-workflow/client"),require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5"),require("react-i18next"),require("@nocobase/utils/client"),require("@formily/core"),require("lodash"),require("dayjs"),require("antd"),require("antd-style")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-manual",["@nocobase/plugin-workflow/client","@nocobase/client","@ant-design/icons","@formily/react","react","@formily/antd-v5","react-i18next","@nocobase/utils/client","@formily/core","lodash","dayjs","antd","antd-style"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-manual"]=t(require("@nocobase/plugin-workflow/client"),require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("react"),require("@formily/antd-v5"),require("react-i18next"),require("@nocobase/utils/client"),require("@formily/core"),require("lodash"),require("dayjs"),require("antd"),require("antd-style")):e["@nocobase/plugin-workflow-manual"]=t(e["@nocobase/plugin-workflow/client"],e["@nocobase/client"],e["@ant-design/icons"],e["@formily/react"],e.react,e["@formily/antd-v5"],e["react-i18next"],e["@nocobase/utils/client"],e["@formily/core"],e.lodash,e.dayjs,e.antd,e["antd-style"])}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,f){return function(){"use strict";var m={482:function(e){e.exports=n},632:function(e){e.exports=i},563:function(e){e.exports=c},505:function(e){e.exports=r},772:function(e){e.exports=t},433:function(t){t.exports=e},584:function(e){e.exports=l},721:function(e){e.exports=p},202:function(e){e.exports=f},760:function(e){e.exports=s},467:function(e){e.exports=u},156:function(e){e.exports=o},238:function(e){e.exports=a}},d={};function y(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return m[e](n,n.exports,y),n.exports}y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},y.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var v={};y.r(v),y.d(v,{default:function(){return tF}});var b=y("772"),h=y("156"),g=y.n(h),x=y("482"),w=y("433"),S=y.n(w),O=y("632"),k=y("563"),C=y("505"),j=y("721"),P=y("238"),A=y("584"),E="workflow-manual",I=0,F=1,T=-1,D=[{value:I,label:'{{t("Pending", { ns: "workflow" })}}',color:"gold"},{value:F,label:'{{t("Resolved", { ns: "workflow" })}}',color:"green"},{value:T,label:'{{t("Rejected", { ns: "workflow" })}}',color:"red"}],M=D.reduce(function(e,t){var n,r,o;return Object.assign(e,(n={},r=t.value,o=t,r in n?Object.defineProperty(n,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[r]=o,n))},{});function B(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,R(t).t)(e)}function R(e){return(0,P.useTranslation)(E,e)}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function V(e){var t,n,r,o,i,a,l=(0,b.useCollectionRecordData)(),c=(0,C.useFieldSchema)(),u=(0,C.useField)(),s=(0,h.useRef)(null),p=e.dataSource||b.DEFAULT_DATA_SOURCE_KEY,f=j.theme.useToken().token,m=(0,(0,b.useAssociationNames)(p).getAssociationAppends)(),d=m.appends,y=m.updateAssociationValues;var v=(t=Object.keys(null!==(a=c.toJSON().properties)&&void 0!==a?a:{}),n=1,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(t,1)||function(e,t){if(e){if("string"==typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(e,t)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],x=null==l?void 0:null===(i=l.result)||void 0===i?void 0:i[v],w=(0,h.useMemo)(function(){return(0,k.createForm)({initialValues:x})},[x]),S=(0,h.useMemo)(function(){return N({appends:d},e.params)},[d,e.params]),O=(0,h.useMemo)(function(){return{loading:!1,data:{data:x}}},[x]),P=(0,b.useAPIClient)(),A=(0,b.useDataSourceHeaders)(p),E=P.resource(e.collection,void 0,A),I=(0,b.useBlockRequestContext)(),F=(0,h.useMemo)(function(){return{params:S,form:w,field:u,service:O,updateAssociationValues:y,formBlockRef:s}},[u,w,S,O,y]);return(null==l?void 0:l.status)&&!x?null:g().createElement(b.CollectionManagerProvider,{dataSource:p},g().createElement(b.CollectionProvider_deprecated,{collection:e.collection},g().createElement(b.BlockProvider,(r=N({name:e.name||"form"},e),o=(o={block:"form",parentRecord:null},o),Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r),g().createElement(b.FormActiveFieldsProvider,{name:"form"},g().createElement(b.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:e,field:u,service:O,resource:E,__parent:I}},g().createElement(b.FormBlockContext.Provider,{value:F},g().createElement(b.RecordProvider,{record:x,parent:null},g().createElement(b.FormV2.Templates,{style:{marginBottom:f.margin},form:w}),g().createElement("div",{ref:s},e.children))))))))}var _=y("467"),U=y.n(_);function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function W(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function G(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function L(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function J(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return q(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e){var t=e.schema,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}(e,["schema"]),r=(0,b.useSchemaTemplateManager)().getTemplateSchemaByMode,o=(0,b.useSchemaInitializer)().insert,i=(0,b.useRecordCollectionDataSourceItems)("FormItem");function a(){var e;return e=function(e){var n,i,a,l,c,u,s;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(p){switch(p.label){case 0:if(!(n=e.item).template)return[3,2];return[4,r(n)];case 1:return l=p.sent(),[3,3];case 2:l=null,p.label=3;case 3:var f;return a=l,f=L(G({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:'{{t("Continue the process", { ns: "'.concat(E,'" })}}'),"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:w.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:a}),c=(0,b.createFormBlockSchema)(f),delete c["x-acl-action-props"],delete c["x-acl-action"],u=J(Object.keys(c.properties),1)[0],s=(null===(i=Object.entries(c.properties[u].properties).find(function(e){var t=J(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))||void 0===i?void 0:i[0])||"actions",c.properties[u].properties[s]["x-decorator"]="ActionBarProvider",c.properties[u].properties[s]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},(0,w.traverseSchema)(c,function(e){e["x-uid"]&&delete e["x-uid"]}),o(c),[2]}})},(a=function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){W(i,r,o,a,l,"next",e)}function l(e){W(i,r,o,a,l,"throw",e)}a(void 0)})}).apply(this,arguments)}return g().createElement(b.SchemaInitializerItem,L(G({},n),{onClick:function(e){return a.apply(this,arguments)},items:i}))}function K(){var e,t,n=(0,b.useSchemaInitializerItem)();return g().createElement(b.CollectionProvider_deprecated,{dataSource:null===(e=n.schema)||void 0===e?void 0:e.dataSource,collection:null===(t=n.schema)||void 0===t?void 0:t.collection},g().createElement($,n))}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Q(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[];return e?!t(e)||n&&e.properties?(e.properties&&Object.keys(e.properties).forEach(function(n){var o;r.push.apply(r,function(e){if(Array.isArray(e))return Y(e)}(o=Q(e.properties[n],t))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,t){if(e){if("string"==typeof e)return Y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Y(e,t)}}(o)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}),r):(r.push(e),r):r}function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function X(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return H(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return H(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ee(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function et(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ee(i,r,o,a,l,"next",e)}function l(e){ee(i,r,o,a,l,"throw",e)}a(void 0)})}}function en(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function er(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){en(e,t,n[t])})}return e}function eo(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function ei(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||ea(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ea(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}function el(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function ec(e){var t,n,r,o,i=ei((0,h.useState)(null!==(r=null===(t=e.collection)||void 0===t?void 0:t.fields)&&void 0!==r?r:[]),2),a=i[0],l=i[1],c=(0,b.useCollectionRecordData)(),u=(0,C.useField)(),s=ei(Object.keys(null!==(o=(0,C.useFieldSchema)().toJSON().properties)&&void 0!==o?o:{}),1)[0],p=null==c?void 0:null===(n=c.result)||void 0===n?void 0:n[s],f=(0,h.useMemo)(function(){return(0,k.createForm)({initialValues:p})},[p]);return(null==c?void 0:c.status)&&!p?null:g().createElement(b.CollectionProvider_deprecated,{collection:eo(er({},e.collection),{fields:a})},g().createElement(b.RecordProvider,{record:p,parent:null},g().createElement(b.FormBlockContext.Provider,{value:{form:f,field:u,setCollectionFields:l}},e.children)))}function eu(){var e=(0,b.useSchemaInitializer)().insert,t=(0,b.useSchemaInitializerItem)();return g().createElement(b.SchemaInitializerItem,eo(er({},t),{onClick:function(){e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:(0,A.uid)(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:en({},(0,A.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: "'.concat(E,'" })}}'),"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:w.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}})})}}))}var es={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")}}'},ep=g().createContext({});function ef(){var e=(0,C.useForm)(),t=e.values,n=e.query,r=e.reset,o=[B("Field name existed in form")],i=(0,h.useContext)(ep),a=i.collection,l=i.interfaceOptions,c=i.setCollectionFields,u=i.insert,s=i.setCallback,p=i.setInterface;return{run:function(){return et(function(){var e,i,f,m,d,y,v;return el(this,function(b){var h;if(f=l.default,m=(0,A.uid)(),f.name=null!==(d=t.name)&&void 0!==d?d:m,f.uiSchema.title=null!==(y=null===(e=t.uiSchema)||void 0===e?void 0:e.title)&&void 0!==y?y:m,f.interface=l.name,null===(i=a.fields)||void 0===i?void 0:i.find(function(e){return e.name===f.name}))return n("name").take().setFeedback({type:"error",messages:o}),[2];return v=(0,A.merge)(f,t),c(((function(e){if(Array.isArray(e))return Z(e)})(h=a.fields)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(h)||ea(h)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([v])),u({name:f.name,type:f.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:v},"x-collection-field":"".concat(a.name,".").concat(f.name),"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),r(),s(null),p(null),[2]})})()}}}var em={wrap:b.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:function(e){var t,n,r=ei((0,h.useState)(null),2),o=r[0],i=r[1],a=ei((0,h.useState)(),2),l=a[0],c=a[1];var u=(n={},Object.keys(t=(0,b.useCollectionManager_deprecated)().interfaces).forEach(function(e){var r=t[e],o=r.group,i=void 0===o?"others":o;n[i]=n[i]||{},(0,_.set)(n,[i,e],r)}),Object.keys(es).filter(function(e){return["basic","choices","datetime","media"].includes(e)}).map(function(e){return{title:es[e],children:Object.keys(n[e]||{}).map(function(t){var r=n[e][t];return er({value:t,title:r.title,name:t},n[e][t])}).sort(function(e,t){return e.order-t.order})}})).map(function(e){return{name:e.title,type:"itemGroup",title:e.title,children:e.children.map(function(e){return{name:e.name,type:"item",title:e.title,Component:ev,fieldInterface:e.name}})}}),s=(0,b.useCollection_deprecated)(),p=(0,h.useContext)(b.FormBlockContext).setCollectionFields,f=(0,h.useMemo)(function(){return(0,k.createForm)()},[]);return g().createElement(ep.Provider,{value:{collection:s,insert:l,interfaceOptions:o,onAddField:function(e){var t=(0,_.pick)(e,["name","group","title","default","validateSchema"]),n=e.properties,r=(n.unique,n.type,n.layout,n.autoIncrement,function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}(e.properties,["unique","type","layout","autoIncrement"]));t.properties=r;var o=(0,_.cloneDeep)(t);delete o.properties.name["x-disabled"],i(o)},setCallback:c,setInterface:i,setCollectionFields:p}},g().createElement(b.SchemaInitializerItems,eo(er({},e),{items:u})),g().createElement(b.ActionContextProvider,{value:{visible:!!o,setVisible:function(e){!e&&i(null)}}},o?g().createElement(b.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:f},"x-component":"Action.Drawer",properties:eo(er({},o.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:function(){var e=(0,C.useForm)();return{run:function(){return et(function(){return el(this,function(t){return c(null),i(null),e.reset(),[2]})})()}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:ef}}}}})},components:{ArrayTable:O.ArrayTable}}):null))}},ed=new b.CompatibleSchemaInitializer(er({name:"AddCustomFormField"},em)),ey=new b.CompatibleSchemaInitializer(er({name:"workflowManual:customForm:configureFields"},em),ed);function ev(){var e=(0,b.useSchemaInitializerItem)(),t=(0,b.useSchemaInitializer)().insert,n=(0,h.useContext)(ep),r=n.onAddField,o=n.setCallback,i=(0,(0,b.useCollectionManager_deprecated)().getInterface)(e.fieldInterface);return g().createElement(b.SchemaInitializerItem,er({key:e.fieldInterface,onClick:function(){o(function(){return t}),r(i)}},e))}function eb(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eh(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eb(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eg={title:'{{t("Update record form", { ns: "'.concat(E,'" })}}'),config:{useInitializer:function(e){var t=e.allCollections,n=(0,h.useMemo)(function(){return t.map(function(e){var t=e.key;return{key:t,name:t,label:e.displayName,type:"subMenu",children:e.collections.map(function(e){return{name:U().camelCase("updateRecordForm-child-".concat(e.name)),type:"item",title:e.title||e.tableName,schema:{collection:e.name,dataSource:t,title:'{{t("Update record", { ns: "'.concat(E,'" })}}'),formType:"update","x-designer":"UpdateFormDesigner"},Component:K}})}})},[t]),r=eh((0,h.useState)([]),2),o=r[0],i=r[1],a=(0,b.useMenuSearch)({data:n,openKeys:o});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:'{{t("Update record form", { ns: "'.concat(E,'" })}}'),componentProps:{onOpenChange:function(e){i(e)}},children:a}},initializers:{},components:{FilterDynamicComponent:w.FilterDynamicComponent,UpdateFormDesigner:function(){var e=(0,b.useCollection_deprecated)(),t=e.name,n=e.title,r=(0,C.useFieldSchema)(),o=(0,P.useTranslation)().t,i=(0,b.useDesignable)().dn;return g().createElement(b.GeneralSchemaDesigner,{title:n||t},g().createElement(b.SchemaSettingsBlockTitleItem,null),g().createElement(b.SchemaSettingsActionModalItem,{title:o("Filter settings",{ns:E}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":function(){var e;return{options:(0,b.useCollectionFilterOptions)(null==r?void 0:null===(e=r["x-decorator-props"])||void 0===e?void 0:e.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:null==r?void 0:r["x-decorator-props"],onSubmit:function(e){var t=e.filter;r["x-decorator-props"].filter=t,i.emit("patch",{schema:{"x-decorator-props":r["x-decorator-props"]}}),i.refresh()},width:"60%"}),g().createElement(b.SchemaSettingsLinkageRules,{collectionName:t}),g().createElement(b.SchemaSettingsDivider,null),g().createElement(b.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}))}},parseFormOptions:function(e){var t={};return Q(e,function(e){return"FormBlockProvider"===e["x-decorator"]&&"update"===e["x-decorator-props"].formType}).forEach(function(e){var n,r,o,i,a=eh(Object.keys(e.properties),1)[0],l=e.properties[a],c=(null===(o=Object.entries(l.properties).find(function(e){var t=eh(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))||void 0===o?void 0:o[0])||"actions";t[a]=(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e["x-decorator-props"]),r=(r={type:"update",title:(null===(i=e["x-component-props"])||void 0===i?void 0:i.title)||a,actions:Q(l.properties[c],function(e){return"Action"===e["x-component"]}).map(function(e){var t,n;return{status:e["x-decorator-props"].value,values:null===(n=e["x-action-settings"])||void 0===n?void 0:null===(t=n.assignedValues)||void 0===t?void 0:t.values,key:e.name}})},r),Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n)}),t}},block:{scope:{},components:{}},validate:function(e){var t=e.filter;return t&&(0,A.isValidFilter)(t)?null:"Please check one of your update record form, and add at least one filter condition in form settings."}};function ex(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ew(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function eS(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eO(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}function ek(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||ej(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eC(e){return function(e){if(Array.isArray(e))return ex(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ej(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ej(e,t){if(e){if("string"==typeof e)return ex(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ex(e,t)}}var eP=new A.Registry;eP.register("custom",{title:'{{t("Custom form", { ns: "'.concat(E,'" })}}'),config:{useInitializer:function(){return{name:"customForm",type:"item",title:'{{t("Custom form", { ns: "'.concat(E,'" })}}'),Component:eu}},initializers:{},components:{CustomFormBlockProvider:ec},parseFormOptions:function(e){var t={};return Q(e,function(e){return"CustomFormBlockProvider"===e["x-decorator"]}).forEach(function(e){var n,r,o=ei(Object.keys(e.properties),1)[0],i=e.properties[o],a=Q(i.properties.grid,function(e){return"CollectionField"===e["x-component"]},!0);e["x-decorator-props"].collection.fields=a.map(function(e){var t,n;return null!==(n=null===(t=e["x-component-props"])||void 0===t?void 0:t.field)&&void 0!==n?n:e["x-interface-options"]});var l=(null===(n=Object.entries(i.properties).find(function(e){var t=ei(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))||void 0===n?void 0:n[0])||"actions";t[o]={type:"custom",title:(null===(r=e["x-component-props"])||void 0===r?void 0:r.title)||o,actions:Q(i.properties[l],function(e){return"Action"===e["x-component"]}).map(function(e){var t,n;return{status:e["x-decorator-props"].value,values:null===(n=e["x-action-settings"])||void 0===n?void 0:null===(t=n.assignedValues)||void 0===t?void 0:t.values,key:e.name}}),collection:e["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:ec}}}),eP.register("create",{title:'{{t("Create record form", { ns: "'.concat(E,'" })}}'),config:{useInitializer:function(e){var t=e.allCollections,n=(0,h.useMemo)(function(){return t.map(function(e){var t=e.key;return{key:t,name:t,label:e.displayName,type:"subMenu",children:e.collections.map(function(e){return{name:U().camelCase("createRecordForm-child-".concat(e.name)),type:"item",title:e.title||e.tableName,schema:{collection:e.name,dataSource:t,title:'{{t("Create record", { ns: "'.concat(E,'" })}}'),formType:"create","x-designer":"CreateFormDesigner"},Component:K}})}})},[t]),r=X((0,h.useState)([]),2),o=r[0],i=r[1],a=(0,b.useMenuSearch)({data:n,openKeys:o});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:'{{t("Create record form", { ns: "'.concat(E,'" })}}'),componentProps:{onOpenChange:function(e){i(e)}},children:a}},initializers:{},components:{CreateFormDesigner:function(){var e=(0,b.useCollection_deprecated)(),t=e.name,n=e.title;return g().createElement(b.GeneralSchemaDesigner,{title:n||t},g().createElement(b.SchemaSettingsBlockTitleItem,null),g().createElement(b.SchemaSettingsLinkageRules,{collectionName:t}),g().createElement(b.SchemaSettingsDataTemplates,{collectionName:t}),g().createElement(b.SchemaSettingsDivider,null),g().createElement(b.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}))}},parseFormOptions:function(e){var t={};return Q(e,function(e){return"FormBlockProvider"===e["x-decorator"]&&"create"===e["x-decorator-props"].formType}).forEach(function(e){var n,r,o=X(Object.keys(e.properties),1)[0],i=e.properties[o],a=(null===(n=Object.entries(i.properties).find(function(e){var t=X(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))||void 0===n?void 0:n[0])||"actions";t[o]={type:"create",title:(null===(r=e["x-component-props"])||void 0===r?void 0:r.title)||o,actions:Q(i.properties[a],function(e){return"Action"===e["x-component"]}).map(function(e){var t,n;return{status:e["x-decorator-props"].value,values:null===(n=e["x-action-settings"])||void 0===n?void 0:null===(t=n.assignedValues)||void 0===t?void 0:t.values,key:e.name}}),collection:e["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}}),eP.register("update",eg);var eA={wrap:b.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren:function(){var e,t,n=(0,b.usePlugin)(S()),r=(0,w.useNodeContext)(),o=(0,w.useAvailableUpstreams)(r);var i=[(e=(0,w.useFlowContext)().workflow,(t=(0,w.useTrigger)()).useInitializers?t.useInitializers(e.config):null)].filter(Boolean),a=o.map(function(e){var t,r=n.instructions.get(e.type);return null==r?void 0:null===(t=r.useInitializers)||void 0===t?void 0:t.call(r,e)}).filter(Boolean);return eC(i).concat(eC(a.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "'.concat(E,'" })}}'),children:a}]:[])).filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren:function(){var e=(0,b.useDataSourceManager)().getAllCollections();return Array.from(eP.getValues()).map(function(t){return(0,t.config.useInitializer)({allCollections:e})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},eE=new b.CompatibleSchemaInitializer(ew({name:"AddBlockButton"},eA)),eI=new b.CompatibleSchemaInitializer(ew({name:"workflowManual:popup:configureUserInterface:addBlock"},eA),eE);function eF(){var e,t,n,r=(0,h.useContext)(b.SchemaComponentContext),o=(0,P.useTranslation)().t,i=R().t,a=(0,C.useFieldSchema)(),l=(0,w.useWorkflowVariableOptions)(),c=ek((0,h.useState)(!1),2),u=c[0],s=c[1],p=ek((0,h.useState)(null!==(n=null==a?void 0:null===(t=a["x-action-settings"])||void 0===t?void 0:null===(e=t.assignedValues)||void 0===e?void 0:e.schema)&&void 0!==n?n:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),2),f=p[0],m=p[1],d=ek((0,h.useState)(null),2),y=d[0],v=d[1],x=(0,b.useSchemaOptionsContext)().components;(0,h.useEffect)(function(){v(new C.Schema({properties:{grid:f}}))},[f]);var S=(0,h.useMemo)(function(){var e,t,n=null==a?void 0:null===(t=a["x-action-settings"])||void 0===t?void 0:null===(e=t.assignedValues)||void 0===e?void 0:e.values;return(0,k.createForm)({initialValues:A.lodash.cloneDeep(n),values:A.lodash.cloneDeep(n)})},[a]),E=(0,b.useFormActiveFields)(),I=o("Assign field values");function F(){s(!1)}return g().createElement(g().Fragment,null,g().createElement(b.SchemaSettingsItem,{title:I,onClick:function(){return s(!0)}},I),g().createElement(j.Modal,{width:"50%",title:I,open:u,onCancel:F,footer:g().createElement(j.Space,null,g().createElement(j.Button,{onClick:F},i("Cancel")),g().createElement(j.Button,{type:"primary",onClick:function(){!a["x-action-settings"]&&(a["x-action-settings"]={}),!a["x-action-settings"].assignedValues&&(a["x-action-settings"].assignedValues={}),a["x-action-settings"].assignedValues.schema=f,a["x-action-settings"].assignedValues.values=S.values,s(!1),setTimeout(function(){var e;null===(e=r.refresh)||void 0===e||e.call(r)},300)}},i("Submit")))},g().createElement(b.DefaultValueProvider,{isAllowToSetDefaultValue:function(){return!1}},g().createElement(b.VariableScopeProvider,{scope:l},g().createElement(b.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:null==E?void 0:E.getActiveFieldsName},g().createElement(C.FormProvider,{form:S},g().createElement(O.FormLayout,{layout:"vertical"},g().createElement(j.Alert,{message:i("Values preset in this form will override user submitted ones when continue or reject.")}),g().createElement("br",null),u&&y&&g().createElement(b.SchemaComponentContext.Provider,{value:eS(ew({},r),{refresh:function(){m(A.lodash.get(y.toJSON(),"properties.grid"))}})},g().createElement(b.SchemaComponent,{schema:y,components:x})))))))))}function eT(e){return g().createElement(b.GeneralSchemaDesigner,eS(ew({},e),{disableInitializer:!0}),g().createElement(b.Action.Designer.ButtonEditor,null),g().createElement(eF,null),g().createElement(b.SchemaSettingsDivider,null),g().createElement(b.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}}))}function eD(){var e=(0,b.useSchemaInitializerItem)(),t=e.action,n=e.actionProps,r=eO(e,["action","actionProps"]);return g().createElement(b.InitializerWithSwitch,eS(ew({},r),{item:e,schema:{type:"void",title:r.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":eS(ew({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action":"".concat(t)},type:"x-action"}))}var eM={title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:'{{t("Continue the process", { ns: "'.concat(E,'" })}}'),Component:function(){var e=(0,b.useSchemaInitializerItem)(),t=e.action,n=e.actionProps,r=eO(e,["action","actionProps"]),o=(0,b.useSchemaInitializer)().insert;return g().createElement(b.SchemaInitializerItem,eS(ew({},r),{onClick:function(){o({type:"void",title:r.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:t},"x-component":"Action","x-component-props":eS(ew({},n),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))},action:w.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:'{{t("Terminate the process", { ns: "'.concat(E,'" })}}'),Component:eD,action:w.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:'{{t("Save temporarily", { ns: "'.concat(E,'" })}}'),Component:eD,action:w.JOB_STATUS.PENDING}]},eB=new b.CompatibleSchemaInitializer(ew({name:"AddActionButton"},eM)),eR=new b.CompatibleSchemaInitializer(ew({name:"workflowManual:form:configureActions"},eM),eB);function ez(){return{run:function(){}}}function eN(e){var t=e.value,n=e.onChange,r=(0,b.usePlugin)(S()),o=(0,h.useContext)(b.SchemaComponentContext),i=(0,w.useNodeContext)(),a=(0,w.useAvailableUpstreams)(i),l=(0,C.useForm)(),c=(0,w.useFlowContext)().workflow,u=(0,h.useRef)(function(){}),s={};a.forEach(function(e){Object.assign(s,r.instructions.get(e.type).components)});var p=(0,h.useMemo)(function(){return new C.Schema({properties:{drawer:{type:"void",title:'{{t("User interface", { ns: "'.concat(E,'" })}}'),"x-decorator":"Form","x-component":"Action.Container","x-component-props":{onClose:function(){return u.current()}},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:null!=t?t:{tab1:{type:"void",title:'{{t("Manual", { ns: "'.concat(E,'" })}}'),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}})},[]),f=(0,h.useCallback)(function(){var e=A.lodash.get(p.toJSON(),"properties.drawer.properties").tabs,t=Array.from(eP.getValues()).reduce(function(t,n){return Object.assign(t,n.config.parseFormOptions(e))},{});l.setValuesIn("forms",t),n(e.properties)},[l,n,p]);return u.current=f,g().createElement(b.SchemaComponentContext.Provider,{value:eS(ew({},o),{designable:!c.executed,refresh:f})},g().createElement(b.SchemaComponent,{schema:p,components:eS(ew({},s,Array.from(eP.getValues()).reduce(function(e,t){return Object.assign(e,t.config.components)},{})),{FormBlockProvider:V,DetailsBlockProvider:w.DetailsBlockProvider,ManualActionStatusProvider:function(e){return e.children},ActionBarProvider:function(e){return e.children},SimpleDesigner:w.SimpleDesigner,ManualActionDesigner:eT}),scope:{useSubmit:ez,useDetailsBlockProps:b.useFormBlockContext}}))}function eV(e){var t=(0,w.useFlowContext)().workflow,n=ek((0,h.useState)(!1),2),r=n[0],o=n[1],i=(0,C.useForm)().values,a=R().t,l=(0,h.useCallback)(function(e){if(!e){var t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!0,n=!1,r=void 0;try{for(var o,i=Object.values(e)[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value,l=eP.get(a.type);if("function"==typeof l.validate){var c=l.validate(a);if(c)return c}}}catch(e){n=!0,r=e}finally{try{!t&&null!=i.return&&i.return()}finally{if(n)throw r}}}(i.forms);if(t){j.message.error({content:a(t)});return}}o(e)},[i.forms]);return g().createElement(g().Fragment,null,g().createElement(j.Button,{type:"primary",onClick:function(){return o(!0)},disabled:!1},a(t.executed?"View user interface":"Configure user interface")),g().createElement(b.ActionContextProvider,{value:{visible:r,setVisible:l,formValueChanged:!1}},e.children))}function e_(){var e,t,n=(e=["\n .ant-radio-group {\n .anticon {\n margin-left: 0.5em;\n }\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return e_=function(){return n},n}function eU(e){var t,n=e.value,r=e.onChange;!(t=n)||t>=1;var o=g().createElement("fieldset",null,g().createElement(O.FormLayout,{layout:"vertical"},g().createElement(b.FormItem,{label:B("Negotiation")},g().createElement(j.Radio.Group,{value:n,onChange:r},g().createElement(j.Radio,{value:1},g().createElement(j.Tooltip,{title:B("Everyone should pass"),placement:"bottom"},g().createElement("span",null,B("All pass")),g().createElement(x.QuestionCircleOutlined,{style:{color:"#999"}}))),g().createElement(j.Radio,{value:-1},g().createElement(j.Tooltip,{title:B("Anyone pass"),placement:"bottom"},g().createElement("span",null,B("Any pass")),g().createElement(x.QuestionCircleOutlined,{style:{color:"#999"}})))))));return g().createElement("fieldset",{className:(0,b.css)(e_())},g().createElement(j.Form.Item,null,g().createElement(j.Radio.Group,{value:!!n,onChange:function(e){var t=e.target.value;console.log(t),r(Number(t))}},g().createElement(j.Radio,{value:!0},g().createElement(j.Tooltip,{title:B("Each user has own task"),placement:"bottom"},g().createElement("span",null,B("Separately")),g().createElement(x.QuestionCircleOutlined,{style:{color:"#999"}}))),g().createElement(j.Radio,{value:!1},g().createElement(j.Tooltip,{title:B("Everyone shares one task"),placement:"bottom"},g().createElement("span",null,B("Collaboratively")),g().createElement(x.QuestionCircleOutlined,{style:{color:"#999"}}))))),n?o:null)}function eq(e){return e.isForeignKey||"context"===e.type?"users"===e.target:"users"===e.collectionName&&"id"===e.name}function eW(e){e.multiple;var t=e.value,n=void 0===t?[]:t,r=e.onChange,o=(0,w.useWorkflowVariableOptions)({types:[eq]});return g().createElement(b.Variable.Input,{scope:o,value:n[0],onChange:function(e){r([e])}},g().createElement(b.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:n[0],onChange:function(e){r(null!=e?[e]:[])}}))}function eG(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function eL(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eJ(e){return(eJ=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function e$(e,t){return(e$=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eK(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eK=function(){return!!e})()}function eY(e,t){var n,r,o=e.key,i=e.title,a=e.config,l=t.types,c=t.fieldNames,u=void 0===c?w.defaultFieldNames:c,s=(0,b.useCompile)(),p=(0,b.useCollectionManager_deprecated)().getCollectionFields,f=Object.keys(null!==(n=a.forms)&&void 0!==n?n:{});if(!f.length)return null;var m=f.map(function(e){var t,n=a.forms[e],r=(0,w.getCollectionFieldOptions)({fields:null===(t=n.collection)||void 0===t?void 0:t.fields,collection:n.collection,types:l,compile:s,getCollectionFields:p}),o=s(n.title)||e;return r.length?{key:e,value:e,label:o,title:o,children:r}:null}).filter(Boolean);return m.length?(eL(r={},u.value,o),eL(r,u.label,i),eL(r,u.children,m),r):null}function eQ(e){var t,n=(0,b.useCollectionManager_deprecated)().getCollection,r=Object.keys(null!==(t=e.config.forms)&&void 0!==t?t:{});if(!r.length||e.config.mode)return null;var o=r.map(function(t){var r,o,i=e.config.forms[t],a=n(i.collection).fields;return(void 0===a?[]:a).length?{name:null!==(r=i.title)&&void 0!==r?r:t,type:"item",title:null!==(o=i.title)&&void 0!==o?o:t,Component:w.CollectionBlockInitializer,collection:i.collection,dataPath:"$jobsMapByNodeKey.".concat(e.key,".").concat(t)}:null}).filter(Boolean);return o.length?{name:"#".concat(e.id),key:"forms",type:"subMenu",title:e.title,children:o}:null}Symbol("single"),Symbol("all"),Symbol("any"),Symbol("all percentage"),Symbol("any percentage");var eH=function(e){var t,n,r;function o(){var e,t,n,r;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=eJ(n),eL(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,eK()?Reflect.construct(n,r||[],eJ(t).constructor):n.apply(t,r)),"title",'{{t("Manual", { ns: "'.concat(E,'" })}}')),eL(e,"type","manual"),eL(e,"group","manual"),eL(e,"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: "'.concat(E,'" })}}')),eL(e,"icon",g().createElement(x.SolutionOutlined,null)),eL(e,"fieldset",{assignees:{type:"array",title:'{{t("Assignees", { ns: "'.concat(E,'" })}}'),"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:'{{t("Mode", { ns: "'.concat(E,'" })}}'),"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},title:{type:"string",title:'{{t("Task title", { ns: "'.concat(E,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea",description:'{{t("Title of each task item. Default to node title.", { ns: "'.concat(E,'" })}}'),default:"{{useNodeContext().title}}"},schema:{type:"void",title:'{{t("User interface", { ns: "'.concat(E,'" })}}'),"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}}),eL(e,"scope",{useNodeContext:w.useNodeContext}),eL(e,"components",{SchemaConfigButton:eV,SchemaConfig:eN,ModeConfig:eU,AssigneesSelect:eW,WorkflowVariableTextArea:w.WorkflowVariableTextArea}),eL(e,"useVariables",eY),eL(e,"useInitializers",eQ),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&e$(e,t)}(o,e),t=o,n=[{key:"isAvailable",value:function(e){var t=e.engine,n=e.workflow;return e.upstream,e.branchIndex,!t.isWorkflowSync(n)}}],eG(t.prototype,n),o}(w.Instruction),eX=y("202"),eZ=y("760"),e0=y.n(eZ);function e1(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function e2(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function e3(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function e6(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){e3(e,t,n[t])})}return e}function e5(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function e8(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}function e4(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return e1(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e1(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e7(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function e9(){var e=e7(["\n margin-bottom: 1em;\n time {\n margin-right: 0.5em;\n }\n "]);return e9=function(){return e},e}function te(){var e=e7(["\n .ant-descriptions-header {\n margin-bottom: 0.5em;\n .ant-descriptions-extra {\n color: ",";\n }\n }\n .ant-descriptions-item-label {\n width: 6em;\n }\n "]);return te=function(){return e},e}function tt(){var e=e7(["\n .ant-card-extra {\n color: ",";\n }\n "]);return tt=function(){return e},e}function tn(e){var t,n=(0,b.useCollectionRecordData)(),r=B("Unprocessed");return(null==n?void 0:null===(t=n.execution)||void 0===t?void 0:t.status)&&!(null==n?void 0:n.status)?g().createElement(j.Tag,null,r):e.children}function tr(e){var t=(0,b.useCollectionRecordData)();if(Array.isArray(e.dataIndex)){var n=!0,r=!1,o=void 0;try{for(var i,a=e.dataIndex[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var l=i.value,c=(0,_.get)(t,l);if(c)return c}}catch(e){r=!0,o=e}finally{try{!n&&null!=a.return&&a.return()}finally{if(r)throw o}}}return(0,_.get)(t,e.dataIndex)}var to=function(e){var t=ti({defaultOpenMode:(0,b.useOpenModeContext)().defaultOpenMode,collectionName:"workflowManualTasks"});return g().createElement(b.SchemaComponentContext.Provider,{value:{designable:!1}},g().createElement(b.SchemaComponent,{scope:{useCollectionRecordData:b.useCollectionRecordData},components:{FormLayout:O.FormLayout,ContentDetailWithTitle:tv},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},default:{$and:[{title:{$includes:""}},{"workflow.title":{$includes:""}}]},"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"}}},list:{type:"array","x-component":"List",properties:{item:{type:"object","x-component":"List.Item",properties:{content:{type:"void","x-decorator":"FormLayout","x-decorator-props":{layout:"horizontal"},"x-component":"ContentDetailWithTitle","x-component-props":{}},actions:{type:"void","x-component":"ActionBar","x-use-component-props":"useListActionBarProps","x-component-props":{layout:"one-column"},"x-align":"left",properties:{view:t}}}}}}}}}))};function ti(e){var t=e.defaultOpenMode,n=e.collectionName;return{name:"view",type:"void","x-component":"Action.Link","x-component-props":{openMode:t},title:'{{t("View")}}',"x-uid":"".concat(n,"-view"),"x-action":"view","x-action-context":{dataSource:"main",collection:n,doNotUpdateContext:!0},properties:{drawer:{type:"void","x-component":to.Drawer}}}}function ta(e){var t,n=(0,b.useCurrentUserContext)().data,r=(0,w.useFlowContext)().userJob,o=r.status,i=r.result,a=r.userId,l=(0,C.useFieldSchema)().parent.toJSON().name,c=e.children;return o?!i[l]&&(c=null):(null==n?void 0:null===(t=n.data)||void 0===t?void 0:t.id)!==a&&(c=null),c}var tl=(0,h.createContext)(null);function tc(e){var t=e.value,n=e.children,r=(0,w.useFlowContext)(),o=r.userJob,i=r.execution,a=(0,C.useField)(),l=(0,C.useFieldSchema)(),c=(0,b.useCompile)();return(0,h.useEffect)(function(){(i.status||o.status)&&(a.disabled=!0,a.visible=o.status===t&&o.result._===l.name)},[i,o,t,a,l.name]),g().createElement(tl.Provider,{value:t},i.status||o.status?g().createElement(j.Button,{type:"primary",disabled:!0},c(l.title)):n)}function tu(){var e,t=(0,b.useAPIClient)(),n=(0,b.useActionContext)(),r=n.setVisible,o=n.setSubmitted,i=(0,C.useForm)(),a=i.values,l=i.submit,c=(0,C.useField)(),u=(0,C.useFieldSchema)(),s=(0,b.useTableBlockContext)().service,p=(0,w.useFlowContext)(),f=p.userJob,m=p.execution,d=u.name,y=u.parent.parent.name,v=(null!==(e=null==u?void 0:u["x-action-settings"])&&void 0!==e?e:{}).assignedValues,h=void 0===v?{}:v;return{run:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,function(n){switch(n.label){case 0:if(m.status||f.status)return[2];return[4,l()];case 1:return n.sent(),c.data=c.data||{},c.data.loading=!0,[4,t.resource("workflowManualTasks").submit({filterByTk:f.id,values:{result:(e3(e={},y,e6({},a,h.values)),e3(e,"_",d),e)}})];case 2:return n.sent(),c.data.loading=!1,o(!0),r(!1),null==s||s.refresh(),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){e2(i,r,o,a,l,"next",e)}function l(e){e2(i,r,o,a,l,"throw",e)}a(void 0)})})()}}}function ts(e){var t,n=(0,b.usePlugin)(S()),r=(0,b.useAPIClient)(),o=((0,b.useCollectionRecordData)()||{}).id,i=e4((0,h.useState)(null),2),a=i[0],l=i[1],c=e4((0,h.useState)(null),2),u=c[0],s=c[1];(0,h.useEffect)(function(){var e,t;if(!!o)null===(e=(t=r.resource("workflowManualTasks")).get)||void 0===e||e.call(t,{filterByTk:o,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(function(e){var t,n=e.data,r=null!==(t=null==n?void 0:n.data)&&void 0!==t?t:{},o=r.node,i=r.workflow,a=(void 0===i?{}:i).nodes,c=void 0===a?[]:a,u=r.execution,p=e8(r.workflow,["nodes"]),f=e8(r,["node","workflow","execution"]);(0,w.linkNodes)(c),s(o),l({userJob:f,workflow:p,nodes:c,execution:u})})},[r,o]);var p=(0,w.useAvailableUpstreams)(null==a?void 0:a.nodes.find(function(e){return e.id===u.id})).reduce(function(e,t){var r=t.type;return Object.assign(e,n.instructions.get(r).components)},{});return u&&a?g().createElement(w.FlowContext.Provider,{value:a},g().createElement(b.SchemaComponent,{components:e6({FormBlockProvider:V,DetailsBlockProvider:w.DetailsBlockProvider,ActionBarProvider:ta,ManualActionStatusProvider:tc},Array.from(eP.getValues()).reduce(function(e,t){return Object.assign(e,t.block.components)},{}),p),scope:e6({useSubmit:tu,useFormBlockProps:tp,useDetailsBlockProps:tf},Array.from(eP.getValues()).reduce(function(e,t){return Object.assign(e,t.block.scope)},{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:null===(t=u.config)||void 0===t?void 0:t.schema}})):g().createElement(j.Spin,null)}function tp(){var e,t=(0,w.useFlowContext)(),n=t.userJob,r=t.execution,o=(0,b.useCollectionRecordData)(),i=(0,b.useCurrentUserContext)().data,a=(0,b.useFormBlockContext)().form,l=r.status||n.status?o?"readPretty":"disabled":(null==i?void 0:null===(e=i.data)||void 0===e?void 0:e.id)!==n.userId?"disabled":"editable";return(0,h.useEffect)(function(){null==a||a.setPattern(l)},[l,a]),{form:a}}function tf(){return{form:(0,b.useFormBlockContext)().form}}function tm(){var e=(0,b.useCompile)(),t=(0,b.useCollectionRecordData)()||{},n=t.status,r=t.updatedAt,o=M[n];return n?g().createElement(j.Space,{className:(0,b.css)(e9())},g().createElement("time",null,e0()(r).format("YYYY-MM-DD HH:mm:ss")),g().createElement(j.Tag,{color:o.color},e(o.label))):null}function td(){var e,t=(0,h.useContext)(b.SchemaComponentContext),n=(0,b.useCollectionRecordData)()||{},r=n.id,o=n.node,i=n.workflow,a=n.status;return g().createElement(b.SchemaComponentContext.Provider,{value:e5(e6({},t),{reset:function(){},designable:!1})},g().createElement(b.SchemaComponent,{components:{FooterStatus:tm,FlowContextProvider:ts},schema:{type:"void",name:"drawer-".concat(r,"-").concat(a),"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:"".concat(null==i?void 0:i.title," - ").concat(null!==(e=null==o?void 0:o.title)&&void 0!==e?e:"#".concat(null==o?void 0:o.id)),properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Container.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}}))}tl.displayName="ManualActionStatusContext";function ty(e){var t=(0,P.useTranslation)().t,n=(0,eX.useAntdToken)();return g().createElement(j.ConfigProvider,{theme:{token:{fontSizeLG:14}}},g().createElement(j.Descriptions,e5(e6({},e),{column:1,items:[{key:"createdAt",label:t("Created at"),children:g().createElement(b.SchemaComponent,{schema:{name:"createdAt",type:"string","x-component":"CollectionField","x-read-pretty":!0}})},{key:"status",label:t("Status",{ns:"workflow"}),children:g().createElement(b.SchemaComponent,{components:{TaskStatusColumn:tn},schema:{name:"status",type:"number","x-decorator":"TaskStatusColumn","x-component":"CollectionField","x-read-pretty":!0}})}],className:(0,b.css)(te(),n.colorTextDescription)})))}function tv(e){return g().createElement(ty,{title:g().createElement(tr,{dataIndex:["title","node.title"]}),extra:g().createElement(tr,{dataIndex:"workflow.title"})})}to.Initializer=function(){var e=(0,b.useSchemaInitializerItem)(),t=(0,b.useSchemaInitializer)().insert;return g().createElement(b.SchemaInitializerItem,e5(e6({icon:g().createElement(x.TableOutlined,null)},e),{onClick:function(){t({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"}}})}}))},to.Drawer=td,to.Decorator=function(e){var t=e.params,n=void 0===t?{}:t,r=e.children,o={collection:"workflowManualTasks",resource:"workflowManualTasks",action:"list",params:e5(e6({pageSize:20,sort:["-createdAt"]},n),{filter:e6({},n.filter),appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]})};return g().createElement(b.OpenModeProvider,{defaultOpenMode:"modal"},g().createElement(b.List.Decorator,o,r))};var tb={pending:{status:w.JOB_STATUS.PENDING,"execution.status":w.EXECUTION_STATUS.STARTED},completed:{status:w.JOB_STATUS.RESOLVED}},th={title:'{{t("My manual tasks", { ns: "'.concat(E,'" })}}'),collection:"workflowManualTasks",useActionParams:function(e){var t,n,r=(0,b.useCurrentUserContext)().data;return{filter:e5(e6({},null!==(n=tb[e])&&void 0!==n?n:{}),{userId:null==r?void 0:null===(t=r.data)||void 0===t?void 0:t.id}),appends:["job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]}},component:function(){var e=(0,eX.useAntdToken)(),t=e4((0,h.useState)(!1),2),n=t[0],r=t[1],o=(0,b.useCollectionRecordData)();(0,P.useTranslation)().t;var i=(0,h.useCallback)(function(e){var t=e.target;e.currentTarget.contains(t)&&r(!0),e.stopPropagation()},[]);return g().createElement(g().Fragment,null,g().createElement(j.Card,{onClick:i,hoverable:!0,size:"small",title:o.title,extra:g().createElement(w.WorkflowTitle,o.workflow),className:(0,b.css)(tt(),e.colorTextDescription)},g().createElement(ty,null)),g().createElement(b.PopupContextProvider,{visible:n,setVisible:r,openMode:"modal"},g().createElement(td,null)))},extraActions:function(){return g().createElement(b.SchemaComponent,{schema:{name:"actions",type:"void","x-component":"ActionBar",properties:{refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},filter:{type:"void",title:'{{t("Filter")}}',"x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},default:{$and:[{title:{$includes:""}},{"workflow.title":{$includes:""}}]}}}}})}},tg={title:'{{t("Workflow", { ns: "workflow" })}}',name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}}]},tx={title:'{{t("Workflow todos", { ns: "'.concat(E,'" })}}'),name:"workflowManualTasks",fields:[{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Task title", { ns: "'.concat(E,'" })}}'),"x-component":"Input"}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"id"}}}},{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",isAssociation:!0,uiSchema:{type:"object",title:'{{t("Assignee", { ns: "'.concat(E,'" })}}'),"x-component":"AssociationField","x-component-props":{fieldNames:{label:"nickname",value:"id"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:D}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},tw=function(e){return g().createElement(b.ExtendCollectionsProvider,{collections:[tg,tx]},e.children)};!function(e){e.forEach(function(e){var t=ti({defaultOpenMode:function(){return window.location.pathname.startsWith("/m/")}()?"page":"modal",collectionName:e});(0,b.storePopupContext)(t["x-uid"],function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({schema:t},t["x-action-context"]))})}([tx.name]);function tS(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function tO(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){tS(i,r,o,a,l,"next",e)}function l(e){tS(i,r,o,a,l,"throw",e)}a(void 0)})}}function tk(e,t,n){return(tk=tE()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&tP(o,n.prototype),o}).apply(null,arguments)}function tC(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tj(e){return(tj=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tP(e,t){return(tP=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tA(e){var t="function"==typeof Map?new Map:void 0;return(tA=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return tk(e,arguments,tj(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),tP(r,e)})(e)}function tE(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tE=function(){return!!e})()}function tI(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var tF=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=tj(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,tE()?Reflect.construct(t,n||[],tj(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tP(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return tO(function(){return tI(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return tO(function(){var t;return tI(this,function(n){return e.addComponents(),e.app.addProvider(tw),(t=e.app.pm.get("workflow")).registerInstruction("manual",eH),t.registerTaskType("manual",th),e.app.schemaInitializerManager.add(eE),e.app.schemaInitializerManager.add(eI),e.app.schemaInitializerManager.add(eB),e.app.schemaInitializerManager.add(eR),e.app.schemaInitializerManager.add(ed),e.app.schemaInitializerManager.add(ey),e.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflowTodos",{title:'{{t("Workflow todos", { ns: "'.concat(E,'" })}}'),Component:"WorkflowTodo.Initializer",icon:"CheckSquareOutlined"}),e.app.schemaInitializerManager.addItem("mobile:addBlock","otherBlocks.workflowTodos",{title:'{{t("Workflow todos", { ns: "'.concat(E,'" })}}'),Component:"WorkflowTodo.Initializer",icon:"CheckSquareOutlined"}),[2]})})()}},{key:"addComponents",value:function(){this.app.addComponents({WorkflowTodo:to})}}],tC(t.prototype,n),o}(tA(b.Plugin));return v}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("dayjs"),require("react"),require("@formily/antd-v5"),require("lodash"),require("@nocobase/client"),require("react-router-dom"),require("@nocobase/plugin-workflow/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/utils/client"),require("antd"),require("antd-style"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-manual",["@formily/core","dayjs","react","@formily/antd-v5","lodash","@nocobase/client","react-router-dom","@nocobase/plugin-workflow/client","@formily/react","@ant-design/icons","@nocobase/utils/client","antd","antd-style","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-manual"]=t(require("@formily/core"),require("dayjs"),require("react"),require("@formily/antd-v5"),require("lodash"),require("@nocobase/client"),require("react-router-dom"),require("@nocobase/plugin-workflow/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/utils/client"),require("antd"),require("antd-style"),require("react-i18next")):e["@nocobase/plugin-workflow-manual"]=t(e["@formily/core"],e.dayjs,e.react,e["@formily/antd-v5"],e.lodash,e["@nocobase/client"],e["react-router-dom"],e["@nocobase/plugin-workflow/client"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/utils/client"],e.antd,e["antd-style"],e["react-i18next"])}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,f,m){return function(){"use strict";var d={482:function(e){e.exports=u},632:function(e){e.exports=r},563:function(t){t.exports=e},505:function(e){e.exports=c},772:function(e){e.exports=i},433:function(e){e.exports=l},584:function(e){e.exports=s},721:function(e){e.exports=p},202:function(e){e.exports=f},760:function(e){e.exports=t},467:function(e){e.exports=o},156:function(e){e.exports=n},238:function(e){e.exports=m},128:function(e){e.exports=a}},y={};function b(e){var t=y[e];if(void 0!==t)return t.exports;var n=y[e]={exports:{}};return d[e](n,n.exports,b),n.exports}b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},b.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var v={};return!function(){b.r(v),b.d(v,{default:function(){return tp}});var e=b(772),t=b(156),n=b.n(t),r=b(482),o=b(433),i=b.n(o),a=b(632),l=b(563),c=b(505),u=b(721),s=b(238),p=b(584),f="workflow-manual",m=[{value:0,label:'{{t("Pending", { ns: "workflow" })}}',color:"gold"},{value:1,label:'{{t("Resolved", { ns: "workflow" })}}',color:"green"},{value:-5,label:'{{t("Rejected", { ns: "workflow" })}}',color:"red"}],d=m.reduce(function(e,t){var n,r;return Object.assign(e,(n={},r=t.value,r in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n))},{});function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,h(t).t)(e)}function h(e){return(0,s.useTranslation)(f,e)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function w(r){var o,i,a,s,p,f=(0,e.useCollectionRecordData)(),m=(0,c.useFieldSchema)(),d=(0,c.useField)(),y=(0,t.useRef)(null),b=r.dataSource||e.DEFAULT_DATA_SOURCE_KEY,v=u.theme.useToken().token,h=(0,(0,e.useAssociationNames)(b).getAssociationAppends)(),w=h.appends,S=h.updateAssociationValues,O=(o=Object.keys(null!=(p=m.toJSON().properties)?p:{}),function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(o,1)||function(e,t){if(e){if("string"==typeof e)return g(e,1);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(o,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],k=null==f||null==(s=f.result)?void 0:s[O],C=(0,t.useMemo)(function(){return(0,l.createForm)({initialValues:k})},[k]),j=(0,t.useMemo)(function(){return x({appends:w},r.params)},[w,r.params]),P=(0,t.useMemo)(function(){return{loading:!1,data:{data:k}}},[k]),A=(0,e.useAPIClient)(),E=(0,e.useDataSourceHeaders)(b),I=A.resource(r.collection,void 0,E),F=(0,e.useBlockRequestContext)(),T=(0,t.useMemo)(function(){return{params:j,form:C,field:d,service:P,updateAssociationValues:S,formBlockRef:y}},[d,C,j,P,S]);return(null==f?void 0:f.status)&&!k?null:n().createElement(e.CollectionManagerProvider,{dataSource:b},n().createElement(e.CollectionProvider_deprecated,{collection:r.collection},n().createElement(e.BlockProvider,(i=x({name:r.name||"form"},r),a=a={block:"form",parentRecord:null},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),i),n().createElement(e.FormActiveFieldsProvider,{name:"form"},n().createElement(e.BlockRequestContext_deprecated.Provider,{value:{block:"form",props:r,field:d,service:P,resource:I,__parent:F}},n().createElement(e.FormBlockContext.Provider,{value:T},n().createElement(e.RecordProvider,{record:k,parent:null},n().createElement(e.FormV2.Templates,{style:{marginBottom:v.margin},form:C}),n().createElement("div",{ref:y},r.children))))))))}var S=b(467),O=b.n(S);function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function C(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function P(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function A(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return k(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t){var r=t.schema,i=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(t,["schema"]),a=(0,e.useSchemaTemplateManager)().getTemplateSchemaByMode,l=(0,e.useSchemaInitializer)().insert,c=(0,e.useRecordCollectionDataSourceItems)("FormItem");function u(){var t;return t=function(t){var n,i,c,u,s,p,m;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(d){switch(d.label){case 0:if(!(n=t.item).template)return[3,2];return[4,a(n)];case 1:return u=d.sent(),[3,3];case 2:u=null,d.label=3;case 3:var y;return c=u,y=P(j({actionInitializers:"workflowManual:form:configureActions",actions:{resolve:{type:"void",title:'{{t("Continue the process", { ns: "'.concat(f,'" })}}'),"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:o.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},r),{template:c}),s=(0,e.createFormBlockSchema)(y),delete s["x-acl-action-props"],delete s["x-acl-action"],p=A(Object.keys(s.properties),1)[0],m=(null==(i=Object.entries(s.properties[p].properties).find(function(e){var t=A(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))?void 0:i[0])||"actions",s.properties[p].properties[m]["x-decorator"]="ActionBarProvider",s.properties[p].properties[m]["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},(0,o.traverseSchema)(s,function(e){e["x-uid"]&&delete e["x-uid"]}),l(s),[2]}})},(u=function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){C(i,r,o,a,l,"next",e)}function l(e){C(i,r,o,a,l,"throw",e)}a(void 0)})}).apply(this,arguments)}return n().createElement(e.SchemaInitializerItem,P(j({},i),{onClick:function(e){return u.apply(this,arguments)},items:c}))}function I(){var t,r,o=(0,e.useSchemaInitializerItem)();return n().createElement(e.CollectionProvider_deprecated,{dataSource:null==(t=o.schema)?void 0:t.dataSource,collection:null==(r=o.schema)?void 0:r.collection},n().createElement(E,o))}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[];return e&&(!t(e)||n&&e.properties?e.properties&&Object.keys(e.properties).forEach(function(n){var o;r.push.apply(r,function(e){if(Array.isArray(e))return F(e)}(o=T(e.properties[n],t))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,t){if(e){if("string"==typeof e)return F(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return F(e,t)}}(o)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}):r.push(e)),r}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return D(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function R(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function z(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){R(i,r,o,a,l,"next",e)}function l(e){R(i,r,o,a,l,"throw",e)}a(void 0)})}}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){N(e,t,n[t])})}return e}function _(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||U(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return B(e,t)}}function W(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function G(r){var o,i,a,u,s=q((0,t.useState)(null!=(a=null==(o=r.collection)?void 0:o.fields)?a:[]),2),p=s[0],f=s[1],m=(0,e.useCollectionRecordData)(),d=(0,c.useField)(),y=q(Object.keys(null!=(u=(0,c.useFieldSchema)().toJSON().properties)?u:{}),1)[0],b=null==m||null==(i=m.result)?void 0:i[y],v=(0,t.useMemo)(function(){return(0,l.createForm)({initialValues:b})},[b]);return(null==m?void 0:m.status)&&!b?null:n().createElement(e.CollectionProvider_deprecated,{collection:_(V({},r.collection),{fields:p})},n().createElement(e.RecordProvider,{record:b,parent:null},n().createElement(e.FormBlockContext.Provider,{value:{form:v,field:d,setCollectionFields:f}},r.children)))}function L(){var t=(0,e.useSchemaInitializer)().insert,r=(0,e.useSchemaInitializerItem)();return n().createElement(e.SchemaInitializerItem,_(V({},r),{onClick:function(){t({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:(0,p.uid)(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:N({},(0,p.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: "'.concat(f,'" })}}'),"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:o.JOB_STATUS.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}})})}}))}var J={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")}}'},$=n().createContext({});function K(){var e=(0,c.useForm)(),n=e.values,r=e.query,o=e.reset,i=[y("Field name existed in form")],a=(0,t.useContext)($),l=a.collection,u=a.interfaceOptions,s=a.setCollectionFields,f=a.insert,m=a.setCallback,d=a.setInterface;return{run:function(){return z(function(){var e,t,a,c,y,b,v;return W(this,function(h){var g;return(a=u.default,c=(0,p.uid)(),a.name=null!=(y=n.name)?y:c,a.uiSchema.title=null!=(b=null==(e=n.uiSchema)?void 0:e.title)?b:c,a.interface=u.name,null==(t=l.fields)?void 0:t.find(function(e){return e.name===a.name}))?(r("name").take().setFeedback({type:"error",messages:i}),[2]):(v=(0,p.merge)(a,n),s(((function(e){if(Array.isArray(e))return B(e)})(g=l.fields)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(g)||U(g)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([v])),f({name:a.name,type:a.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:v},"x-collection-field":"".concat(l.name,".").concat(a.name),"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem"}),o(),m(null),d(null),[2])})})()}}}var Y={wrap:e.gridRowColWrap,insertPosition:"beforeEnd",title:"{{t('Configure fields')}}",ItemsComponent:function(r){var o,i,u=q((0,t.useState)(null),2),s=u[0],p=u[1],f=q((0,t.useState)(),2),m=f[0],d=f[1],y=(i={},Object.keys(o=(0,e.useCollectionManager_deprecated)().interfaces).forEach(function(e){var t=o[e],n=t.group,r=void 0===n?"others":n;i[r]=i[r]||{},(0,S.set)(i,[r,e],t)}),Object.keys(J).filter(function(e){return["basic","choices","datetime","media"].includes(e)}).map(function(e){return{title:J[e],children:Object.keys(i[e]||{}).map(function(t){var n=i[e][t];return V({value:t,title:n.title,name:t},i[e][t])}).sort(function(e,t){return e.order-t.order})}})).map(function(e){return{name:e.title,type:"itemGroup",title:e.title,children:e.children.map(function(e){return{name:e.name,type:"item",title:e.title,Component:X,fieldInterface:e.name}})}}),b=(0,e.useCollection_deprecated)(),v=(0,t.useContext)(e.FormBlockContext).setCollectionFields,h=(0,t.useMemo)(function(){return(0,l.createForm)()},[]);return n().createElement($.Provider,{value:{collection:b,insert:m,interfaceOptions:s,onAddField:function(e){var t=(0,S.pick)(e,["name","group","title","default","validateSchema"]),n=e.properties;n.unique,n.type,n.layout,n.autoIncrement,t.properties=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e.properties,["unique","type","layout","autoIncrement"]);var r=(0,S.cloneDeep)(t);delete r.properties.name["x-disabled"],p(r)},setCallback:d,setInterface:p,setCollectionFields:v}},n().createElement(e.SchemaInitializerItems,_(V({},r),{items:y})),n().createElement(e.ActionContextProvider,{value:{visible:!!s,setVisible:function(e){e||p(null)}}},s?n().createElement(e.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"FormV2","x-decorator-props":{form:h},"x-component":"Action.Drawer",properties:_(V({},s.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:function(){var e=(0,c.useForm)();return{run:function(){return z(function(){return W(this,function(t){return d(null),p(null),e.reset(),[2]})})()}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:K}}}}})},components:{ArrayTable:a.ArrayTable}}):null))}},Q=new e.CompatibleSchemaInitializer(V({name:"AddCustomFormField"},Y)),H=new e.CompatibleSchemaInitializer(V({name:"workflowManual:customForm:configureFields"},Y),Q);function X(){var r=(0,e.useSchemaInitializerItem)(),o=(0,e.useSchemaInitializer)().insert,i=(0,t.useContext)($),a=i.onAddField,l=i.setCallback,c=(0,(0,e.useCollectionManager_deprecated)().getInterface)(r.fieldInterface);return n().createElement(e.SchemaInitializerItem,V({key:r.fieldInterface,onClick:function(){l(function(){return o}),a(c)}},r))}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var et={title:'{{t("Update record form", { ns: "'.concat(f,'" })}}'),config:{useInitializer:function(n){var r=n.allCollections,o=(0,t.useMemo)(function(){return r.map(function(e){var t=e.key;return{key:t,name:t,label:e.displayName,type:"subMenu",children:e.collections.map(function(e){return{name:O().camelCase("updateRecordForm-child-".concat(e.name)),type:"item",title:e.title||e.tableName,schema:{collection:e.name,dataSource:t,title:'{{t("Update record", { ns: "'.concat(f,'" })}}'),formType:"update","x-designer":"UpdateFormDesigner"},Component:I}})}})},[r]),i=ee((0,t.useState)([]),2),a=i[0],l=i[1],c=(0,e.useMenuSearch)({data:o,openKeys:a});return{name:"updateRecordForm",key:"updateRecordForm",type:"subMenu",title:'{{t("Update record form", { ns: "'.concat(f,'" })}}'),componentProps:{onOpenChange:function(e){l(e)}},children:c}},initializers:{},components:{FilterDynamicComponent:o.FilterDynamicComponent,UpdateFormDesigner:function(){var t=(0,e.useCollection_deprecated)(),r=t.name,o=t.title,i=(0,c.useFieldSchema)(),a=(0,s.useTranslation)().t,l=(0,e.useDesignable)().dn;return n().createElement(e.GeneralSchemaDesigner,{title:o||r},n().createElement(e.SchemaSettingsBlockTitleItem,null),n().createElement(e.SchemaSettingsActionModalItem,{title:a("Filter settings",{ns:f}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-use-component-props":function(){var t;return{options:(0,e.useCollectionFilterOptions)(null==i||null==(t=i["x-decorator-props"])?void 0:t.collection)}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},initialValues:null==i?void 0:i["x-decorator-props"],onSubmit:function(e){var t=e.filter;i["x-decorator-props"].filter=t,l.emit("patch",{schema:{"x-decorator-props":i["x-decorator-props"]}}),l.refresh()},width:"60%"}),n().createElement(e.SchemaSettingsLinkageRules,{collectionName:r}),n().createElement(e.SchemaSettingsDivider,null),n().createElement(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}))}},parseFormOptions:function(e){var t={};return T(e,function(e){return"FormBlockProvider"===e["x-decorator"]&&"update"===e["x-decorator-props"].formType}).forEach(function(e){var n,r,o,i,a=ee(Object.keys(e.properties),1)[0],l=e.properties[a],c=(null==(o=Object.entries(l.properties).find(function(e){var t=ee(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))?void 0:o[0])||"actions";t[a]=(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e["x-decorator-props"]),r=r={type:"update",title:(null==(i=e["x-component-props"])?void 0:i.title)||a,actions:T(l.properties[c],function(e){return"Action"===e["x-component"]}).map(function(e){var t,n;return{status:e["x-decorator-props"].value,values:null==(n=e["x-action-settings"])||null==(t=n.assignedValues)?void 0:t.values,key:e.name}})},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n)}),t}},block:{scope:{},components:{}},validate:function(e){var t=e.filter;return t&&(0,p.isValidFilter)(t)?null:"Please check one of your update record form, and add at least one filter condition in form settings."}};function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function er(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function eo(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function ei(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function ea(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||ec(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function el(e){return function(e){if(Array.isArray(e))return en(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ec(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ec(e,t){if(e){if("string"==typeof e)return en(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(e,t)}}var eu=new p.Registry;eu.register("custom",{title:'{{t("Custom form", { ns: "'.concat(f,'" })}}'),config:{useInitializer:function(){return{name:"customForm",type:"item",title:'{{t("Custom form", { ns: "'.concat(f,'" })}}'),Component:L}},initializers:{},components:{CustomFormBlockProvider:G},parseFormOptions:function(e){var t={};return T(e,function(e){return"CustomFormBlockProvider"===e["x-decorator"]}).forEach(function(e){var n,r,o=q(Object.keys(e.properties),1)[0],i=e.properties[o],a=T(i.properties.grid,function(e){return"CollectionField"===e["x-component"]},!0);e["x-decorator-props"].collection.fields=a.map(function(e){var t,n;return null!=(n=null==(t=e["x-component-props"])?void 0:t.field)?n:e["x-interface-options"]});var l=(null==(n=Object.entries(i.properties).find(function(e){var t=q(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))?void 0:n[0])||"actions";t[o]={type:"custom",title:(null==(r=e["x-component-props"])?void 0:r.title)||o,actions:T(i.properties[l],function(e){return"Action"===e["x-component"]}).map(function(e){var t,n;return{status:e["x-decorator-props"].value,values:null==(n=e["x-action-settings"])||null==(t=n.assignedValues)?void 0:t.values,key:e.name}}),collection:e["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:G}}}),eu.register("create",{title:'{{t("Create record form", { ns: "'.concat(f,'" })}}'),config:{useInitializer:function(n){var r=n.allCollections,o=(0,t.useMemo)(function(){return r.map(function(e){var t=e.key;return{key:t,name:t,label:e.displayName,type:"subMenu",children:e.collections.map(function(e){return{name:O().camelCase("createRecordForm-child-".concat(e.name)),type:"item",title:e.title||e.tableName,schema:{collection:e.name,dataSource:t,title:'{{t("Create record", { ns: "'.concat(f,'" })}}'),formType:"create","x-designer":"CreateFormDesigner"},Component:I}})}})},[r]),i=M((0,t.useState)([]),2),a=i[0],l=i[1],c=(0,e.useMenuSearch)({data:o,openKeys:a});return{name:"createRecordForm",key:"createRecordForm",type:"subMenu",title:'{{t("Create record form", { ns: "'.concat(f,'" })}}'),componentProps:{onOpenChange:function(e){l(e)}},children:c}},initializers:{},components:{CreateFormDesigner:function(){var t=(0,e.useCollection_deprecated)(),r=t.name,o=t.title;return n().createElement(e.GeneralSchemaDesigner,{title:o||r},n().createElement(e.SchemaSettingsBlockTitleItem,null),n().createElement(e.SchemaSettingsLinkageRules,{collectionName:r}),n().createElement(e.SchemaSettingsDataTemplates,{collectionName:r}),n().createElement(e.SchemaSettingsDivider,null),n().createElement(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}))}},parseFormOptions:function(e){var t={};return T(e,function(e){return"FormBlockProvider"===e["x-decorator"]&&"create"===e["x-decorator-props"].formType}).forEach(function(e){var n,r,o=M(Object.keys(e.properties),1)[0],i=e.properties[o],a=(null==(n=Object.entries(i.properties).find(function(e){var t=M(e,2);return"ActionBar"===(t[0],t[1])["x-component"]}))?void 0:n[0])||"actions";t[o]={type:"create",title:(null==(r=e["x-component-props"])?void 0:r.title)||o,actions:T(i.properties[a],function(e){return"Action"===e["x-component"]}).map(function(e){var t,n;return{status:e["x-decorator-props"].value,values:null==(n=e["x-action-settings"])||null==(t=n.assignedValues)?void 0:t.values,key:e.name}}),dataSource:e["x-decorator-props"].dataSource,collection:e["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}}),eu.register("update",et);var es={wrap:e.gridRowColWrap,title:'{{t("Add block")}}',items:[{type:"itemGroup",name:"dataBlocks",title:'{{t("Data blocks")}}',hideIfNoChildren:!0,useChildren:function(){var t,n,r=(0,e.usePlugin)(i()),a=(0,o.useNodeContext)(),l=(0,o.useAvailableUpstreams)(a),c=[(t=(0,o.useFlowContext)().workflow,(n=(0,o.useTrigger)()).useInitializers?n.useInitializers(t.config):null)].filter(Boolean),u=l.map(function(e){var t,n=r.instructions.get(e.type);return null==n||null==(t=n.useInitializers)?void 0:t.call(n,e)}).filter(Boolean);return el(c).concat(el(u.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "'.concat(f,'" })}}'),children:u}]:[])).filter(Boolean)}},{type:"itemGroup",name:"form",title:'{{t("Form")}}',useChildren:function(){var t=(0,e.useDataSourceManager)().getAllCollections();return Array.from(eu.getValues()).map(function(e){return(0,e.config.useInitializer)({allCollections:t})})}},{type:"itemGroup",name:"otherBlocks",title:'{{t("Other blocks")}}',children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},ep=new e.CompatibleSchemaInitializer(er({name:"AddBlockButton"},es)),ef=new e.CompatibleSchemaInitializer(er({name:"workflowManual:popup:configureUserInterface:addBlock"},es),ep);function em(){var r,i,f,m=(0,t.useContext)(e.SchemaComponentContext),d=(0,s.useTranslation)().t,y=h().t,b=(0,c.useFieldSchema)(),v=(0,o.useWorkflowVariableOptions)(),g=ea((0,t.useState)(!1),2),x=g[0],w=g[1],S=ea((0,t.useState)(null!=(f=null==b||null==(i=b["x-action-settings"])||null==(r=i.assignedValues)?void 0:r.schema)?f:{type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields",properties:{}}),2),O=S[0],k=S[1],C=ea((0,t.useState)(null),2),j=C[0],P=C[1],A=(0,e.useSchemaOptionsContext)().components;(0,t.useEffect)(function(){P(new c.Schema({properties:{grid:O}}))},[O]);var E=(0,t.useMemo)(function(){var e,t,n=null==b||null==(t=b["x-action-settings"])||null==(e=t.assignedValues)?void 0:e.values;return(0,l.createForm)({initialValues:p.lodash.cloneDeep(n),values:p.lodash.cloneDeep(n)})},[b]),I=(0,e.useFormActiveFields)(),F=d("Assign field values");function T(){w(!1)}return n().createElement(n().Fragment,null,n().createElement(e.SchemaSettingsItem,{title:F,onClick:function(){return w(!0)}},F),n().createElement(u.Modal,{width:"50%",title:F,open:x,onCancel:T,footer:n().createElement(u.Space,null,n().createElement(u.Button,{onClick:T},y("Cancel")),n().createElement(u.Button,{type:"primary",onClick:function(){b["x-action-settings"]||(b["x-action-settings"]={}),b["x-action-settings"].assignedValues||(b["x-action-settings"].assignedValues={}),b["x-action-settings"].assignedValues.schema=O,b["x-action-settings"].assignedValues.values=E.values,w(!1),setTimeout(function(){var e;null==(e=m.refresh)||e.call(m)},300)}},y("Submit")))},n().createElement(e.DefaultValueProvider,{isAllowToSetDefaultValue:function(){return!1}},n().createElement(e.VariableScopeProvider,{scope:v},n().createElement(e.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:null==I?void 0:I.getActiveFieldsName},n().createElement(c.FormProvider,{form:E},n().createElement(a.FormLayout,{layout:"vertical"},n().createElement(u.Alert,{message:y("Values preset in this form will override user submitted ones when continue or reject.")}),n().createElement("br",null),x&&j&&n().createElement(e.SchemaComponentContext.Provider,{value:eo(er({},m),{refresh:function(){k(p.lodash.get(j.toJSON(),"properties.grid"))}})},n().createElement(e.SchemaComponent,{schema:j,components:A})))))))))}function ed(t){return n().createElement(e.GeneralSchemaDesigner,eo(er({},t),{disableInitializer:!0}),n().createElement(e.Action.Designer.ButtonEditor,null),n().createElement(em,null),n().createElement(e.SchemaSettingsDivider,null),n().createElement(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}}))}function ey(){var t=(0,e.useSchemaInitializerItem)(),r=t.action,o=t.actionProps,i=ei(t,["action","actionProps"]);return n().createElement(e.InitializerWithSwitch,eo(er({},i),{item:t,schema:{type:"void",title:i.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":eo(er({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action":"".concat(r)},type:"x-action"}))}var eb={title:'{{t("Configure actions")}}',items:[{name:"jobStatusResolved",title:'{{t("Continue the process", { ns: "'.concat(f,'" })}}'),Component:function(){var t=(0,e.useSchemaInitializerItem)(),r=t.action,o=t.actionProps,i=ei(t,["action","actionProps"]),a=(0,e.useSchemaInitializer)().insert;return n().createElement(e.SchemaInitializerItem,eo(er({},i),{onClick:function(){a({type:"void",title:i.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:r},"x-component":"Action","x-component-props":eo(er({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))},action:o.JOB_STATUS.RESOLVED,actionProps:{type:"primary"}},{name:"jobStatusRejected",title:'{{t("Terminate the process", { ns: "'.concat(f,'" })}}'),Component:ey,action:o.JOB_STATUS.REJECTED,actionProps:{danger:!0}},{name:"jobStatusPending",title:'{{t("Save temporarily", { ns: "'.concat(f,'" })}}'),Component:ey,action:o.JOB_STATUS.PENDING}]},ev=new e.CompatibleSchemaInitializer(er({name:"AddActionButton"},eb)),eh=new e.CompatibleSchemaInitializer(er({name:"workflowManual:form:configureActions"},eb),ev);function eg(){return{run:function(){}}}function ex(r){var a=r.value,l=r.onChange,u=(0,e.usePlugin)(i()),s=(0,t.useContext)(e.SchemaComponentContext),m=(0,o.useNodeContext)(),d=(0,o.useAvailableUpstreams)(m),y=(0,c.useForm)(),b=(0,o.useWorkflowExecuted)(),v=(0,t.useRef)(function(){}),h={};d.forEach(function(e){Object.assign(h,u.instructions.get(e.type).components)});var g=(0,t.useMemo)(function(){return new c.Schema({properties:{drawer:{type:"void",title:'{{t("User interface", { ns: "'.concat(f,'" })}}'),"x-decorator":"Form","x-component":"Action.Container","x-component-props":{onClose:function(){return v.current()}},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"workflowManual:popup:configureUserInterface:addBlock"},properties:null!=a?a:{tab1:{type:"void",title:'{{t("Manual", { ns: "'.concat(f,'" })}}'),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"workflowManual:popup:configureUserInterface:addBlock",properties:{}}}}}}}}}})},[]),x=(0,t.useCallback)(function(){var e=p.lodash.get(g.toJSON(),"properties.drawer.properties").tabs,t=Array.from(eu.getValues()).reduce(function(t,n){return Object.assign(t,n.config.parseFormOptions(e))},{});y.setValuesIn("forms",t),l(e.properties)},[y,l,g]);return v.current=x,n().createElement(e.SchemaComponentContext.Provider,{value:eo(er({},s),{designable:!b,refresh:x})},n().createElement(e.SchemaComponent,{schema:g,components:eo(er({},h,Array.from(eu.getValues()).reduce(function(e,t){return Object.assign(e,t.config.components)},{})),{FormBlockProvider:w,DetailsBlockProvider:o.DetailsBlockProvider,ManualActionStatusProvider:function(e){return e.children},ActionBarProvider:function(e){return e.children},SimpleDesigner:o.SimpleDesigner,ManualActionDesigner:ed}),scope:{useSubmit:eg,useDetailsBlockProps:e.useFormBlockContext}}))}function ew(r){var i=(0,o.useWorkflowExecuted)(),a=ea((0,t.useState)(!1),2),l=a[0],s=a[1],p=(0,c.useForm)().values,f=h().t,m=(0,t.useCallback)(function(e){if(!e){var t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!0,n=!1,r=void 0;try{for(var o,i=Object.values(e)[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value,l=eu.get(a.type);if("function"==typeof l.validate){var c=l.validate(a);if(c)return c}}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}}(p.forms);if(t)return void u.message.error({content:f(t)})}s(e)},[p.forms]);return n().createElement(n().Fragment,null,n().createElement(u.Button,{type:"primary",onClick:function(){return s(!0)},disabled:!1},f(i?"View user interface":"Configure user interface")),n().createElement(e.ActionContextProvider,{value:{visible:l,setVisible:m,formValueChanged:!1}},r.children))}function eS(){var e,t,n=(e=["\n .ant-radio-group {\n .anticon {\n margin-left: 0.5em;\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eS=function(){return n},n}function eO(t){var o=t.value,i=t.onChange,l=n().createElement("fieldset",null,n().createElement(a.FormLayout,{layout:"vertical"},n().createElement(e.FormItem,{label:y("Negotiation")},n().createElement(u.Radio.Group,{value:o,onChange:i},n().createElement(u.Radio,{value:1},n().createElement(u.Tooltip,{title:y("Everyone should pass"),placement:"bottom"},n().createElement("span",null,y("All pass")),n().createElement(r.QuestionCircleOutlined,{style:{color:"#999"}}))),n().createElement(u.Radio,{value:-1},n().createElement(u.Tooltip,{title:y("Anyone pass"),placement:"bottom"},n().createElement("span",null,y("Any pass")),n().createElement(r.QuestionCircleOutlined,{style:{color:"#999"}})))))));return n().createElement("fieldset",{className:(0,e.css)(eS())},n().createElement(u.Form.Item,null,n().createElement(u.Radio.Group,{value:!!o,onChange:function(e){var t=e.target.value;console.log(t),i(Number(t))}},n().createElement(u.Radio,{value:!0},n().createElement(u.Tooltip,{title:y("Each user has own task"),placement:"bottom"},n().createElement("span",null,y("Separately")),n().createElement(r.QuestionCircleOutlined,{style:{color:"#999"}}))),n().createElement(u.Radio,{value:!1},n().createElement(u.Tooltip,{title:y("Everyone shares one task"),placement:"bottom"},n().createElement("span",null,y("Collaboratively")),n().createElement(r.QuestionCircleOutlined,{style:{color:"#999"}}))))),o?l:null)}function ek(e){return e.isForeignKey||"context"===e.type?"users"===e.target:"users"===e.collectionName&&"id"===e.name}function eC(t){t.multiple;var r=t.value,i=void 0===r?[]:r,a=t.onChange,l=(0,o.useWorkflowVariableOptions)({types:[ek]});return n().createElement(e.Variable.Input,{scope:l,value:i[0],onChange:function(e){a([e])}},n().createElement(e.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:i[0],onChange:function(e){a(null!=e?[e]:[])}}))}function ej(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eP(e){return(eP=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eA(e,t){return(eA=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eE(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eE=function(){return!!e})()}function eI(t,n){var r,i,a=t.key,l=t.title,c=t.config,u=n.types,s=n.fieldNames,p=void 0===s?o.defaultFieldNames:s,f=(0,e.useCompile)(),m=(0,e.useCollectionManager_deprecated)().getCollectionFields,d=Object.keys(null!=(r=c.forms)?r:{});if(!d.length)return null;var y=d.map(function(e){var t,n=c.forms[e],r=(0,o.getCollectionFieldOptions)({fields:null==(t=n.collection)?void 0:t.fields,collection:n.collection,types:u,compile:f,getCollectionFields:m}),i=f(n.title)||e;return r.length?{key:e,value:e,label:i,title:i,children:r}:null}).filter(Boolean);return y.length?(ej(i={},p.value,a),ej(i,p.label,l),ej(i,p.children,y),i):null}function eF(t){var n,r=(0,e.useDataSourceManager)(),i=Object.keys(null!=(n=t.config.forms)?n:{});if(!i.length||t.config.mode)return null;var a=i.map(function(n){var i,a,l=t.config.forms[n],c=r.getDataSource(l.dataSource).collectionManager,u=("string"==typeof l.collection?c.getCollection(l.collection):l.collection||{fields:[]}).fields;return(void 0===u?[]:u).length?{name:null!=(i=l.title)?i:n,type:"item",title:null!=(a=l.title)?a:n,Component:o.CollectionBlockInitializer,collection:(0,e.joinCollectionName)(l.dataSource,l.collection),dataPath:"$jobsMapByNodeKey.".concat(t.key,".").concat(n)}:null}).filter(Boolean);return a.length?{name:"#".concat(t.id),key:"forms",type:"subMenu",title:t.title,children:a}:null}Symbol("single"),Symbol("all"),Symbol("any"),Symbol("all percentage"),Symbol("any percentage");var eT=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t,a;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,a=arguments,t=eP(t),ej(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eE()?Reflect.construct(t,a||[],eP(this).constructor):t.apply(this,a)),"title",'{{t("Manual", { ns: "'.concat(f,'" })}}')),ej(e,"type","manual"),ej(e,"group","manual"),ej(e,"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: "'.concat(f,'" })}}')),ej(e,"icon",n().createElement(r.SolutionOutlined,null)),ej(e,"fieldset",{assignees:{type:"array",title:'{{t("Assignees", { ns: "'.concat(f,'" })}}'),"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:'{{t("Mode", { ns: "'.concat(f,'" })}}'),"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},title:{type:"string",title:'{{t("Task title", { ns: "'.concat(f,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea",description:'{{t("Title of each task item. Default to node title.", { ns: "'.concat(f,'" })}}'),default:"{{useNodeContext().title}}"},schema:{type:"void",title:'{{t("User interface", { ns: "'.concat(f,'" })}}'),"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}}),ej(e,"scope",{useNodeContext:o.useNodeContext}),ej(e,"components",{SchemaConfigButton:ew,SchemaConfig:ex,ModeConfig:eO,AssigneesSelect:eC,WorkflowVariableTextArea:o.WorkflowVariableTextArea}),ej(e,"useVariables",eI),ej(e,"useInitializers",eF),e}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&eA(i,e),t=[{key:"isAvailable",value:function(e){var t=e.engine,n=e.workflow;return e.upstream,e.branchIndex,!t.isWorkflowSync(n)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,t),i}(o.Instruction),eD=b(128),eM=b(202),eB=b(760),eR=b.n(eB);function ez(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eN(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eV(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function e_(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eV(e,t,n[t])})}return e}function eq(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eU(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function eW(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ez(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ez(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eG(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eL(){var e=eG(["\n margin-bottom: 1em;\n time {\n margin-right: 0.5em;\n }\n "]);return eL=function(){return e},e}function eJ(){var e=eG(["\n .ant-descriptions-header {\n margin-bottom: 0.5em;\n .ant-descriptions-extra {\n color: ",";\n }\n }\n .ant-descriptions-item-label {\n width: 6em;\n }\n "]);return eJ=function(){return e},e}function e$(){var e=eG(["\n .ant-card-extra {\n color: ",";\n }\n "]);return e$=function(){return e},e}function eK(t){var r,o=(0,e.useCollectionRecordData)(),i=y("Unprocessed");return(null==o||null==(r=o.execution)?void 0:r.status)&&!(null==o?void 0:o.status)?n().createElement(u.Tag,null,i):t.children}function eY(t){var n=(0,e.useCollectionRecordData)();if(Array.isArray(t.dataIndex)){var r=!0,o=!1,i=void 0;try{for(var a,l=t.dataIndex[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){var c=a.value,u=(0,S.get)(n,c);if(u)return u}}catch(e){o=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}}return(0,S.get)(n,t.dataIndex)}var eQ=function(t){var r=eH({defaultOpenMode:(0,e.useOpenModeContext)().defaultOpenMode,collectionName:"workflowManualTasks"});return n().createElement(e.SchemaComponentContext.Provider,{value:{designable:!1}},n().createElement(e.SchemaComponent,{scope:{useCollectionRecordData:e.useCollectionRecordData},components:{FormLayout:a.FormLayout,ContentDetailWithTitle:e7},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined",nonfilterable:["workflow.type","workflow.mode","workflow.description","workflow.categories"]},default:{$and:[{title:{$includes:""}},{"workflow.title":{$includes:""}}]},"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"}}},list:{type:"array","x-component":"List",properties:{item:{type:"object","x-component":"List.Item",properties:{content:{type:"void","x-decorator":"FormLayout","x-decorator-props":{layout:"horizontal"},"x-component":"ContentDetailWithTitle","x-component-props":{}},actions:{type:"void","x-component":"ActionBar","x-use-component-props":"useListActionBarProps","x-component-props":{layout:"one-column"},"x-align":"left",properties:{view:r}}}}}}}}}))};function eH(e){var t=e.defaultOpenMode,n=e.collectionName;return{name:"view",type:"void","x-component":"Action.Link","x-component-props":{openMode:t},title:'{{t("View")}}',"x-uid":"".concat(n,"-view"),"x-action":"view","x-action-context":{dataSource:"main",collection:n,doNotUpdateContext:!0},properties:{drawer:{type:"void","x-component":eQ.Drawer}}}}function eX(t){var n,r=(0,e.useCurrentUserContext)().data,i=(0,o.useFlowContext)().userJob,a=i.status,l=i.result,u=i.userId,s=(0,c.useFieldSchema)().parent.toJSON().name,p=t.children;return a?l[s]||(p=null):(null==r||null==(n=r.data)?void 0:n.id)!==u&&(p=null),p}var eZ=(0,t.createContext)(null);function e0(r){var i=r.value,a=r.children,l=(0,o.useFlowContext)(),s=l.userJob,p=l.execution,f=(0,c.useField)(),m=(0,c.useFieldSchema)(),d=(0,e.useCompile)();return(0,t.useEffect)(function(){if(p.status||s.status){var e;f.disabled=!0,f.visible=s.status===i&&(null==(e=s.result)?void 0:e._)===m.name}},[p,s,i,f,m.name]),n().createElement(eZ.Provider,{value:i},p.status||s.status?n().createElement(u.Button,{type:"primary",disabled:!0},d(m.title)):a)}function e1(){var t,n=(0,e.useAPIClient)(),r=(0,e.useActionContext)(),i=r.setVisible,a=r.setSubmitted,l=(0,c.useForm)(),u=l.values,s=l.submit,p=(0,c.useField)(),f=(0,c.useFieldSchema)(),m=(0,e.useListBlockContext)().service,d=(0,o.useFlowContext)(),y=d.userJob,b=d.execution,v=f.name,h=f.parent.parent.name,g=(null!=(t=null==f?void 0:f["x-action-settings"])?t:{}).assignedValues,x=void 0===g?{}:g;return{run:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:if(b.status||y.status)return[2];return[4,s()];case 1:return t.sent(),p.data=p.data||{},p.data.loading=!0,[4,n.resource("workflowManualTasks").submit({filterByTk:y.id,values:{result:(eV(e={},h,e_({},u,x.values)),eV(e,"_",v),e)}})];case 2:return t.sent(),p.data.loading=!1,a(!0),i(!1),null==m||m.refresh(),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eN(i,r,o,a,l,"next",e)}function l(e){eN(i,r,o,a,l,"throw",e)}a(void 0)})})()}}}function e2(r){var a,l=(0,e.usePlugin)(i()),c=(0,e.useAPIClient)(),s=((0,e.useCollectionRecordData)()||{}).id,p=eW((0,t.useState)(null),2),f=p[0],m=p[1],d=eW((0,t.useState)(null),2),y=d[0],b=d[1];(0,t.useEffect)(function(){var e,t;s&&(null==(e=(t=c.resource("workflowManualTasks")).get)||e.call(t,{filterByTk:s,appends:["node","job","workflow","workflow.nodes","execution","execution.jobs"]}).then(function(e){var t,n=e.data,r=null!=(t=null==n?void 0:n.data)?t:{},i=r.node,a=r.workflow,l=(void 0===a?{}:a).nodes,c=void 0===l?[]:l,u=r.execution,s=eU(r.workflow,["nodes"]),p=eU(r,["node","workflow","execution"]);(0,o.linkNodes)(c),b(i),m({userJob:p,workflow:s,nodes:c,execution:u})}))},[c,s]);var v=(0,o.useAvailableUpstreams)(null==f?void 0:f.nodes.find(function(e){return e.id===y.id})).reduce(function(e,t){var n=t.type;return Object.assign(e,l.instructions.get(n).components)},{});return y&&f?n().createElement(o.FlowContext.Provider,{value:f},n().createElement(e.SchemaComponent,{components:e_({FormBlockProvider:w,DetailsBlockProvider:o.DetailsBlockProvider,ActionBarProvider:eX,ManualActionStatusProvider:e0},Array.from(eu.getValues()).reduce(function(e,t){return Object.assign(e,t.block.components)},{}),v),scope:e_({useSubmit:e1,useFormBlockProps:e3,useDetailsBlockProps:e6},Array.from(eu.getValues()).reduce(function(e,t){return Object.assign(e,t.block.scope)},{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:null==(a=y.config)?void 0:a.schema}})):n().createElement(u.Spin,null)}function e3(){var n,r=(0,o.useFlowContext)(),i=r.userJob,a=r.execution,l=(0,e.useCollectionRecordData)(),c=(0,e.useCurrentUserContext)().data,u=(0,e.useFormBlockContext)().form,s=a.status||i.status?l?"readPretty":"disabled":(null==c||null==(n=c.data)?void 0:n.id)!==i.userId?"disabled":"editable";return(0,t.useEffect)(function(){null==u||u.setPattern(s)},[s,u]),{form:u}}function e6(){return{form:(0,e.useFormBlockContext)().form}}function e5(){var t=(0,e.useCompile)(),r=(0,e.useCollectionRecordData)()||{},o=r.status,i=r.updatedAt,a=d[o];return o?n().createElement(u.Space,{className:(0,e.css)(eL())},n().createElement("time",null,eR()(i).format("YYYY-MM-DD HH:mm:ss")),n().createElement(u.Tag,{color:a.color},t(a.label))):null}function e8(){var r,o=(0,t.useContext)(e.SchemaComponentContext),i=(0,e.useCollectionRecordData)()||{},a=i.id,l=i.node,c=i.workflow,u=i.status;return n().createElement(e.SchemaComponentContext.Provider,{value:eq(e_({},o),{reset:function(){},designable:!1})},n().createElement(e.SchemaComponent,{components:{FooterStatus:e5,FlowContextProvider:e2},schema:{type:"void",name:"drawer-".concat(a,"-").concat(u),"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},title:"".concat(null==c?void 0:c.title," - ").concat(null!=(r=null==l?void 0:l.title)?r:"#".concat(null==l?void 0:l.id)),properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Container.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}}))}function e4(t){var r=(0,s.useTranslation)().t,o=(0,eM.useAntdToken)();return n().createElement(u.ConfigProvider,{theme:{token:{fontSizeLG:14}}},n().createElement(u.Descriptions,eq(e_({},t),{column:1,items:[{key:"createdAt",label:r("Created at"),children:n().createElement(e.SchemaComponent,{schema:{name:"createdAt",type:"string","x-component":"CollectionField","x-read-pretty":!0}})},{key:"status",label:r("Status",{ns:"workflow"}),children:n().createElement(e.SchemaComponent,{components:{TaskStatusColumn:eK},schema:{name:"status",type:"number","x-decorator":"TaskStatusColumn","x-component":"CollectionField","x-read-pretty":!0}})}],className:(0,e.css)(eJ(),o.colorTextDescription)})))}function e7(e){return n().createElement(e4,{title:n().createElement(eY,{dataIndex:["title","node.title"]}),extra:n().createElement(eY,{dataIndex:"workflow.title"})})}eZ.displayName="ManualActionStatusContext",eQ.Initializer=function(){var t=(0,e.useSchemaInitializerItem)(),o=(0,e.useSchemaInitializer)().insert;return n().createElement(e.SchemaInitializerItem,eq(e_({icon:n().createElement(r.TableOutlined,null)},t),{onClick:function(){o({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"}}})}}))},eQ.Drawer=e8,eQ.Decorator=function(t){var r=t.params,o=void 0===r?{}:r,i=t.children,a={collection:"workflowManualTasks",resource:"workflowManualTasks",action:"list",params:eq(e_({pageSize:20,sort:["-createdAt"]},o),{filter:e_({},o.filter),appends:["user","node","workflow","execution.status"],except:["node.config","workflow.config","workflow.options"]})};return n().createElement(e.OpenModeProvider,{defaultOpenMode:"modal"},n().createElement(e.List.Decorator,a,i))};var e9={pending:{status:0,"execution.status":o.EXECUTION_STATUS.STARTED},completed:{status:[1,-5]}},te={title:'{{t("My manual tasks", { ns: "'.concat(f,'" })}}'),collection:"workflowManualTasks",action:"listMine",useActionParams:function(t){var n;return(0,e.useCurrentUserContext)().data,{filter:null!=(n=e9[t])?n:{},appends:["job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]}},Actions:function(){return n().createElement(e.SchemaComponent,{schema:{name:"actions",type:"void","x-component":"ActionBar",properties:{refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},filter:{type:"void",title:'{{t("Filter")}}',"x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},default:{$and:[{title:{$includes:""}},{"workflow.title":{$includes:""}}]}}}}})},Item:function(){var r=(0,eM.useAntdToken)(),i=(0,e.useCollectionRecordData)(),a=(0,eD.useNavigate)(),l=(0,o.usePopupRecordContext)().setRecord,c=(0,t.useCallback)(function(e){var t=e.target;e.currentTarget.contains(t)&&(l(i),a("./".concat(i.id))),e.stopPropagation()},[a,i.id]);return n().createElement(u.Card,{onClick:c,hoverable:!0,size:"small",title:i.title,extra:n().createElement(o.WorkflowTitle,i.workflow),className:(0,e.css)(e$(),r.colorTextDescription)},n().createElement(e4,null))},Detail:e8},tt={title:'{{t("Workflow todos", { ns: "'.concat(f,'" })}}'),name:"workflowManualTasks",fields:[{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Task title", { ns: "'.concat(f,'" })}}'),"x-component":"Input"}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"AssociationField","x-component-props":{fieldNames:{label:"title",value:"id"}}}},{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",isAssociation:!0,uiSchema:{type:"object",title:'{{t("Assignee", { ns: "'.concat(f,'" })}}'),"x-component":"AssociationField","x-component-props":{fieldNames:{label:"nickname",value:"id"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:'{{t("Status", { ns: "workflow" })}}',"x-component":"Select",enum:m}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},tn=function(t){return n().createElement(e.ExtendCollectionsProvider,{collections:[tt]},t.children)};function tr(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function to(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){tr(i,r,o,a,l,"next",e)}function l(e){tr(i,r,o,a,l,"throw",e)}a(void 0)})}}function ti(e,t,n){return(ti=tu()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&tl(o,n.prototype),o}).apply(null,arguments)}[tt.name].forEach(function(t){var n=eH({defaultOpenMode:window.location.pathname.startsWith("/m/")?"page":"modal",collectionName:t});(0,e.storePopupContext)(n["x-uid"],function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({schema:n},n["x-action-context"]))});function ta(e){return(ta=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function tl(e,t){return(tl=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tc(e){var t="function"==typeof Map?new Map:void 0;return(tc=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return ti(e,arguments,ta(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),tl(n,e)})(e)}function tu(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(tu=function(){return!!e})()}function ts(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){var c=[i,l];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var tp=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=ta(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,tu()?Reflect.construct(e,t||[],ta(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&tl(n,e),t=[{key:"afterAdd",value:function(){return to(function(){return ts(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return to(function(){var t;return ts(this,function(n){return e.addComponents(),e.app.addProvider(tn),(t=e.app.pm.get("workflow")).registerInstruction("manual",eT),t.registerTaskType("manual",te),e.app.schemaInitializerManager.add(ep),e.app.schemaInitializerManager.add(ef),e.app.schemaInitializerManager.add(ev),e.app.schemaInitializerManager.add(eh),e.app.schemaInitializerManager.add(Q),e.app.schemaInitializerManager.add(H),e.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflowTodos",{title:'{{t("Workflow todos", { ns: "'.concat(f,'" })}}'),Component:"WorkflowTodo.Initializer",icon:"CheckSquareOutlined"}),e.app.schemaInitializerManager.addItem("mobile:addBlock","otherBlocks.workflowTodos",{title:'{{t("Workflow todos", { ns: "'.concat(f,'" })}}'),Component:"WorkflowTodo.Initializer",icon:"CheckSquareOutlined"}),[2]})})()}},{key:"addComponents",value:function(){this.app.addComponents({WorkflowTodo:eQ})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(tc(e.Plugin))}(),v}()});
|
package/dist/common/constants.js
CHANGED
package/dist/externalVersion.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.
|
|
11
|
+
"@nocobase/client": "1.8.0-alpha.1",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
+
"react-router-dom": "6.28.1",
|
|
13
14
|
"@formily/react": "2.3.0",
|
|
14
15
|
"@formily/antd-v5": "1.2.3",
|
|
15
16
|
"antd": "5.24.2",
|
|
@@ -18,14 +19,14 @@ module.exports = {
|
|
|
18
19
|
"dayjs": "1.11.13",
|
|
19
20
|
"react-i18next": "11.18.6",
|
|
20
21
|
"lodash": "4.17.21",
|
|
21
|
-
"@nocobase/plugin-workflow": "1.
|
|
22
|
-
"@nocobase/utils": "1.
|
|
23
|
-
"@nocobase/server": "1.
|
|
24
|
-
"@nocobase/
|
|
25
|
-
"@nocobase/
|
|
26
|
-
"@nocobase/
|
|
27
|
-
"@nocobase/
|
|
22
|
+
"@nocobase/plugin-workflow": "1.8.0-alpha.1",
|
|
23
|
+
"@nocobase/utils": "1.8.0-alpha.1",
|
|
24
|
+
"@nocobase/server": "1.8.0-alpha.1",
|
|
25
|
+
"@nocobase/database": "1.8.0-alpha.1",
|
|
26
|
+
"@nocobase/actions": "1.8.0-alpha.1",
|
|
27
|
+
"@nocobase/resourcer": "1.8.0-alpha.1",
|
|
28
|
+
"@nocobase/test": "1.8.0-alpha.1",
|
|
29
|
+
"@nocobase/plugin-workflow-test": "1.8.0-alpha.1",
|
|
28
30
|
"@formily/core": "2.3.0",
|
|
29
|
-
"@nocobase/database": "1.7.0-beta.9",
|
|
30
31
|
"sequelize": "6.35.2"
|
|
31
32
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -26,5 +26,10 @@
|
|
|
26
26
|
"Update record form": "Update record form",
|
|
27
27
|
"Filter settings": "Filter settings",
|
|
28
28
|
"Workflow todos": "Workflow todos",
|
|
29
|
-
"Task": "Task"
|
|
29
|
+
"Task node": "Task node",
|
|
30
|
+
"Unprocessed": "Unprocessed",
|
|
31
|
+
"Please check one of your update record form, and add at least one filter condition in form settings.": "Please check one of your update record form, and add at least one filter condition in form settings.",
|
|
32
|
+
"My manual tasks": "My manual tasks",
|
|
33
|
+
"Task title": "Task title",
|
|
34
|
+
"Title of each task item. Default to node title.": "Title of each task item. Default to node title."
|
|
30
35
|
}
|
package/dist/server/Plugin.d.ts
CHANGED
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Plugin } from '@nocobase/server';
|
|
10
|
+
import { Model } from '@nocobase/database';
|
|
10
11
|
export default class extends Plugin {
|
|
12
|
+
onTaskSave: (task: Model, { transaction }: {
|
|
13
|
+
transaction: any;
|
|
14
|
+
}) => Promise<void>;
|
|
15
|
+
onExecutionStatusChange: (execution: any, { transaction }: {
|
|
16
|
+
transaction: any;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
onWorkflowStatusChange: (workflow: any, { transaction }: {
|
|
19
|
+
transaction: any;
|
|
20
|
+
}) => Promise<void>;
|
|
11
21
|
load(): Promise<void>;
|
|
12
22
|
}
|
package/dist/server/Plugin.js
CHANGED
|
@@ -46,6 +46,217 @@ var jobActions = __toESM(require("./actions"));
|
|
|
46
46
|
var import_ManualInstruction = __toESM(require("./ManualInstruction"));
|
|
47
47
|
var import_constants = require("../common/constants");
|
|
48
48
|
class Plugin_default extends import_server.Plugin {
|
|
49
|
+
onTaskSave = async (task, { transaction }) => {
|
|
50
|
+
const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
|
|
51
|
+
const workflowId = Array.from(workflowPlugin.enabledCache.keys());
|
|
52
|
+
const ModelClass = task.constructor;
|
|
53
|
+
const pending = await ModelClass.count({
|
|
54
|
+
where: {
|
|
55
|
+
userId: task.userId,
|
|
56
|
+
workflowId,
|
|
57
|
+
status: import_constants.TASK_STATUS.PENDING
|
|
58
|
+
},
|
|
59
|
+
include: [
|
|
60
|
+
{
|
|
61
|
+
association: "execution",
|
|
62
|
+
attributes: [],
|
|
63
|
+
where: {
|
|
64
|
+
status: import_plugin_workflow.EXECUTION_STATUS.STARTED
|
|
65
|
+
},
|
|
66
|
+
required: true
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
col: "id",
|
|
70
|
+
distinct: true,
|
|
71
|
+
transaction
|
|
72
|
+
});
|
|
73
|
+
const all = await ModelClass.count({
|
|
74
|
+
where: {
|
|
75
|
+
userId: task.userId,
|
|
76
|
+
workflowId
|
|
77
|
+
},
|
|
78
|
+
col: "id",
|
|
79
|
+
transaction
|
|
80
|
+
});
|
|
81
|
+
await workflowPlugin.updateTasksStats(task.userId, import_constants.MANUAL_TASK_TYPE, { pending, all }, { transaction });
|
|
82
|
+
};
|
|
83
|
+
onExecutionStatusChange = async (execution, { transaction }) => {
|
|
84
|
+
if (!execution.status) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
|
|
88
|
+
if (!execution.workflow) {
|
|
89
|
+
execution.workflow = workflowPlugin.enabledCache.get(execution.workflowId) || await execution.getWorkflow({ transaction });
|
|
90
|
+
}
|
|
91
|
+
if (!execution.workflow.nodes) {
|
|
92
|
+
execution.workflow.nodes = await execution.workflow.getNodes({ transaction });
|
|
93
|
+
}
|
|
94
|
+
const manualNodes = execution.workflow.nodes.filter((node) => node.type === "manual");
|
|
95
|
+
if (!manualNodes.length) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const manualNodeIds = new Set(manualNodes.map((node) => node.id));
|
|
99
|
+
const WorkflowManualTaskModel = this.db.getModel("workflowManualTasks");
|
|
100
|
+
const manualTasks = await WorkflowManualTaskModel.findAll({
|
|
101
|
+
attributes: ["id", "userId"],
|
|
102
|
+
where: {
|
|
103
|
+
nodeId: Array.from(manualNodeIds),
|
|
104
|
+
executionId: execution.id
|
|
105
|
+
},
|
|
106
|
+
transaction
|
|
107
|
+
});
|
|
108
|
+
const userStatsMap = /* @__PURE__ */ new Map();
|
|
109
|
+
const userId = [];
|
|
110
|
+
for (const item of manualTasks) {
|
|
111
|
+
userId.push(item.userId);
|
|
112
|
+
userStatsMap.set(item.userId, { pending: 0, all: 0 });
|
|
113
|
+
}
|
|
114
|
+
const pendingCounts = await WorkflowManualTaskModel.count({
|
|
115
|
+
where: {
|
|
116
|
+
status: import_constants.TASK_STATUS.PENDING,
|
|
117
|
+
userId,
|
|
118
|
+
workflowId: execution.workflowId
|
|
119
|
+
},
|
|
120
|
+
include: [
|
|
121
|
+
{
|
|
122
|
+
association: "execution",
|
|
123
|
+
attributes: [],
|
|
124
|
+
where: {
|
|
125
|
+
status: import_plugin_workflow.EXECUTION_STATUS.STARTED
|
|
126
|
+
},
|
|
127
|
+
required: true
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
col: "id",
|
|
131
|
+
group: ["userId"],
|
|
132
|
+
transaction
|
|
133
|
+
});
|
|
134
|
+
const allCounts = await WorkflowManualTaskModel.count({
|
|
135
|
+
where: {
|
|
136
|
+
userId,
|
|
137
|
+
workflowId: execution.workflowId
|
|
138
|
+
},
|
|
139
|
+
col: "id",
|
|
140
|
+
group: ["userId"],
|
|
141
|
+
transaction
|
|
142
|
+
});
|
|
143
|
+
for (const row of pendingCounts) {
|
|
144
|
+
if (!userStatsMap.get(row.userId)) {
|
|
145
|
+
userStatsMap.set(row.userId, { pending: 0, all: 0 });
|
|
146
|
+
}
|
|
147
|
+
userStatsMap.set(row.userId, { ...userStatsMap.get(row.userId), pending: row.count });
|
|
148
|
+
}
|
|
149
|
+
for (const row of allCounts) {
|
|
150
|
+
if (!userStatsMap.get(row.userId)) {
|
|
151
|
+
userStatsMap.set(row.userId, { pending: 0, all: 0 });
|
|
152
|
+
}
|
|
153
|
+
userStatsMap.set(row.userId, { ...userStatsMap.get(row.userId), all: row.count });
|
|
154
|
+
}
|
|
155
|
+
for (const [userId2, stats] of userStatsMap.entries()) {
|
|
156
|
+
await workflowPlugin.updateTasksStats(userId2, import_constants.MANUAL_TASK_TYPE, stats, { transaction });
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
onWorkflowStatusChange = async (workflow, { transaction }) => {
|
|
160
|
+
const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
|
|
161
|
+
const WorkflowManualTaskModel = this.db.getModel("workflowManualTasks");
|
|
162
|
+
const enalbedSet = new Set(workflowPlugin.enabledCache.keys());
|
|
163
|
+
let pendingCounts = [];
|
|
164
|
+
let allCounts = [];
|
|
165
|
+
const userStatsMap = /* @__PURE__ */ new Map();
|
|
166
|
+
if (workflow.enabled) {
|
|
167
|
+
enalbedSet.add(workflow.id);
|
|
168
|
+
const workflowId = [...enalbedSet];
|
|
169
|
+
pendingCounts = await WorkflowManualTaskModel.count({
|
|
170
|
+
where: {
|
|
171
|
+
status: import_constants.TASK_STATUS.PENDING,
|
|
172
|
+
workflowId
|
|
173
|
+
},
|
|
174
|
+
include: [
|
|
175
|
+
{
|
|
176
|
+
association: "execution",
|
|
177
|
+
attributes: [],
|
|
178
|
+
where: {
|
|
179
|
+
status: import_plugin_workflow.EXECUTION_STATUS.STARTED
|
|
180
|
+
},
|
|
181
|
+
required: true
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
col: "id",
|
|
185
|
+
group: ["userId"],
|
|
186
|
+
transaction
|
|
187
|
+
});
|
|
188
|
+
allCounts = await WorkflowManualTaskModel.count({
|
|
189
|
+
where: {
|
|
190
|
+
workflowId
|
|
191
|
+
},
|
|
192
|
+
col: "id",
|
|
193
|
+
group: ["userId"],
|
|
194
|
+
transaction
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
enalbedSet.delete(workflow.id);
|
|
198
|
+
const workflowId = [...enalbedSet];
|
|
199
|
+
const tasksByUser = await WorkflowManualTaskModel.count({
|
|
200
|
+
col: "userId",
|
|
201
|
+
where: {
|
|
202
|
+
status: import_constants.TASK_STATUS.PENDING,
|
|
203
|
+
workflowId: workflow.id
|
|
204
|
+
},
|
|
205
|
+
distinct: true,
|
|
206
|
+
group: ["userId"],
|
|
207
|
+
transaction
|
|
208
|
+
});
|
|
209
|
+
const userId = [];
|
|
210
|
+
for (const item of tasksByUser) {
|
|
211
|
+
userId.push(item.userId);
|
|
212
|
+
userStatsMap.set(item.userId, { pending: 0, all: 0 });
|
|
213
|
+
}
|
|
214
|
+
pendingCounts = await WorkflowManualTaskModel.count({
|
|
215
|
+
where: {
|
|
216
|
+
status: import_constants.TASK_STATUS.PENDING,
|
|
217
|
+
userId,
|
|
218
|
+
workflowId
|
|
219
|
+
},
|
|
220
|
+
include: [
|
|
221
|
+
{
|
|
222
|
+
association: "execution",
|
|
223
|
+
attributes: [],
|
|
224
|
+
where: {
|
|
225
|
+
status: import_plugin_workflow.EXECUTION_STATUS.STARTED
|
|
226
|
+
},
|
|
227
|
+
required: true
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
col: "id",
|
|
231
|
+
group: ["userId"],
|
|
232
|
+
transaction
|
|
233
|
+
});
|
|
234
|
+
allCounts = await WorkflowManualTaskModel.count({
|
|
235
|
+
where: {
|
|
236
|
+
userId,
|
|
237
|
+
workflowId
|
|
238
|
+
},
|
|
239
|
+
col: "id",
|
|
240
|
+
group: ["userId"],
|
|
241
|
+
transaction
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
for (const row of pendingCounts) {
|
|
245
|
+
if (!userStatsMap.get(row.userId)) {
|
|
246
|
+
userStatsMap.set(row.userId, { pending: 0, all: 0 });
|
|
247
|
+
}
|
|
248
|
+
userStatsMap.set(row.userId, { ...userStatsMap.get(row.userId), pending: row.count });
|
|
249
|
+
}
|
|
250
|
+
for (const row of allCounts) {
|
|
251
|
+
if (!userStatsMap.get(row.userId)) {
|
|
252
|
+
userStatsMap.set(row.userId, { pending: 0, all: 0 });
|
|
253
|
+
}
|
|
254
|
+
userStatsMap.set(row.userId, { ...userStatsMap.get(row.userId), all: row.count });
|
|
255
|
+
}
|
|
256
|
+
for (const [userId, stats] of userStatsMap.entries()) {
|
|
257
|
+
await workflowPlugin.updateTasksStats(userId, import_constants.MANUAL_TASK_TYPE, stats, { transaction });
|
|
258
|
+
}
|
|
259
|
+
};
|
|
49
260
|
async load() {
|
|
50
261
|
this.app.resourceManager.define({
|
|
51
262
|
name: "workflowManualTasks",
|
|
@@ -69,20 +280,12 @@ class Plugin_default extends import_server.Plugin {
|
|
|
69
280
|
...jobActions
|
|
70
281
|
}
|
|
71
282
|
});
|
|
72
|
-
this.app.acl.allow("workflowManualTasks", ["list", "get", "submit"], "loggedIn");
|
|
283
|
+
this.app.acl.allow("workflowManualTasks", ["list", "listMine", "get", "submit"], "loggedIn");
|
|
73
284
|
const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
|
|
74
285
|
workflowPlugin.registerInstruction("manual", import_ManualInstruction.default);
|
|
75
|
-
this.db.on("workflowManualTasks.afterSave",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
key: `${task.id}`,
|
|
80
|
-
userId: task.userId,
|
|
81
|
-
workflowId: task.workflowId
|
|
82
|
-
},
|
|
83
|
-
Boolean(task.status),
|
|
84
|
-
options
|
|
85
|
-
);
|
|
86
|
-
});
|
|
286
|
+
this.db.on("workflowManualTasks.afterSave", this.onTaskSave);
|
|
287
|
+
this.db.on("workflowManualTasks.afterDestroy", this.onTaskSave);
|
|
288
|
+
this.db.on("executions.afterUpdate", this.onExecutionStatusChange);
|
|
289
|
+
this.db.on("workflows.afterUpdate", this.onWorkflowStatusChange);
|
|
87
290
|
}
|
|
88
291
|
}
|
package/dist/server/actions.d.ts
CHANGED
package/dist/server/actions.js
CHANGED
|
@@ -36,10 +36,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
var actions_exports = {};
|
|
38
38
|
__export(actions_exports, {
|
|
39
|
+
listMine: () => listMine,
|
|
39
40
|
submit: () => submit
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(actions_exports);
|
|
42
|
-
var import_actions = require("@nocobase/actions");
|
|
43
|
+
var import_actions = __toESM(require("@nocobase/actions"));
|
|
43
44
|
var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
|
|
44
45
|
async function submit(context, next) {
|
|
45
46
|
var _a, _b, _c;
|
|
@@ -109,7 +110,31 @@ async function submit(context, next) {
|
|
|
109
110
|
processor.logger.info(`manual node (${task.nodeId}) action trigger execution (${task.execution.id}) to resume`);
|
|
110
111
|
plugin.resume(task.job);
|
|
111
112
|
}
|
|
113
|
+
async function listMine(context, next) {
|
|
114
|
+
context.action.mergeParams({
|
|
115
|
+
filter: {
|
|
116
|
+
$and: [
|
|
117
|
+
{ userId: context.state.currentUser.id },
|
|
118
|
+
{
|
|
119
|
+
$or: [
|
|
120
|
+
{
|
|
121
|
+
"workflow.enabled": true
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"workflow.enabled": false,
|
|
125
|
+
status: {
|
|
126
|
+
$ne: import_plugin_workflow.JOB_STATUS.PENDING
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return import_actions.default.list(context, next);
|
|
135
|
+
}
|
|
112
136
|
// Annotate the CommonJS export names for ESM import in node:
|
|
113
137
|
0 && (module.exports = {
|
|
138
|
+
listMine,
|
|
114
139
|
submit
|
|
115
140
|
});
|
|
@@ -71,7 +71,8 @@ var workflowManualTasks_default = (0, import_database.defineCollection)({
|
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
type: "belongsTo",
|
|
74
|
-
name: "execution"
|
|
74
|
+
name: "execution",
|
|
75
|
+
onDelete: "CASCADE"
|
|
75
76
|
},
|
|
76
77
|
{
|
|
77
78
|
type: "belongsTo",
|
|
@@ -83,6 +84,7 @@ var workflowManualTasks_default = (0, import_database.defineCollection)({
|
|
|
83
84
|
name: "workflow",
|
|
84
85
|
target: "workflows",
|
|
85
86
|
foreignKey: "workflowId",
|
|
87
|
+
onDelete: "CASCADE",
|
|
86
88
|
interface: "m2o",
|
|
87
89
|
uiSchema: {
|
|
88
90
|
type: "object",
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
import { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
appVersion: string;
|
|
12
|
+
up(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var tasks_stats_exports = {};
|
|
28
|
+
__export(tasks_stats_exports, {
|
|
29
|
+
default: () => tasks_stats_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(tasks_stats_exports);
|
|
32
|
+
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
33
|
+
var import_server = require("@nocobase/server");
|
|
34
|
+
var import_constants = require("../../common/constants");
|
|
35
|
+
class tasks_stats_default extends import_server.Migration {
|
|
36
|
+
appVersion = "<1.7.0";
|
|
37
|
+
async up() {
|
|
38
|
+
const { db } = this.context;
|
|
39
|
+
const UserTaskModel = db.getModel("userWorkflowTasks");
|
|
40
|
+
const WorkflowManualTaskModel = db.getModel("workflowManualTasks");
|
|
41
|
+
const WorkflowRepo = db.getRepository("workflows");
|
|
42
|
+
const ExecutionRepo = db.getRepository("executions");
|
|
43
|
+
await db.sequelize.transaction(async (transaction) => {
|
|
44
|
+
const workflows = await WorkflowRepo.find({
|
|
45
|
+
filter: {
|
|
46
|
+
enabled: true
|
|
47
|
+
},
|
|
48
|
+
fields: ["id"],
|
|
49
|
+
transaction
|
|
50
|
+
});
|
|
51
|
+
const workflowId = workflows.map((item) => item.id);
|
|
52
|
+
const executions = await ExecutionRepo.find({
|
|
53
|
+
filter: {
|
|
54
|
+
status: import_plugin_workflow.EXECUTION_STATUS.STARTED,
|
|
55
|
+
workflowId
|
|
56
|
+
},
|
|
57
|
+
fields: ["id"],
|
|
58
|
+
transaction
|
|
59
|
+
});
|
|
60
|
+
const executionId = executions.map((item) => item.id);
|
|
61
|
+
const pendingCounts = await WorkflowManualTaskModel.count({
|
|
62
|
+
where: {
|
|
63
|
+
status: import_constants.TASK_STATUS.PENDING,
|
|
64
|
+
workflowId,
|
|
65
|
+
executionId
|
|
66
|
+
},
|
|
67
|
+
col: "id",
|
|
68
|
+
group: ["userId"],
|
|
69
|
+
transaction
|
|
70
|
+
});
|
|
71
|
+
const allCounts = await WorkflowManualTaskModel.count({
|
|
72
|
+
where: {
|
|
73
|
+
workflowId
|
|
74
|
+
},
|
|
75
|
+
col: "id",
|
|
76
|
+
group: ["userId"],
|
|
77
|
+
transaction
|
|
78
|
+
});
|
|
79
|
+
const userStatsMap = /* @__PURE__ */ new Map();
|
|
80
|
+
for (const row of pendingCounts) {
|
|
81
|
+
if (!userStatsMap.get(row.userId)) {
|
|
82
|
+
userStatsMap.set(row.userId, {});
|
|
83
|
+
}
|
|
84
|
+
userStatsMap.set(row.userId, { ...userStatsMap.get(row.userId), pending: row.count });
|
|
85
|
+
}
|
|
86
|
+
for (const row of allCounts) {
|
|
87
|
+
if (!userStatsMap.get(row.userId)) {
|
|
88
|
+
userStatsMap.set(row.userId, {});
|
|
89
|
+
}
|
|
90
|
+
userStatsMap.set(row.userId, { ...userStatsMap.get(row.userId), all: row.count });
|
|
91
|
+
}
|
|
92
|
+
for (const [userId, stats] of userStatsMap.entries()) {
|
|
93
|
+
const existed = await UserTaskModel.findOne({
|
|
94
|
+
where: {
|
|
95
|
+
type: import_constants.MANUAL_TASK_TYPE,
|
|
96
|
+
userId
|
|
97
|
+
},
|
|
98
|
+
transaction
|
|
99
|
+
});
|
|
100
|
+
if (existed) {
|
|
101
|
+
await existed.update(
|
|
102
|
+
{
|
|
103
|
+
stats
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
transaction
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
} else {
|
|
110
|
+
await UserTaskModel.create(
|
|
111
|
+
{
|
|
112
|
+
type: import_constants.MANUAL_TASK_TYPE,
|
|
113
|
+
userId,
|
|
114
|
+
stats
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
transaction
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:人工处理节点",
|
|
5
5
|
"description": "Could be used for workflows which some of decisions are made by users.",
|
|
6
6
|
"description.zh-CN": "用于人工控制部分决策的流程。",
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.8.0-alpha.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow-manual",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@nocobase/test": "1.x",
|
|
31
31
|
"@nocobase/utils": "1.x"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "bc81ea73ed91b18dfb7cfad0f353b825881b4cc7",
|
|
34
34
|
"keywords": [
|
|
35
35
|
"Workflow"
|
|
36
36
|
]
|