@nocobase/plugin-workflow 0.9.4-alpha.2 → 0.10.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/lib/client/AddButton.d.ts +2 -2
  2. package/lib/client/Branch.d.ts +2 -2
  3. package/lib/client/CanvasContent.d.ts +2 -2
  4. package/lib/client/ExecutionCanvas.d.ts +2 -2
  5. package/lib/client/ExecutionCanvas.js +1 -1
  6. package/lib/client/ExecutionLink.d.ts +2 -1
  7. package/lib/client/ExecutionPage.d.ts +2 -1
  8. package/lib/client/ExecutionPage.js +14 -15
  9. package/lib/client/ExecutionResourceProvider.d.ts +2 -1
  10. package/lib/client/WorkflowCanvas.d.ts +2 -2
  11. package/lib/client/WorkflowCanvas.js +31 -31
  12. package/lib/client/WorkflowLink.d.ts +2 -1
  13. package/lib/client/WorkflowPage.d.ts +2 -1
  14. package/lib/client/WorkflowPage.js +11 -10
  15. package/lib/client/WorkflowProvider.d.ts +1 -1
  16. package/lib/client/WorkflowProvider.js +15 -15
  17. package/lib/client/components/CollectionBlockInitializer.d.ts +2 -7
  18. package/lib/client/components/CollectionBlockInitializer.js +49 -17
  19. package/lib/client/components/CollectionFieldset.d.ts +2 -2
  20. package/lib/client/components/CollectionFieldset.js +18 -15
  21. package/lib/client/components/Duration.d.ts +2 -2
  22. package/lib/client/components/DynamicExpression.d.ts +3 -1
  23. package/lib/client/components/DynamicExpression.js +2 -0
  24. package/lib/client/components/FieldsSelect.d.ts +1 -1
  25. package/lib/client/components/FieldsSelect.js +2 -0
  26. package/lib/client/components/FilterDynamicComponent.d.ts +2 -2
  27. package/lib/client/components/NodeDescription.d.ts +2 -2
  28. package/lib/client/components/OpenDrawer.d.ts +2 -2
  29. package/lib/client/components/OpenDrawer.js +1 -1
  30. package/lib/client/components/RadioWithTooltip.d.ts +2 -2
  31. package/lib/client/components/renderEngineReference.d.ts +2 -1
  32. package/lib/client/constants.d.ts +2 -1
  33. package/lib/client/locale/zh-CN.d.ts +3 -0
  34. package/lib/client/locale/zh-CN.js +3 -0
  35. package/lib/client/nodes/aggregate.d.ts +1 -1
  36. package/lib/client/nodes/calculation.d.ts +4 -3
  37. package/lib/client/nodes/condition.d.ts +6 -4
  38. package/lib/client/nodes/condition.js +3 -1
  39. package/lib/client/nodes/create.d.ts +3 -6
  40. package/lib/client/nodes/create.js +1 -4
  41. package/lib/client/nodes/index.d.ts +5 -5
  42. package/lib/client/nodes/index.js +7 -4
  43. package/lib/client/nodes/loop.d.ts +4 -1
  44. package/lib/client/nodes/loop.js +3 -1
  45. package/lib/client/nodes/manual/AssigneesSelect.d.ts +2 -2
  46. package/lib/client/nodes/manual/DetailsBlockProvider.d.ts +2 -0
  47. package/lib/client/nodes/manual/DetailsBlockProvider.js +106 -0
  48. package/lib/client/nodes/manual/FormBlockInitializer.d.ts +2 -0
  49. package/lib/client/nodes/manual/FormBlockInitializer.js +106 -0
  50. package/lib/client/nodes/manual/FormBlockProvider.d.ts +2 -0
  51. package/lib/client/nodes/manual/FormBlockProvider.js +113 -0
  52. package/lib/client/nodes/manual/ModeConfig.d.ts +2 -2
  53. package/lib/client/nodes/manual/SchemaConfig.d.ts +43 -3
  54. package/lib/client/nodes/manual/SchemaConfig.js +42 -79
  55. package/lib/client/nodes/manual/WorkflowTodo.d.ts +5 -8
  56. package/lib/client/nodes/manual/WorkflowTodo.js +111 -76
  57. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -2
  58. package/lib/client/nodes/manual/forms/create.d.ts +3 -0
  59. package/lib/client/nodes/manual/forms/create.js +104 -0
  60. package/lib/client/nodes/manual/forms/custom.d.ts +3 -0
  61. package/lib/client/nodes/manual/forms/{customForm.js → custom.js} +63 -45
  62. package/lib/client/nodes/manual/forms/update.d.ts +3 -0
  63. package/lib/client/nodes/manual/forms/update.js +161 -0
  64. package/lib/client/nodes/manual/index.d.ts +2 -5
  65. package/lib/client/nodes/manual/index.js +17 -16
  66. package/lib/client/nodes/manual/utils.d.ts +2 -0
  67. package/lib/client/nodes/manual/utils.js +31 -0
  68. package/lib/client/nodes/parallel.d.ts +4 -1
  69. package/lib/client/nodes/parallel.js +3 -1
  70. package/lib/client/nodes/query.d.ts +2 -5
  71. package/lib/client/nodes/query.js +2 -5
  72. package/lib/client/nodes/request.d.ts +1 -1
  73. package/lib/client/nodes/request.js +1 -11
  74. package/lib/client/nodes/update.d.ts +1 -1
  75. package/lib/client/schemas/collection.js +1 -1
  76. package/lib/client/schemas/executions.d.ts +2 -0
  77. package/lib/client/triggers/collection.d.ts +2 -5
  78. package/lib/client/triggers/collection.js +5 -8
  79. package/lib/client/triggers/index.d.ts +1 -2
  80. package/lib/client/triggers/index.js +4 -3
  81. package/lib/client/triggers/schedule/DateFieldsSelect.js +14 -12
  82. package/lib/client/triggers/schedule/EndsByField.d.ts +2 -2
  83. package/lib/client/triggers/schedule/OnField.d.ts +2 -2
  84. package/lib/client/triggers/schedule/RepeatField.d.ts +2 -2
  85. package/lib/client/triggers/schedule/ScheduleConfig.d.ts +2 -1
  86. package/lib/client/triggers/schedule/index.d.ts +3 -6
  87. package/lib/client/triggers/schedule/index.js +1 -4
  88. package/lib/server/Processor.js +1 -2
  89. package/lib/server/instructions/manual/actions.js +42 -47
  90. package/lib/server/instructions/manual/forms/create.d.ts +5 -0
  91. package/lib/server/instructions/manual/forms/create.js +46 -0
  92. package/lib/server/instructions/manual/forms/index.d.ts +6 -0
  93. package/lib/server/instructions/manual/forms/index.js +15 -0
  94. package/lib/server/instructions/manual/forms/update.d.ts +6 -0
  95. package/lib/server/instructions/manual/forms/update.js +47 -0
  96. package/lib/server/instructions/manual/index.d.ts +3 -0
  97. package/lib/server/instructions/manual/index.js +16 -3
  98. package/lib/server/instructions/request.js +1 -1
  99. package/lib/server/migrations/20230612021134-manual-collection-block.d.ts +4 -0
  100. package/lib/server/migrations/20230612021134-manual-collection-block.js +155 -0
  101. package/package.json +16 -13
  102. package/lib/client/WorkflowShortcut.d.ts +0 -1
  103. package/lib/client/WorkflowShortcut.js +0 -48
  104. package/lib/client/components/CollectionFieldInitializers.d.ts +0 -2
  105. package/lib/client/components/CollectionFieldInitializers.js +0 -70
  106. package/lib/client/nodes/manual/forms/customForm.d.ts +0 -40
