@nocobase/plugin-workflow 0.9.4-alpha.1 → 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
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _react() {
8
+ const data = _interopRequireDefault(require("react"));
9
+ _react = function _react() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _client() {
15
+ const data = require("@nocobase/client");
16
+ _client = function _client() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ var _locale = require("../../../locale");
22
+ var _utils = require("../utils");
23
+ var _FormBlockInitializer = require("../FormBlockInitializer");
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
26
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
27
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
29
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
30
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
+ function CreateFormDesigner() {
32
+ const _useCollection = (0, _client().useCollection)(),
33
+ name = _useCollection.name,
34
+ title = _useCollection.title;
35
+ return _react().default.createElement(_client().GeneralSchemaDesigner, {
36
+ title: title || name
37
+ }, _react().default.createElement(_client().SchemaSettings.BlockTitleItem, null), _react().default.createElement(_client().SchemaSettings.LinkageRules, {
38
+ collectionName: name
39
+ }), _react().default.createElement(_client().SchemaSettings.DataTemplates, {
40
+ collectionName: name
41
+ }), _react().default.createElement(_client().SchemaSettings.Divider, null), _react().default.createElement(_client().SchemaSettings.Remove, {
42
+ removeParentsIfNoChildren: true,
43
+ breakRemoveOn: {
44
+ 'x-component': 'Grid'
45
+ }
46
+ }));
47
+ }
48
+ var _default = {
49
+ title: `{{t("Create record form", { ns: "${_locale.NAMESPACE}" })}}`,
50
+ config: {
51
+ useInitializer() {
52
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
53
+ collections = _useCollectionManager.collections;
54
+ return {
55
+ key: 'createRecordForm',
56
+ type: 'subMenu',
57
+ title: `{{t("Create record form", { ns: "${_locale.NAMESPACE}" })}}`,
58
+ children: collections.filter(item => !item.hidden).map(item => ({
59
+ key: `createForm-${item.name}`,
60
+ type: 'item',
61
+ title: item.title,
62
+ schema: {
63
+ collection: item.name,
64
+ title: `{{t("Create record", { ns: "${_locale.NAMESPACE}" })}}`,
65
+ formType: 'create',
66
+ 'x-designer': 'CreateFormDesigner'
67
+ },
68
+ component: _FormBlockInitializer.FormBlockInitializer
69
+ }))
70
+ };
71
+ },
72
+ initializers: {
73
+ // AddCustomFormField
74
+ },
75
+ components: {
76
+ CreateFormDesigner
77
+ },
78
+ parseFormOptions(root) {
79
+ const forms = {};
80
+ const formBlocks = (0, _utils.findSchema)(root, item => item['x-decorator'] === 'FormBlockProvider' && item['x-decorator-props'].formType === 'create');
81
+ formBlocks.forEach(formBlock => {
82
+ var _formBlock$xComponen;
83
+ const _Object$keys = Object.keys(formBlock.properties),
84
+ _Object$keys2 = _slicedToArray(_Object$keys, 1),
85
+ formKey = _Object$keys2[0];
86
+ const formSchema = formBlock.properties[formKey];
87
+ forms[formKey] = {
88
+ type: 'create',
89
+ title: ((_formBlock$xComponen = formBlock['x-component-props']) === null || _formBlock$xComponen === void 0 ? void 0 : _formBlock$xComponen.title) || formKey,
90
+ actions: (0, _utils.findSchema)(formSchema.properties.actions, item => item['x-component'] === 'Action').map(item => item['x-decorator-props'].value),
91
+ collection: formBlock['x-decorator-props'].collection
92
+ };
93
+ });
94
+ return forms;
95
+ }
96
+ },
97
+ block: {
98
+ scope: {
99
+ // useFormBlockProps
100
+ },
101
+ components: {}
102
+ }
103
+ };
104
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import { ManualFormType } from '../SchemaConfig';
2
+ declare const _default: ManualFormType;
3
+ export default _default;
@@ -55,6 +55,7 @@ function _client2() {
55
55
  }
56
56
  var _constants = require("../../../constants");
57
57
  var _locale = require("../../../locale");
58
+ var _utils = require("../utils");
58
59
  const _excluded = ["insert"],
59
60
  _excluded2 = ["unique", "type"],
60
61
  _excluded3 = ["properties"];
@@ -75,22 +76,36 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
75
76
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
76
77
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
77
78
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
78
- const FormCollectionContext = _react().default.createContext(null);
79
- function FormCollectionProvider(props) {
80
- var _props$collection$fie, _props$collection;
79
+ function CustomFormBlockProvider(props) {
80
+ var _props$collection$fie, _props$collection, _fieldSchema$toJSON$p, _userJob$result;
81
81
  const _useState = (0, _react().useState)((_props$collection$fie = (_props$collection = props.collection) === null || _props$collection === void 0 ? void 0 : _props$collection.fields) !== null && _props$collection$fie !== void 0 ? _props$collection$fie : []),
82
82
  _useState2 = _slicedToArray(_useState, 2),
83
83
  fields = _useState2[0],
84
84
  setCollectionFields = _useState2[1];
85
- return _react().default.createElement(FormCollectionContext.Provider, {
86
- value: {
87
- setCollectionFields
88
- }
89
- }, _react().default.createElement(_client().CollectionProvider, {
85
+ const userJob = (0, _client().useRecord)();
86
+ const field = (0, _react2().useField)();
87
+ const fieldSchema = (0, _react2().useFieldSchema)();
88
+ const _Object$keys = Object.keys((_fieldSchema$toJSON$p = fieldSchema.toJSON().properties) !== null && _fieldSchema$toJSON$p !== void 0 ? _fieldSchema$toJSON$p : {}),
89
+ _Object$keys2 = _slicedToArray(_Object$keys, 1),
90
+ formKey = _Object$keys2[0];
91
+ const values = userJob === null || userJob === void 0 ? void 0 : (_userJob$result = userJob.result) === null || _userJob$result === void 0 ? void 0 : _userJob$result[formKey];
92
+ const form = (0, _react().useMemo)(() => (0, _core().createForm)({
93
+ initialValues: values
94
+ }), [values]);
95
+ return _react().default.createElement(_client().CollectionProvider, {
90
96
  collection: _objectSpread(_objectSpread({}, props.collection), {}, {
91
97
  fields
92
98
  })
93
- }, props.children));
99
+ }, _react().default.createElement(_client().RecordProvider, {
100
+ record: values,
101
+ parent: false
102
+ }, _react().default.createElement(_client().FormBlockContext.Provider, {
103
+ value: {
104
+ form,
105
+ field,
106
+ setCollectionFields
107
+ }
108
+ }, props.children)));
94
109
  }
95
110
  function CustomFormBlockInitializer(_ref) {
96
111
  let insert = _ref.insert,
@@ -99,7 +114,7 @@ function CustomFormBlockInitializer(_ref) {
99
114
  onClick: () => {
100
115
  insert({
101
116
  type: 'void',
102
- 'x-decorator': 'FormCollectionProvider',
117
+ 'x-decorator': 'CustomFormBlockProvider',
103
118
  'x-decorator-props': {
104
119
  collection: {
105
120
  name: (0, _client2().uid)(),
@@ -227,7 +242,7 @@ function AddCustomFormField(props) {
227
242
  _useState6 = _slicedToArray(_useState5, 2),
228
243
  insert = _useState6[0],
229
244
  setCallback = _useState6[1];
230
- const _useContext = (0, _react().useContext)(FormCollectionContext),
245
+ const _useContext = (0, _react().useContext)(_client().FormBlockContext),
231
246
  setCollectionFields = _useContext.setCollectionFields;
232
247
  return _react().default.createElement(AddCustomFormFieldButtonContext.Provider, {
233
248
  value: {
@@ -251,7 +266,7 @@ function AddCustomFormField(props) {
251
266
  items: items,
252
267
  component: component,
253
268
  title: "{{t('Configure fields')}}"
254
- }), _react().default.createElement(_client().ActionContext.Provider, {
269
+ }), _react().default.createElement(_client().ActionContextProvider, {
255
270
  value: {
256
271
  visible: Boolean(interfaceOptions)
257
272
  }
@@ -322,7 +337,9 @@ function AddCustomFormField(props) {
322
337
  type: options.uiSchema.type,
323
338
  'x-decorator': 'FormItem',
324
339
  'x-component': 'CollectionField',
325
- 'x-interface-options': newField,
340
+ 'x-component-props': {
341
+ field: newField
342
+ },
326
343
  'x-collection-field': `${collection.name}.${options.name}`,
327
344
  'x-designer': 'FormItem.Designer'
328
345
  });
@@ -360,50 +377,51 @@ function CustomFormFieldInitializer(props) {
360
377
  }
361
378
  });
362
379
  }
363
- function useFormBlockProps() {
364
- var _user$data;
365
- const _useRecord = (0, _client().useRecord)(),
366
- status = _useRecord.status,
367
- result = _useRecord.result,
368
- userId = _useRecord.userId;
369
- const _useCurrentUserContex = (0, _client().useCurrentUserContext)(),
370
- user = _useCurrentUserContex.data;
371
- const _useFieldSchema = (0, _react2().useFieldSchema)(),
372
- name = _useFieldSchema.name;
373
- const pattern = status ? (result === null || result === void 0 ? void 0 : result[name]) ? 'readPretty' : 'disabled' : (user === null || user === void 0 ? void 0 : (_user$data = user.data) === null || _user$data === void 0 ? void 0 : _user$data.id) !== userId ? 'disabled' : 'editable';
374
- const form = (0, _react().useMemo)(() => {
375
- var _result$name;
376
- return (0, _core().createForm)({
377
- pattern,
378
- initialValues: (_result$name = result === null || result === void 0 ? void 0 : result[name]) !== null && _result$name !== void 0 ? _result$name : {}
379
- });
380
- }, [result, name]);
381
- return {
382
- form
383
- };
384
- }
385
380
  var _default = {
386
381
  title: `{{t("Custom form", { ns: "${_locale.NAMESPACE}" })}}`,
387
382
  config: {
388
- initializer: {
389
- key: 'customForm',
390
- type: 'item',
391
- title: `{{t("Custom form", { ns: "${_locale.NAMESPACE}" })}}`,
392
- component: CustomFormBlockInitializer
383
+ useInitializer() {
384
+ return {
385
+ key: 'customForm',
386
+ type: 'item',
387
+ title: `{{t("Custom form", { ns: "${_locale.NAMESPACE}" })}}`,
388
+ component: CustomFormBlockInitializer
389
+ };
393
390
  },
394
391
  initializers: {
395
392
  AddCustomFormField
396
393
  },
397
394
  components: {
398
- FormCollectionProvider
395
+ CustomFormBlockProvider
396
+ },
397
+ parseFormOptions(root) {
398
+ const forms = {};
399
+ const formBlocks = (0, _utils.findSchema)(root, item => item['x-decorator'] === 'CustomFormBlockProvider');
400
+ formBlocks.forEach(formBlock => {
401
+ var _formBlock$xComponen;
402
+ const _Object$keys3 = Object.keys(formBlock.properties),
403
+ _Object$keys4 = _slicedToArray(_Object$keys3, 1),
404
+ formKey = _Object$keys4[0];
405
+ const formSchema = formBlock.properties[formKey];
406
+ const fields = (0, _utils.findSchema)(formSchema.properties.grid, item => item['x-component'] === 'CollectionField', true);
407
+ formBlock['x-decorator-props'].collection.fields = fields.map(field => {
408
+ var _field$xComponentPr, _field$xComponentPr2;
409
+ return (_field$xComponentPr = (_field$xComponentPr2 = field['x-component-props']) === null || _field$xComponentPr2 === void 0 ? void 0 : _field$xComponentPr2.field) !== null && _field$xComponentPr !== void 0 ? _field$xComponentPr : field['x-interface-options'];
410
+ });
411
+ forms[formKey] = {
412
+ type: 'custom',
413
+ title: ((_formBlock$xComponen = formBlock['x-component-props']) === null || _formBlock$xComponen === void 0 ? void 0 : _formBlock$xComponen.title) || formKey,
414
+ actions: (0, _utils.findSchema)(formSchema.properties.actions, item => item['x-component'] === 'Action').map(item => item['x-decorator-props'].value),
415
+ collection: formBlock['x-decorator-props'].collection
416
+ };
417
+ });
418
+ return forms;
399
419
  }
400
420
  },
401
421
  block: {
402
- scope: {
403
- useFormBlockProps
404
- },
422
+ scope: {},
405
423
  components: {
406
- FormCollectionProvider: _client().CollectionProvider
424
+ CustomFormBlockProvider
407
425
  }
408
426
  }
409
427
  };
@@ -0,0 +1,3 @@
1
+ import { ManualFormType } from '../SchemaConfig';
2
+ declare const _default: ManualFormType;
3
+ export default _default;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _react() {
8
+ const data = _interopRequireDefault(require("react"));
9
+ _react = function _react() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _react2() {
15
+ const data = require("@formily/react");
16
+ _react2 = function _react2() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _reactI18next() {
22
+ const data = require("react-i18next");
23
+ _reactI18next = function _reactI18next() {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _client() {
29
+ const data = require("@nocobase/client");
30
+ _client = function _client() {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ var _locale = require("../../../locale");
36
+ var _utils = require("../utils");
37
+ var _FilterDynamicComponent = require("../../../components/FilterDynamicComponent");
38
+ var _FormBlockInitializer = require("../FormBlockInitializer");
39
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
42
+ 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; }
43
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
44
+ 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); }
45
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
46
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
47
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
48
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
49
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
50
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
51
+ function UpdateFormDesigner() {
52
+ const _useCollection = (0, _client().useCollection)(),
53
+ name = _useCollection.name,
54
+ title = _useCollection.title;
55
+ const fieldSchema = (0, _react2().useFieldSchema)();
56
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
57
+ t = _useTranslation.t;
58
+ const _useDesignable = (0, _client().useDesignable)(),
59
+ dn = _useDesignable.dn;
60
+ return _react().default.createElement(_client().GeneralSchemaDesigner, {
61
+ title: title || name
62
+ }, _react().default.createElement(_client().SchemaSettings.BlockTitleItem, null), _react().default.createElement(_client().SchemaSettings.ActionModalItem, {
63
+ title: t('Filter settings', {
64
+ ns: _locale.NAMESPACE
65
+ }),
66
+ schema: {
67
+ name: 'filter',
68
+ type: 'object',
69
+ title: `{{t("Filter")}}`,
70
+ // 'x-decorator': 'FormItem',
71
+ 'x-component': 'Filter',
72
+ 'x-component-props': {
73
+ useProps() {
74
+ var _fieldSchema$xDecora;
75
+ const options = (0, _client().useCollectionFilterOptions)(fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xDecora = fieldSchema['x-decorator-props']) === null || _fieldSchema$xDecora === void 0 ? void 0 : _fieldSchema$xDecora.collection);
76
+ return {
77
+ options
78
+ };
79
+ },
80
+ dynamicComponent: 'FilterDynamicComponent'
81
+ }
82
+ },
83
+ initialValues: fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-decorator-props'],
84
+ onSubmit: ({
85
+ filter
86
+ }) => {
87
+ fieldSchema['x-decorator-props'].filter = filter;
88
+ dn.emit('patch', {
89
+ schema: {
90
+ // ['x-uid']: fieldSchema['x-uid'],
91
+ 'x-decorator-props': fieldSchema['x-decorator-props']
92
+ }
93
+ });
94
+ dn.refresh();
95
+ }
96
+ }), _react().default.createElement(_client().SchemaSettings.LinkageRules, {
97
+ collectionName: name
98
+ }), _react().default.createElement(_client().SchemaSettings.Divider, null), _react().default.createElement(_client().SchemaSettings.Remove, {
99
+ removeParentsIfNoChildren: true,
100
+ breakRemoveOn: {
101
+ 'x-component': 'Grid'
102
+ }
103
+ }));
104
+ }
105
+ var _default = {
106
+ title: `{{t("Update record form", { ns: "${_locale.NAMESPACE}" })}}`,
107
+ config: {
108
+ useInitializer() {
109
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
110
+ collections = _useCollectionManager.collections;
111
+ return {
112
+ key: 'updateRecordForm',
113
+ type: 'subMenu',
114
+ title: `{{t("Update record form", { ns: "${_locale.NAMESPACE}" })}}`,
115
+ children: collections.filter(item => !item.hidden).map(item => ({
116
+ key: `updateForm-${item.name}`,
117
+ type: 'item',
118
+ title: item.title,
119
+ schema: {
120
+ collection: item.name,
121
+ title: `{{t("Update record", { ns: "${_locale.NAMESPACE}" })}}`,
122
+ formType: 'update',
123
+ 'x-designer': 'UpdateFormDesigner'
124
+ },
125
+ component: _FormBlockInitializer.FormBlockInitializer
126
+ }))
127
+ };
128
+ },
129
+ initializers: {
130
+ // AddCustomFormField
131
+ },
132
+ components: {
133
+ FilterDynamicComponent: _FilterDynamicComponent.FilterDynamicComponent,
134
+ UpdateFormDesigner
135
+ },
136
+ parseFormOptions(root) {
137
+ const forms = {};
138
+ const formBlocks = (0, _utils.findSchema)(root, item => item['x-decorator'] === 'FormBlockProvider' && item['x-decorator-props'].formType === 'update');
139
+ formBlocks.forEach(formBlock => {
140
+ var _formBlock$xComponen;
141
+ const _Object$keys = Object.keys(formBlock.properties),
142
+ _Object$keys2 = _slicedToArray(_Object$keys, 1),
143
+ formKey = _Object$keys2[0];
144
+ const formSchema = formBlock.properties[formKey];
145
+ forms[formKey] = _objectSpread(_objectSpread({}, formBlock['x-decorator-props']), {}, {
146
+ type: 'update',
147
+ title: ((_formBlock$xComponen = formBlock['x-component-props']) === null || _formBlock$xComponen === void 0 ? void 0 : _formBlock$xComponen.title) || formKey,
148
+ actions: (0, _utils.findSchema)(formSchema.properties.actions, item => item['x-component'] === 'Action').map(item => item['x-decorator-props'].value)
149
+ });
150
+ });
151
+ return forms;
152
+ }
153
+ },
154
+ block: {
155
+ scope: {
156
+ // useFormBlockProps
157
+ },
158
+ components: {}
159
+ }
160
+ };
161
+ exports.default = _default;
@@ -1,5 +1,4 @@
1
1
  import { SchemaInitializerItemOptions } from '@nocobase/client';
2
- import { CollectionFieldInitializers } from '../../components/CollectionFieldInitializers';
3
2
  import { SchemaConfig, SchemaConfigButton } from './SchemaConfig';
4
3
  import { ModeConfig } from './ModeConfig';
5
4
  import { AssigneesSelect } from './AssigneesSelect';
@@ -68,11 +67,9 @@ declare const _default: {
68
67
  value: string;
69
68
  label: any;
70
69
  title: any;
71
- children: any;
70
+ children: import("../../variable").VariableOption[];
72
71
  }[];
73
72
  useInitializers(node: any): SchemaInitializerItemOptions | null;
74
- initializers: {
75
- CollectionFieldInitializers: typeof CollectionFieldInitializers;
76
- };
73
+ initializers: {};
77
74
  };
78
75
  export default _default;
@@ -12,7 +12,6 @@ function _client() {
12
12
  return data;
13
13
  }
14
14
  var _CollectionBlockInitializer = require("../../components/CollectionBlockInitializer");
15
- var _CollectionFieldInitializers = require("../../components/CollectionFieldInitializers");
16
15
  var _variable = require("../../variable");
17
16
  var _locale = require("../../locale");
18
17
  var _SchemaConfig = require("./SchemaConfig");
@@ -105,35 +104,39 @@ var _default = {
105
104
  return null;
106
105
  }
107
106
  const options = formKeys.map(formKey => {
108
- var _form$collection$fiel, _form$collection;
107
+ var _form$collection;
109
108
  const form = config.forms[formKey];
110
- const fields = ((_form$collection$fiel = (_form$collection = form.collection) === null || _form$collection === void 0 ? void 0 : _form$collection.fields) !== null && _form$collection$fiel !== void 0 ? _form$collection$fiel : []).map(field => ({
111
- key: field.name,
112
- value: field.name,
113
- label: field.uiSchema.title,
114
- title: field.uiSchema.title
115
- }));
116
- const filteredFields = (0, _variable.filterTypedFields)(fields, types);
117
- return filteredFields.length ? {
109
+ // eslint-disable-next-line react-hooks/rules-of-hooks
110
+ const options = (0, _variable.useCollectionFieldOptions)({
111
+ fields: (_form$collection = form.collection) === null || _form$collection === void 0 ? void 0 : _form$collection.fields,
112
+ collection: form.collection,
113
+ types
114
+ });
115
+ return options.length ? {
118
116
  key: formKey,
119
117
  value: formKey,
120
118
  label: form.title || formKey,
121
119
  title: form.title || formKey,
122
- children: filteredFields
120
+ children: options
123
121
  } : null;
124
122
  }).filter(Boolean);
125
123
  return options.length ? options : null;
126
124
  },
127
125
  useInitializers(node) {
128
126
  var _node$config$forms;
127
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
128
+ getCollection = _useCollectionManager.getCollection;
129
129
  const formKeys = Object.keys((_node$config$forms = node.config.forms) !== null && _node$config$forms !== void 0 ? _node$config$forms : {});
130
130
  if (!formKeys.length || node.config.mode) {
131
131
  return null;
132
132
  }
133
133
  const forms = formKeys.map(formKey => {
134
- var _form$collection2, _form$collection2$fie, _form$title;
134
+ var _form$title;
135
135
  const form = node.config.forms[formKey];
136
- return ((_form$collection2 = form.collection) === null || _form$collection2 === void 0 ? void 0 : (_form$collection2$fie = _form$collection2.fields) === null || _form$collection2$fie === void 0 ? void 0 : _form$collection2$fie.length) ? {
136
+ const _getCollection = getCollection(form.collection),
137
+ _getCollection$fields = _getCollection.fields,
138
+ fields = _getCollection$fields === void 0 ? [] : _getCollection$fields;
139
+ return fields.length ? {
137
140
  type: 'item',
138
141
  title: (_form$title = form.title) !== null && _form$title !== void 0 ? _form$title : formKey,
139
142
  component: _CollectionBlockInitializer.CollectionBlockInitializer,
@@ -148,8 +151,6 @@ var _default = {
148
151
  children: forms
149
152
  } : null;
150
153
  },
151
- initializers: {
152
- CollectionFieldInitializers: _CollectionFieldInitializers.CollectionFieldInitializers
153
- }
154
+ initializers: {}
154
155
  };
155
156
  exports.default = _default;
@@ -0,0 +1,2 @@
1
+ export declare function traverseSchema(schema: any, fn: any): void;
2
+ export declare function findSchema(schema: any, filter: any, onlyLeaf?: boolean): any[];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findSchema = findSchema;
7
+ exports.traverseSchema = traverseSchema;
8
+ function traverseSchema(schema, fn) {
9
+ fn(schema);
10
+ if (schema.properties) {
11
+ Object.keys(schema.properties).forEach(key => {
12
+ traverseSchema(schema.properties[key], fn);
13
+ });
14
+ }
15
+ }
16
+ function findSchema(schema, filter, onlyLeaf = false) {
17
+ const result = [];
18
+ if (!schema) {
19
+ return result;
20
+ }
21
+ if (filter(schema) && (!onlyLeaf || !schema.properties)) {
22
+ result.push(schema);
23
+ return result;
24
+ }
25
+ if (schema.properties) {
26
+ Object.keys(schema.properties).forEach(key => {
27
+ result.push(...findSchema(schema.properties[key], filter));
28
+ });
29
+ }
30
+ return result;
31
+ }
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { RadioWithTooltip } from '../components/RadioWithTooltip';
2
3
  declare const _default: {
3
4
  title: string;
@@ -21,7 +22,9 @@ declare const _default: {
21
22
  };
22
23
  };
23
24
  view: {};
24
- render(data: any): JSX.Element;
25
+ component: ({ data }: {
26
+ data: any;
27
+ }) => React.JSX.Element;
25
28
  components: {
26
29
  RadioWithTooltip: typeof RadioWithTooltip;
27
30
  };
@@ -76,7 +76,9 @@ var _default = {
76
76
  }
77
77
  },
78
78
  view: {},
79
- render(data) {
79
+ component: function Component({
80
+ data
81
+ }) {
80
82
  const id = data.id,
81
83
  mode = data.config.mode;
82
84
  const _useFlowContext = (0, _FlowContext.useFlowContext)(),
@@ -1,5 +1,4 @@
1
1
  import { SchemaInitializerItemOptions, useCollectionDataSource } from '@nocobase/client';
2
- import { CollectionFieldInitializers } from '../components/CollectionFieldInitializers';
3
2
  import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
4
3
  declare const _default: {
5
4
  title: string;
@@ -76,14 +75,12 @@ declare const _default: {
76
75
  };
77
76
  components: {
78
77
  FilterDynamicComponent: typeof FilterDynamicComponent;
79
- FieldsSelect: import("react").MemoExoticComponent<import("react").FunctionComponent<Pick<any, string | number | symbol>>>;
78
+ FieldsSelect: import("react").MemoExoticComponent<import("@formily/reactive-react").ReactFC<Pick<any, string | number | symbol>>>;
80
79
  };
81
80
  useVariables({ config }: {
82
81
  config: any;
83
82
  }, options: any): import("../variable").VariableOption[];
84
83
  useInitializers(node: any): SchemaInitializerItemOptions | null;
85
- initializers: {
86
- CollectionFieldInitializers: typeof CollectionFieldInitializers;
87
- };
84
+ initializers: {};
88
85
  };
89
86
  export default _default;
@@ -14,7 +14,6 @@ function _client() {
14
14
  var _collection = require("../schemas/collection");
15
15
  var _locale = require("../locale");
16
16
  var _CollectionBlockInitializer = require("../components/CollectionBlockInitializer");
17
- var _CollectionFieldInitializers = require("../components/CollectionFieldInitializers");
18
17
  var _FilterDynamicComponent = require("../components/FilterDynamicComponent");
19
18
  var _variable = require("../variable");
20
19
  var _FieldsSelect = require("../components/FieldsSelect");
@@ -72,7 +71,7 @@ var _default = {
72
71
  },
73
72
  useInitializers(node) {
74
73
  var _node$title;
75
- if (!node.config.collection) {
74
+ if (!node.config.collection || node.config.multiple) {
76
75
  return null;
77
76
  }
78
77
  return {
@@ -83,8 +82,6 @@ var _default = {
83
82
  dataSource: `{{$jobsMapByNodeId.${node.id}}}`
84
83
  };
85
84
  },
86
- initializers: {
87
- CollectionFieldInitializers: _CollectionFieldInitializers.CollectionFieldInitializers
88
- }
85
+ initializers: {}
89
86
  };
90
87
  exports.default = _default;