@@ -1,6 +1,46 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
+ import { ISchema } from '@formily/react';
3
+ import { SchemaInitializerItemOptions } from '@nocobase/client';
4
+ import { Registry } from '@nocobase/utils/client';
5
+ import { JOB_STATUS } from '../../constants';
6
+ declare type ValueOf<T> = T[keyof T];
7
+ export declare type FormType = {
8
+ type: 'create' | 'update' | 'custom';
9
+ title: string;
10
+ actions: ValueOf<typeof JOB_STATUS>[];
11
+ collection: string | {
12
+ name: string;
13
+ fields: any[];
14
+ [key: string]: any;
15
+ };
16
+ };
17
+ export declare type ManualFormType = {
18
+ title: string;
19
+ config: {
20
+ useInitializer: () => SchemaInitializerItemOptions;
21
+ initializers?: {
22
+ [key: string]: React.FC;
23
+ };
24
+ components?: {
25
+ [key: string]: React.FC;
26
+ };
27
+ parseFormOptions(root: ISchema): {
28
+ [key: string]: FormType;
29
+ };
30
+ };
31
+ block: {
32
+ scope?: {
33
+ [key: string]: () => any;
34
+ };
35
+ components?: {
36
+ [key: string]: React.FC;
37
+ };
38
+ };
39
+ };
40
+ export declare const manualFormTypes: Registry<ManualFormType>;
2
41
  export declare function SchemaConfig({ value, onChange }: {
3
42
  value: any;
4
43
  onChange: any;
5
- }): JSX.Element;
6
- export declare function SchemaConfigButton(props: any): JSX.Element;
44
+ }): React.JSX.Element;
45
+ export declare function SchemaConfigButton(props: any): React.JSX.Element;
46
+ export {};
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SchemaConfig = SchemaConfig;
7
7
  exports.SchemaConfigButton = SchemaConfigButton;
8
+ exports.manualFormTypes = void 0;
8
9
  function _react() {
9
10
  const data = _interopRequireWildcard(require("react"));
10
11
  _react = function _react() {
@@ -33,12 +34,23 @@ function _client() {
33
34
  };
34
35
  return data;
35
36
  }
37
+ function _client2() {
38
+ const data = require("@nocobase/utils/client");
39
+ _client2 = function _client2() {
40
+ return data;
41
+ };
42
+ return data;
43
+ }
36
44
  var _triggers = require("../../triggers");
37
45
  var _ = require("..");
38
46
  var _FlowContext = require("../../FlowContext");
39
47
  var _locale = require("../../locale");
40
48
  var _constants = require("../../constants");
41
- var _customForm = _interopRequireDefault(require("./forms/customForm"));
49
+ var _custom = _interopRequireDefault(require("./forms/custom"));
50
+ var _create = _interopRequireDefault(require("./forms/create"));
51
+ var _update = _interopRequireDefault(require("./forms/update"));
52
+ var _FormBlockProvider = require("./FormBlockProvider");
53
+ var _DetailsBlockProvider = require("./DetailsBlockProvider");
42
54
  const _excluded = ["action", "actionProps"];
43
55
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44
56
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -56,6 +68,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
56
68
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
57
69
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
58
70
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
71
+ const manualFormTypes = new (_client2().Registry)();
72
+ exports.manualFormTypes = manualFormTypes;
73
+ manualFormTypes.register('customForm', _custom.default);
74
+ manualFormTypes.register('createForm', _create.default);
75
+ manualFormTypes.register('updateForm', _update.default);
59
76
  function useTriggerInitializers() {
60
77
  const _useFlowContext = (0, _FlowContext.useFlowContext)(),
61
78
  workflow = _useFlowContext.workflow;
@@ -63,7 +80,7 @@ function useTriggerInitializers() {
63
80
  return trigger.useInitializers ? trigger.useInitializers(workflow.config) : null;
64
81
  }
65
82
  const blockTypeNames = {
66
- customForm: _customForm.default.title,
83
+ customForm: _custom.default.title,
67
84
  record: `{{t("Data record", { ns: "${_locale.NAMESPACE}" })}}`
68
85
  };
69
86
  function SimpleDesigner() {
@@ -102,20 +119,10 @@ function AddBlockButton(props) {
102
119
  }] : []), {
103
120
  type: 'itemGroup',
104
121
  title: '{{t("Form")}}',
105
- children: [_customForm.default.config.initializer
106
- // {
107
- // key: 'createForm',
108
- // type: 'item',
109
- // title: '{{t("Create record form")}}',
110
- // component: CustomFormBlockInitializer,
111
- // },
112
- // {
113
- // key: 'updateForm',
114
- // type: 'item',
115
- // title: '{{t("Update record form")}}',
116
- // component: CustomFormBlockInitializer,
117
- // }
118
- ]
122
+ children: Array.from(manualFormTypes.getValues()).map(item => {
123
+ const getInitializer = item.config.useInitializer;
124
+ return getInitializer();
125
+ })
119
126
  }, {
120
127
  type: 'itemGroup',
121
128
  title: '{{t("Other blocks")}}',
@@ -131,34 +138,6 @@ function AddBlockButton(props) {
131
138
  title: "{{t('Add block')}}"
132
139
  }));
133
140
  }
134
- function findSchema(schema, filter, onlyLeaf = false) {
135
- const result = [];
136
- if (!schema) {
137
- return result;
138
- }
139
- if (filter(schema) && (!onlyLeaf || !schema.properties)) {
140
- result.push(schema);
141
- return result;
142
- }
143
- if (schema.properties) {
144
- Object.keys(schema.properties).forEach(key => {
145
- result.push(...findSchema(schema.properties[key], filter));
146
- });
147
- }
148
- return result;
149
- }
150
- function SchemaComponentRefreshProvider(props) {
151
- const ctx = (0, _client().useSchemaComponentContext)();
152
- return _react().default.createElement(_client().SchemaComponentContext.Provider, {
153
- value: _objectSpread(_objectSpread({}, ctx), {}, {
154
- refresh() {
155
- var _ctx$refresh, _props$onRefresh;
156
- ctx === null || ctx === void 0 ? void 0 : (_ctx$refresh = ctx.refresh) === null || _ctx$refresh === void 0 ? void 0 : _ctx$refresh.call(ctx);
157
- props === null || props === void 0 ? void 0 : (_props$onRefresh = props.onRefresh) === null || _props$onRefresh === void 0 ? void 0 : _props$onRefresh.call(props);
158
- }
159
- })
160
- }, props.children);
161
- }
162
141
  function ActionInitializer(_ref) {
163
142
  let action = _ref.action,
164
143
  actionProps = _ref.actionProps,
@@ -219,9 +198,6 @@ function useSubmit() {
219
198
  run() {}
220
199
  };
221
200
  }
222
- function useFlowRecordFromBlock() {
223
- return {};
224
- }
225
201
  function SchemaConfig({
226
202
  value,
227
203
  onChange
@@ -240,7 +216,7 @@ function SchemaConfig({
240
216
  Object.assign(nodeInitializers, instruction.initializers);
241
217
  Object.assign(nodeComponents, instruction.components);
242
218
  });
243
- const schema = new (_react2().Schema)({
219
+ const schema = (0, _react().useMemo)(() => new (_react2().Schema)({
244
220
  properties: {
245
221
  drawer: {
246
222
  type: 'void',
@@ -279,43 +255,30 @@ function SchemaConfig({
279
255
  }
280
256
  }
281
257
  }
282
- });
258
+ }), []);
283
259
  return _react().default.createElement(_client().SchemaComponentContext.Provider, {
284
260
  value: _objectSpread(_objectSpread({}, ctx), {}, {
285
- designable: !workflow.executed
261
+ designable: !workflow.executed,
262
+ refresh() {
263
+ var _ctx$refresh;
264
+ (_ctx$refresh = ctx.refresh) === null || _ctx$refresh === void 0 ? void 0 : _ctx$refresh.call(ctx);
265
+ const _get = (0, _lodash().get)(schema.toJSON(), 'properties.drawer.properties'),
266
+ tabs = _get.tabs;
267
+ const forms = Array.from(manualFormTypes.getValues()).reduce((result, item) => Object.assign(result, item.config.parseFormOptions(tabs)), {});
268
+ form.setValuesIn('forms', forms);
269
+ onChange(tabs.properties);
270
+ }
286
271
  })
287
272
  }, _react().default.createElement(_client().SchemaInitializerProvider, {
288
273
  initializers: _objectSpread(_objectSpread(_objectSpread({
289
274
  AddBlockButton,
290
275
  AddActionButton
291
- }, trigger.initializers), nodeInitializers), _customForm.default.config.initializers)
292
- }, _react().default.createElement(SchemaComponentRefreshProvider, {
293
- onRefresh: () => {
294
- const forms = {};
295
- const _get = (0, _lodash().get)(schema.toJSON(), 'properties.drawer.properties'),
296
- tabs = _get.tabs;
297
- const formBlocks = findSchema(tabs, item => item['x-decorator'] === 'FormCollectionProvider');
298
- formBlocks.forEach(formBlock => {
299
- var _formBlock$xComponen;
300
- const _Object$keys = Object.keys(formBlock.properties),
301
- _Object$keys2 = _slicedToArray(_Object$keys, 1),
302
- formKey = _Object$keys2[0];
303
- const formSchema = formBlock.properties[formKey];
304
- const fields = findSchema(formSchema.properties.grid, item => item['x-component'] === 'CollectionField', true);
305
- formBlock['x-decorator-props'].collection.fields = fields.map(field => field['x-interface-options']);
306
- forms[formKey] = {
307
- type: 'custom',
308
- title: ((_formBlock$xComponen = formBlock['x-component-props']) === null || _formBlock$xComponen === void 0 ? void 0 : _formBlock$xComponen.title) || formKey,
309
- actions: findSchema(formSchema.properties.actions, item => item['x-component'] === 'Action').map(item => item['x-decorator-props'].value),
310
- collection: formBlock['x-decorator-props'].collection
311
- };
312
- });
313
- form.setValuesIn('forms', forms);
314
- onChange(tabs.properties);
315
- }
276
+ }, trigger.initializers), nodeInitializers), Array.from(manualFormTypes.getValues()).reduce((result, item) => Object.assign(result, item.config.initializers), {}))
316
277
  }, _react().default.createElement(_client().SchemaComponent, {
317
278
  schema: schema,
318
- components: _objectSpread(_objectSpread(_objectSpread({}, nodeComponents), _customForm.default.config.components), {}, {
279
+ components: _objectSpread(_objectSpread(_objectSpread({}, nodeComponents), Array.from(manualFormTypes.getValues()).reduce((result, item) => Object.assign(result, item.config.components), {})), {}, {
280
+ FormBlockProvider: _FormBlockProvider.FormBlockProvider,
281
+ DetailsBlockProvider: _DetailsBlockProvider.DetailsBlockProvider,
319
282
  // NOTE: fake provider component
320
283
  ManualActionStatusProvider(props) {
321
284
  return props.children;
@@ -327,9 +290,9 @@ function SchemaConfig({
327
290
  }),
328
291
  scope: {
329
292
  useSubmit,
330
- useFlowRecordFromBlock
293
+ useDetailsBlockProps: _client().useFormBlockContext
331
294
  }
332
- }))));
295
+ })));
333
296
  }
334
297
  function SchemaConfigButton(props) {
335
298
  const _useFlowContext3 = (0, _FlowContext.useFlowContext)(),
@@ -341,7 +304,7 @@ function SchemaConfigButton(props) {
341
304
  return _react().default.createElement(_react().default.Fragment, null, _react().default.createElement("div", {
342
305
  className: "ant-btn ant-btn-primary",
343
306
  onClick: () => setVisible(true)
344
- }, workflow.executed ? (0, _locale.lang)('View user interface') : (0, _locale.lang)('Configure user interface')), _react().default.createElement(_client().ActionContext.Provider, {
307
+ }, workflow.executed ? (0, _locale.lang)('View user interface') : (0, _locale.lang)('Configure user interface')), _react().default.createElement(_client().ActionContextProvider, {
345
308
  value: {
346
309
  visible,
347
310
  setVisible
@@ -1,8 +1,5 @@
1
- /// <reference types="react" />
2
- export declare function WorkflowTodo(): JSX.Element;
3
- export declare namespace WorkflowTodo {
4
- var Drawer: () => JSX.Element;
5
- var Decorator: ({ children }: {
6
- children: any;
7
- }) => JSX.Element;
8
- }
1
+ import React from 'react';
2
+ export declare const WorkflowTodo: React.FC & {
3
+ Drawer: React.FC;
4
+ Decorator: React.FC;
5
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WorkflowTodo = WorkflowTodo;
6
+ exports.WorkflowTodo = void 0;
7
7
  function _react() {
8
8
  const data = _interopRequireWildcard(require("react"));
9
9
  _react = function _react() {
@@ -58,9 +58,12 @@ var _locale = require("../../locale");
58
58
  var _FlowContext = require("../../FlowContext");
59
59
  var _ = require("..");
60
60
  var _utils = require("../../utils");
61
- var _customForm = _interopRequireDefault(require("./forms/customForm"));
61
+ var _SchemaConfig = require("./SchemaConfig");
62
+ var _FormBlockProvider = require("./FormBlockProvider");
63
+ var _DetailsBlockProvider = require("./DetailsBlockProvider");
62
64
  const _excluded = ["nodes"],
63
- _excluded2 = ["collections"];
65
+ _excluded2 = ["node", "workflow", "execution"],
66
+ _excluded3 = ["collections"];
64
67
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
65
68
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
66
69
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -224,18 +227,24 @@ const NodeColumn = (0, _react2().observer)(() => {
224
227
  var _field$value$title, _field$value, _field$value2;
225
228
  const field = (0, _react2().useField)();
226
229
  return (_field$value$title = field === null || field === void 0 ? void 0 : (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.title) !== null && _field$value$title !== void 0 ? _field$value$title : `#${(_field$value2 = field.value) === null || _field$value2 === void 0 ? void 0 : _field$value2.id}`;
230
+ }, {
231
+ displayName: 'NodeColumn'
227
232
  });
228
233
  const WorkflowColumn = (0, _react2().observer)(() => {
229
234
  var _field$value$title2, _field$value3, _field$value4;
230
235
  const field = (0, _react2().useField)();
231
236
  return (_field$value$title2 = field === null || field === void 0 ? void 0 : (_field$value3 = field.value) === null || _field$value3 === void 0 ? void 0 : _field$value3.title) !== null && _field$value$title2 !== void 0 ? _field$value$title2 : `#${(_field$value4 = field.value) === null || _field$value4 === void 0 ? void 0 : _field$value4.id}`;
237
+ }, {
238
+ displayName: 'WorkflowColumn'
232
239
  });
233
240
  const UserColumn = (0, _react2().observer)(() => {
234
241
  var _field$value$nickname, _field$value5, _field$value6;
235
242
  const field = (0, _react2().useField)();
236
243
  return (_field$value$nickname = field === null || field === void 0 ? void 0 : (_field$value5 = field.value) === null || _field$value5 === void 0 ? void 0 : _field$value5.nickname) !== null && _field$value$nickname !== void 0 ? _field$value$nickname : (_field$value6 = field.value) === null || _field$value6 === void 0 ? void 0 : _field$value6.id;
244
+ }, {
245
+ displayName: 'UserColumn'
237
246
  });
238
- function WorkflowTodo() {
247
+ const WorkflowTodo = () => {
239
248
  return _react().default.createElement(_client().SchemaComponent, {
240
249
  components: {
241
250
  NodeColumn,
@@ -373,7 +382,8 @@ function WorkflowTodo() {
373
382
  }
374
383
  }
375
384
  });
376
- }
385
+ };
386
+ exports.WorkflowTodo = WorkflowTodo;
377
387
  function ActionBarProvider(props) {
378
388
  // * status is done:
379
389
  // 1. form is this form: show action button, and emphasis used status button
@@ -383,10 +393,11 @@ function ActionBarProvider(props) {
383
393
  // 2. not current user: disabled action bar
384
394
  const _useCurrentUserContex = (0, _client().useCurrentUserContext)(),
385
395
  user = _useCurrentUserContex.data;
386
- const _useRecord = (0, _client().useRecord)(),
387
- status = _useRecord.status,
388
- result = _useRecord.result,
389
- userId = _useRecord.userId;
396
+ const _useFlowContext = (0, _FlowContext.useFlowContext)(),
397
+ userJob = _useFlowContext.userJob;
398
+ const status = userJob.status,
399
+ result = userJob.result,
400
+ userId = userJob.userId;
390
401
  const buttonSchema = (0, _react2().useFieldSchema)();
391
402
  const _buttonSchema$parent$ = buttonSchema.parent.toJSON(),
392
403
  name = _buttonSchema$parent$.name;
@@ -408,15 +419,15 @@ function ManualActionStatusProvider({
408
419
  value,
409
420
  children
410
421
  }) {
411
- const _useRecord2 = (0, _client().useRecord)(),
412
- status = _useRecord2.status;
422
+ const _useFlowContext2 = (0, _FlowContext.useFlowContext)(),
423
+ userJob = _useFlowContext2.userJob;
413
424
  const button = (0, _react2().useField)();
414
425
  (0, _react().useEffect)(() => {
415
- if (status) {
426
+ if (userJob.status) {
416
427
  button.disabled = true;
417
- button.visible = status === value;
428
+ button.visible = userJob.status === value;
418
429
  }
419
- }, [status, value]);
430
+ }, [userJob.status, value, button]);
420
431
  return _react().default.createElement(ManualActionStatusContext.Provider, {
421
432
  value: value
422
433
  }, children);
@@ -432,8 +443,10 @@ function useSubmit() {
432
443
  const nextStatus = (0, _react().useContext)(ManualActionStatusContext);
433
444
  const _useTableBlockContext = (0, _client().useTableBlockContext)(),
434
445
  service = _useTableBlockContext.service;
435
- const _useRecord3 = (0, _client().useRecord)(),
436
- id = _useRecord3.id;
446
+ const _useFlowContext3 = (0, _FlowContext.useFlowContext)(),
447
+ userJob = _useFlowContext3.userJob;
448
+ const _useContext = (0, _react().useContext)(_client().FormBlockContext),
449
+ updateAssociationValues = _useContext.updateAssociationValues;
437
450
  return {
438
451
  run() {
439
452
  return _asyncToGenerator(function* () {
@@ -441,13 +454,14 @@ function useSubmit() {
441
454
  const _buttonSchema$parent$2 = buttonSchema.parent.parent.toJSON(),
442
455
  name = _buttonSchema$parent$2.name;
443
456
  yield api.resource('users_jobs').submit({
444
- filterByTk: id,
457
+ filterByTk: userJob.id,
445
458
  values: {
446
459
  status: nextStatus,
447
460
  result: {
448
461
  [name]: values
449
462
  }
450
- }
463
+ },
464
+ updateAssociationValues
451
465
  });
452
466
  setVisible(false);
453
467
  service.refresh();
@@ -455,33 +469,19 @@ function useSubmit() {
455
469
  }
456
470
  };
457
471
  }
458
- function useFlowRecordFromBlock(opts) {
459
- var _execution$jobs;
460
- const _useFieldSchema = (0, _react2().useFieldSchema)(),
461
- dataSource = _useFieldSchema['x-context-datasource'];
462
- const _useFlowContext = (0, _FlowContext.useFlowContext)(),
463
- execution = _useFlowContext.execution;
464
- const result = (0, _client2().parse)(dataSource)({
465
- $context: execution === null || execution === void 0 ? void 0 : execution.context,
466
- $jobsMapByNodeId: ((_execution$jobs = execution === null || execution === void 0 ? void 0 : execution.jobs) !== null && _execution$jobs !== void 0 ? _execution$jobs : []).reduce((map, job) => Object.assign(map, {
467
- [job.nodeId]: job.result
468
- }), {})
469
- });
470
- return (0, _client().useRequest)(() => {
471
- return Promise.resolve({
472
- data: result
473
- });
474
- }, opts);
475
- }
476
472
  function FlowContextProvider(props) {
473
+ var _node$config;
477
474
  const api = (0, _client().useAPIClient)();
478
- const _useRecord4 = (0, _client().useRecord)(),
479
- id = _useRecord4.id,
480
- node = _useRecord4.node;
475
+ const _useRecord = (0, _client().useRecord)(),
476
+ id = _useRecord.id;
481
477
  const _useState = (0, _react().useState)(null),
482
478
  _useState2 = _slicedToArray(_useState, 2),
483
479
  flowContext = _useState2[0],
484
480
  setFlowContext = _useState2[1];
481
+ const _useState3 = (0, _react().useState)(null),
482
+ _useState4 = _slicedToArray(_useState3, 2),
483
+ node = _useState4[0],
484
+ setNode = _useState4[1];
485
485
  (0, _react().useEffect)(() => {
486
486
  var _api$resource$get, _api$resource;
487
487
  if (!id) {
@@ -489,50 +489,90 @@ function FlowContextProvider(props) {
489
489
  }
490
490
  (_api$resource$get = (_api$resource = api.resource('users_jobs')).get) === null || _api$resource$get === void 0 ? void 0 : _api$resource$get.call(_api$resource, {
491
491
  filterByTk: id,
492
- appends: ['workflow', 'workflow.nodes', 'execution', 'execution.jobs']
492
+ appends: ['node', 'workflow', 'workflow.nodes', 'execution', 'execution.jobs']
493
493
  }).then(({
494
494
  data
495
495
  }) => {
496
496
  var _data$data;
497
497
  const _ref = (_data$data = data === null || data === void 0 ? void 0 : data.data) !== null && _data$data !== void 0 ? _data$data : {},
498
+ node = _ref.node,
498
499
  _ref$workflow = _ref.workflow,
499
500
  _ref$workflow2 = _ref$workflow === void 0 ? {} : _ref$workflow,
500
501
  _ref$workflow2$nodes = _ref$workflow2.nodes,
501
502
  nodes = _ref$workflow2$nodes === void 0 ? [] : _ref$workflow2$nodes,
502
503
  workflow = _objectWithoutProperties(_ref$workflow2, _excluded),
503
- execution = _ref.execution;
504
+ execution = _ref.execution,
505
+ userJob = _objectWithoutProperties(_ref, _excluded2);
504
506
  (0, _utils.linkNodes)(nodes);
507
+ setNode(node);
505
508
  setFlowContext({
509
+ userJob,
506
510
  workflow,
507
511
  nodes,
508
512
  execution
509
513
  });
514
+ return;
510
515
  });
511
516
  }, [id]);
512
- if (!flowContext) {
513
- return null;
514
- }
515
- const upstreams = (0, _.useAvailableUpstreams)(flowContext.nodes.find(item => item.id === node.id));
517
+ const upstreams = (0, _.useAvailableUpstreams)(flowContext === null || flowContext === void 0 ? void 0 : flowContext.nodes.find(item => item.id === node.id));
516
518
  const nodeComponents = upstreams.reduce((components, {
517
519
  type
518
520
  }) => Object.assign(components, _.instructions.get(type).components), {});
519
- return _react().default.createElement(_FlowContext.FlowContext.Provider, {
521
+ return node && flowContext ? _react().default.createElement(_FlowContext.FlowContext.Provider, {
520
522
  value: flowContext
521
- }, _react().default.createElement(_client().SchemaComponentOptions, {
522
- components: _objectSpread({}, nodeComponents)
523
- }, props.children));
523
+ }, _react().default.createElement(_client().SchemaComponent, {
524
+ components: _objectSpread(_objectSpread({
525
+ FormBlockProvider: _FormBlockProvider.FormBlockProvider,
526
+ DetailsBlockProvider: _DetailsBlockProvider.DetailsBlockProvider,
527
+ ActionBarProvider,
528
+ ManualActionStatusProvider
529
+ }, Array.from(_SchemaConfig.manualFormTypes.getValues()).reduce((result, item) => Object.assign(result, item.block.components), {})), nodeComponents),
530
+ scope: _objectSpread({
531
+ useSubmit,
532
+ useFormBlockProps,
533
+ useDetailsBlockProps
534
+ }, Array.from(_SchemaConfig.manualFormTypes.getValues()).reduce((result, item) => Object.assign(result, item.block.scope), {})),
535
+ schema: {
536
+ type: 'void',
537
+ name: 'tabs',
538
+ 'x-component': 'Tabs',
539
+ properties: (_node$config = node.config) === null || _node$config === void 0 ? void 0 : _node$config.schema
540
+ }
541
+ })) : _react().default.createElement(_antd().Spin, null);
542
+ }
543
+ function useFormBlockProps() {
544
+ var _user$data2;
545
+ const _useFlowContext4 = (0, _FlowContext.useFlowContext)(),
546
+ userJob = _useFlowContext4.userJob;
547
+ const record = (0, _client().useRecord)();
548
+ const _useCurrentUserContex2 = (0, _client().useCurrentUserContext)(),
549
+ user = _useCurrentUserContex2.data;
550
+ const _useFormBlockContext = (0, _client().useFormBlockContext)(),
551
+ form = _useFormBlockContext.form;
552
+ const pattern = userJob.status ? record ? 'readPretty' : 'disabled' : (user === null || user === void 0 ? void 0 : (_user$data2 = user.data) === null || _user$data2 === void 0 ? void 0 : _user$data2.id) !== userJob.userId ? 'disabled' : 'editable';
553
+ (0, _react().useEffect)(() => {
554
+ form === null || form === void 0 ? void 0 : form.setPattern(pattern);
555
+ }, [pattern, form]);
556
+ return {
557
+ form
558
+ };
524
559
  }
525
- WorkflowTodo.Drawer = function () {
526
- var _node$config, _node$title;
560
+ function useDetailsBlockProps() {
561
+ const _useFormBlockContext2 = (0, _client().useFormBlockContext)(),
562
+ form = _useFormBlockContext2.form;
563
+ return {
564
+ form
565
+ };
566
+ }
567
+ function Drawer() {
568
+ var _node$title;
527
569
  const ctx = (0, _react().useContext)(_client().SchemaComponentContext);
528
- const _useRecord5 = (0, _client().useRecord)(),
529
- id = _useRecord5.id,
530
- node = _useRecord5.node,
531
- workflow = _useRecord5.workflow,
532
- status = _useRecord5.status,
533
- updatedAt = _useRecord5.updatedAt;
534
- const _ref2 = (_node$config = node.config) !== null && _node$config !== void 0 ? _node$config : {},
535
- schema = _ref2.schema;
570
+ const _useRecord2 = (0, _client().useRecord)(),
571
+ id = _useRecord2.id,
572
+ node = _useRecord2.node,
573
+ workflow = _useRecord2.workflow,
574
+ status = _useRecord2.status,
575
+ updatedAt = _useRecord2.updatedAt;
536
576
  const statusOption = _constants.JobStatusOptionsMap[status];
537
577
  const footerSchema = status ? {
538
578
  date: {
@@ -557,15 +597,14 @@ WorkflowTodo.Drawer = function () {
557
597
  } : null;
558
598
  return _react().default.createElement(_client().SchemaComponentContext.Provider, {
559
599
  value: _objectSpread(_objectSpread({}, ctx), {}, {
600
+ reset() {},
560
601
  designable: false
561
602
  })
562
603
  }, _react().default.createElement(_client().SchemaComponent, {
563
- components: _objectSpread({
604
+ components: {
564
605
  Tag: _antd().Tag,
565
- ActionBarProvider,
566
- ManualActionStatusProvider,
567
606
  FlowContextProvider
568
- }, _customForm.default.block.components),
607
+ },
569
608
  schema: {
570
609
  type: 'void',
571
610
  name: `drawer-${id}-${status}`,
@@ -577,9 +616,7 @@ WorkflowTodo.Drawer = function () {
577
616
  properties: {
578
617
  tabs: {
579
618
  type: 'void',
580
- 'x-decorator': 'FlowContextProvider',
581
- 'x-component': 'Tabs',
582
- properties: schema
619
+ 'x-component': 'FlowContextProvider'
583
620
  },
584
621
  footer: {
585
622
  type: 'void',
@@ -587,19 +624,15 @@ WorkflowTodo.Drawer = function () {
587
624
  properties: footerSchema
588
625
  }
589
626
  }
590
- },
591
- scope: _objectSpread({
592
- useSubmit,
593
- useFlowRecordFromBlock
594
- }, _customForm.default.block.scope)
627
+ }
595
628
  }));
596
- };
597
- WorkflowTodo.Decorator = function ({
629
+ }
630
+ function Decorator({
598
631
  children
599
632
  }) {
600
633
  const _useCollectionManager = (0, _client().useCollectionManager)(),
601
634
  collections = _useCollectionManager.collections,
602
- cm = _objectWithoutProperties(_useCollectionManager, _excluded2);
635
+ cm = _objectWithoutProperties(_useCollectionManager, _excluded3);
603
636
  const blockProps = {
604
637
  collection: 'users_jobs',
605
638
  resource: 'users_jobs',
@@ -608,7 +641,7 @@ WorkflowTodo.Decorator = function ({
608
641
  pageSize: 20,
609
642
  sort: ['-createdAt'],
610
643
  appends: ['user', 'node', 'workflow'],
611
- except: ['workflow.config']
644
+ except: ['node.config', 'workflow.config']
612
645
  },
613
646
  rowKey: 'id',
614
647
  showIndex: true,
@@ -617,4 +650,6 @@ WorkflowTodo.Decorator = function ({
617
650
  return _react().default.createElement(_client().CollectionManagerProvider, _objectSpread(_objectSpread({}, cm), {}, {
618
651
  collections: [...collections, nodeCollection, workflowCollection, todoCollection]
619
652
  }), _react().default.createElement(_client().TableBlockProvider, _objectSpread({}, blockProps), children));
620
- };
653
+ }
654
+ WorkflowTodo.Drawer = Drawer;
655
+ WorkflowTodo.Decorator = Decorator;
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare function WorkflowTodoBlockInitializer({ insert, ...props }: {
3
3
  [x: string]: any;
4
4
  insert: any;
5
- }): JSX.Element;
5
+ }): React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { ManualFormType } from '../SchemaConfig';
2
+ declare const _default: ManualFormType;
3
+ export default _default;