@nocobase/plugin-workflow 0.9.4-alpha.2 → 0.10.0-alpha.3
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/lib/client/AddButton.d.ts +2 -2
- package/lib/client/AddButton.js +76 -65
- package/lib/client/Branch.d.ts +2 -2
- package/lib/client/CanvasContent.d.ts +2 -2
- package/lib/client/ExecutionCanvas.d.ts +2 -2
- package/lib/client/ExecutionCanvas.js +1 -1
- package/lib/client/ExecutionLink.d.ts +2 -1
- package/lib/client/ExecutionPage.d.ts +2 -1
- package/lib/client/ExecutionPage.js +14 -15
- package/lib/client/ExecutionResourceProvider.d.ts +2 -1
- package/lib/client/WorkflowCanvas.d.ts +2 -2
- package/lib/client/WorkflowCanvas.js +31 -31
- package/lib/client/WorkflowLink.d.ts +2 -1
- package/lib/client/WorkflowPage.d.ts +2 -1
- package/lib/client/WorkflowPage.js +11 -10
- package/lib/client/WorkflowProvider.d.ts +1 -1
- package/lib/client/WorkflowProvider.js +15 -15
- package/lib/client/components/CollectionBlockInitializer.d.ts +2 -7
- package/lib/client/components/CollectionBlockInitializer.js +49 -17
- package/lib/client/components/CollectionFieldset.d.ts +3 -2
- package/lib/client/components/CollectionFieldset.js +87 -74
- package/lib/client/components/Duration.d.ts +2 -2
- package/lib/client/components/DynamicExpression.d.ts +3 -1
- package/lib/client/components/DynamicExpression.js +2 -0
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +2 -0
- package/lib/client/components/FilterDynamicComponent.d.ts +2 -2
- package/lib/client/components/NodeDescription.d.ts +2 -2
- package/lib/client/components/OpenDrawer.d.ts +2 -2
- package/lib/client/components/OpenDrawer.js +1 -1
- package/lib/client/components/RadioWithTooltip.d.ts +2 -2
- package/lib/client/components/renderEngineReference.d.ts +2 -1
- package/lib/client/constants.d.ts +2 -1
- package/lib/client/locale/zh-CN.d.ts +8 -0
- package/lib/client/locale/zh-CN.js +8 -0
- package/lib/client/nodes/aggregate.d.ts +1 -1
- package/lib/client/nodes/calculation.d.ts +4 -3
- package/lib/client/nodes/condition.d.ts +6 -4
- package/lib/client/nodes/condition.js +3 -1
- package/lib/client/nodes/create.d.ts +3 -6
- package/lib/client/nodes/create.js +1 -4
- package/lib/client/nodes/index.d.ts +5 -5
- package/lib/client/nodes/index.js +9 -6
- package/lib/client/nodes/loop.d.ts +4 -1
- package/lib/client/nodes/loop.js +3 -1
- package/lib/client/nodes/manual/AssigneesSelect.d.ts +2 -2
- package/lib/client/nodes/manual/DetailsBlockProvider.d.ts +2 -0
- package/lib/client/nodes/manual/DetailsBlockProvider.js +106 -0
- package/lib/client/nodes/manual/FormBlockInitializer.d.ts +2 -0
- package/lib/client/nodes/manual/FormBlockInitializer.js +106 -0
- package/lib/client/nodes/manual/FormBlockProvider.d.ts +2 -0
- package/lib/client/nodes/manual/FormBlockProvider.js +113 -0
- package/lib/client/nodes/manual/ModeConfig.d.ts +2 -2
- package/lib/client/nodes/manual/SchemaConfig.d.ts +43 -3
- package/lib/client/nodes/manual/SchemaConfig.js +42 -79
- package/lib/client/nodes/manual/WorkflowTodo.d.ts +5 -8
- package/lib/client/nodes/manual/WorkflowTodo.js +111 -76
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -2
- package/lib/client/nodes/manual/forms/create.d.ts +3 -0
- package/lib/client/nodes/manual/forms/create.js +104 -0
- package/lib/client/nodes/manual/forms/custom.d.ts +3 -0
- package/lib/client/nodes/manual/forms/{customForm.js → custom.js} +63 -45
- package/lib/client/nodes/manual/forms/update.d.ts +3 -0
- package/lib/client/nodes/manual/forms/update.js +161 -0
- package/lib/client/nodes/manual/index.d.ts +2 -5
- package/lib/client/nodes/manual/index.js +17 -16
- package/lib/client/nodes/manual/utils.d.ts +2 -0
- package/lib/client/nodes/manual/utils.js +31 -0
- package/lib/client/nodes/parallel.d.ts +4 -1
- package/lib/client/nodes/parallel.js +3 -1
- package/lib/client/nodes/query.d.ts +2 -5
- package/lib/client/nodes/query.js +2 -5
- package/lib/client/nodes/request.d.ts +1 -1
- package/lib/client/nodes/request.js +1 -11
- package/lib/client/nodes/update.d.ts +24 -1
- package/lib/client/nodes/update.js +76 -3
- package/lib/client/schemas/collection.js +1 -1
- package/lib/client/schemas/executions.d.ts +2 -0
- package/lib/client/style.js +4 -0
- package/lib/client/triggers/collection.d.ts +2 -5
- package/lib/client/triggers/collection.js +5 -8
- package/lib/client/triggers/index.d.ts +1 -2
- package/lib/client/triggers/index.js +10 -8
- package/lib/client/triggers/schedule/DateFieldsSelect.js +14 -12
- package/lib/client/triggers/schedule/EndsByField.d.ts +2 -2
- package/lib/client/triggers/schedule/OnField.d.ts +2 -2
- package/lib/client/triggers/schedule/RepeatField.d.ts +2 -2
- package/lib/client/triggers/schedule/ScheduleConfig.d.ts +2 -1
- package/lib/client/triggers/schedule/index.d.ts +3 -6
- package/lib/client/triggers/schedule/index.js +1 -4
- package/lib/server/Plugin.js +6 -3
- package/lib/server/Processor.d.ts +2 -2
- package/lib/server/Processor.js +22 -26
- package/lib/server/instructions/delay.js +1 -1
- package/lib/server/instructions/loop.d.ts +1 -1
- package/lib/server/instructions/loop.js +1 -1
- package/lib/server/instructions/manual/actions.js +42 -47
- package/lib/server/instructions/manual/forms/create.d.ts +5 -0
- package/lib/server/instructions/manual/forms/create.js +46 -0
- package/lib/server/instructions/manual/forms/index.d.ts +6 -0
- package/lib/server/instructions/manual/forms/index.js +15 -0
- package/lib/server/instructions/manual/forms/update.d.ts +6 -0
- package/lib/server/instructions/manual/forms/update.js +47 -0
- package/lib/server/instructions/manual/index.d.ts +3 -0
- package/lib/server/instructions/manual/index.js +16 -3
- package/lib/server/instructions/parallel.js +2 -2
- package/lib/server/instructions/request.js +3 -3
- package/lib/server/instructions/update.js +2 -3
- package/lib/server/migrations/20230612021134-manual-collection-block.d.ts +4 -0
- package/lib/server/migrations/20230612021134-manual-collection-block.js +155 -0
- package/package.json +16 -13
- package/lib/client/WorkflowShortcut.d.ts +0 -1
- package/lib/client/WorkflowShortcut.js +0 -48
- package/lib/client/components/CollectionFieldInitializers.d.ts +0 -2
- package/lib/client/components/CollectionFieldInitializers.js +0 -70
- package/lib/client/nodes/manual/forms/customForm.d.ts +0 -40
|
@@ -15,7 +15,6 @@ var _collection = require("../schemas/collection");
|
|
|
15
15
|
var _CollectionFieldset = _interopRequireDefault(require("../components/CollectionFieldset"));
|
|
16
16
|
var _locale = require("../locale");
|
|
17
17
|
var _CollectionBlockInitializer = require("../components/CollectionBlockInitializer");
|
|
18
|
-
var _CollectionFieldInitializers = require("../components/CollectionFieldInitializers");
|
|
19
18
|
var _variable = require("../variable");
|
|
20
19
|
var _FieldsSelect = require("../components/FieldsSelect");
|
|
21
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -81,8 +80,6 @@ var _default = {
|
|
|
81
80
|
dataSource: `{{$jobsMapByNodeId.${node.id}}}`
|
|
82
81
|
};
|
|
83
82
|
},
|
|
84
|
-
initializers: {
|
|
85
|
-
CollectionFieldInitializers: _CollectionFieldInitializers.CollectionFieldInitializers
|
|
86
|
-
}
|
|
83
|
+
initializers: {}
|
|
87
84
|
};
|
|
88
85
|
exports.default = _default;
|
|
@@ -23,7 +23,7 @@ export interface Instruction {
|
|
|
23
23
|
components?: {
|
|
24
24
|
[key: string]: any;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
component?(props: any): JSX.Element;
|
|
27
27
|
endding?: boolean;
|
|
28
28
|
useVariables?(node: any, options?: any): VariableOptions;
|
|
29
29
|
useScopeVariables?(node: any, options?: any): VariableOptions;
|
|
@@ -39,7 +39,7 @@ export declare function useAvailableUpstreams(node: any): any[];
|
|
|
39
39
|
export declare function useUpstreamScopes(node: any): any[];
|
|
40
40
|
export declare function Node({ data }: {
|
|
41
41
|
data: any;
|
|
42
|
-
}): JSX.Element;
|
|
43
|
-
export declare function RemoveButton(): JSX.Element;
|
|
44
|
-
export declare function JobButton(): JSX.Element;
|
|
45
|
-
export declare function NodeDefaultView(props: any): JSX.Element;
|
|
42
|
+
}): React.JSX.Element;
|
|
43
|
+
export declare function RemoveButton(): React.JSX.Element;
|
|
44
|
+
export declare function JobButton(): React.JSX.Element;
|
|
45
|
+
export declare function NodeDefaultView(props: any): React.JSX.Element;
|
|
@@ -179,14 +179,17 @@ function useUpstreamScopes(node) {
|
|
|
179
179
|
function Node({
|
|
180
180
|
data
|
|
181
181
|
}) {
|
|
182
|
-
const
|
|
182
|
+
const _instructions$get = instructions.get(data.type),
|
|
183
|
+
_instructions$get$com = _instructions$get.component,
|
|
184
|
+
Component = _instructions$get$com === void 0 ? NodeDefaultView : _instructions$get$com,
|
|
185
|
+
endding = _instructions$get.endding;
|
|
183
186
|
return _react().default.createElement(NodeContext.Provider, {
|
|
184
187
|
value: data
|
|
185
188
|
}, _react().default.createElement("div", {
|
|
186
189
|
className: (0, _css().cx)(_style.nodeBlockClass)
|
|
187
|
-
},
|
|
190
|
+
}, _react().default.createElement(Component, {
|
|
188
191
|
data: data
|
|
189
|
-
}), !
|
|
192
|
+
}), !endding ? _react().default.createElement(_AddButton.AddButton, {
|
|
190
193
|
upstream: data
|
|
191
194
|
}) : _react().default.createElement("div", {
|
|
192
195
|
className: (0, _css().css)`
|
|
@@ -284,7 +287,7 @@ function InnerJobButton(_ref2) {
|
|
|
284
287
|
color = _JobStatusOptionsMap$.color;
|
|
285
288
|
return _react().default.createElement(_antd().Button, _objectSpread(_objectSpread({}, props), {}, {
|
|
286
289
|
shape: "circle",
|
|
287
|
-
className: _style.nodeJobButtonClass
|
|
290
|
+
className: (0, _css().cx)(_style.nodeJobButtonClass, props.className)
|
|
288
291
|
}), _react().default.createElement(_antd().Tag, {
|
|
289
292
|
color: color
|
|
290
293
|
}, icon));
|
|
@@ -333,7 +336,7 @@ function JobButton() {
|
|
|
333
336
|
}
|
|
334
337
|
`
|
|
335
338
|
}, _react().default.createElement("span", {
|
|
336
|
-
className: _style.nodeJobButtonClass
|
|
339
|
+
className: (0, _css().cx)(_style.nodeJobButtonClass, 'inner')
|
|
337
340
|
}, _react().default.createElement(_antd().Tag, {
|
|
338
341
|
color: color
|
|
339
342
|
}, icon)), _react().default.createElement("time", null, (0, _client().str2moment)(job.updatedAt).format('YYYY-MM-DD HH:mm:ss')))
|
|
@@ -420,7 +423,7 @@ function NodeDefaultView(props) {
|
|
|
420
423
|
onChange: ev => setEditingTitle(ev.target.value),
|
|
421
424
|
onBlur: ev => onChangeTitle(ev.target.value),
|
|
422
425
|
autoSize: true
|
|
423
|
-
})), _react().default.createElement(RemoveButton, null), _react().default.createElement(JobButton, null), _react().default.createElement(_client2().
|
|
426
|
+
})), _react().default.createElement(RemoveButton, null), _react().default.createElement(JobButton, null), _react().default.createElement(_client2().ActionContextProvider, {
|
|
424
427
|
value: {
|
|
425
428
|
visible: editingConfig,
|
|
426
429
|
setVisible: setEditingConfig
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { useWorkflowVariableOptions, VariableOption } from '../variable';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
title: string;
|
|
@@ -19,7 +20,9 @@ declare const _default: {
|
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
view: {};
|
|
22
|
-
|
|
23
|
+
component: ({ data }: {
|
|
24
|
+
data: any;
|
|
25
|
+
}) => React.JSX.Element;
|
|
23
26
|
scope: {
|
|
24
27
|
useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
|
|
25
28
|
};
|
package/lib/client/nodes/loop.js
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DetailsBlockProvider = DetailsBlockProvider;
|
|
7
|
+
function _react() {
|
|
8
|
+
const data = _interopRequireWildcard(require("react"));
|
|
9
|
+
_react = function _react() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _core() {
|
|
15
|
+
const data = require("@formily/core");
|
|
16
|
+
_core = function _core() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _react2() {
|
|
22
|
+
const data = require("@formily/react");
|
|
23
|
+
_react2 = function _react2() {
|
|
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 _FlowContext = require("../../FlowContext");
|
|
36
|
+
function _client2() {
|
|
37
|
+
const data = require("@nocobase/utils/client");
|
|
38
|
+
_client2 = function _client2() {
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
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); }
|
|
44
|
+
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; }
|
|
45
|
+
function useFlowContextData(dataSource) {
|
|
46
|
+
const _useFlowContext = (0, _FlowContext.useFlowContext)(),
|
|
47
|
+
execution = _useFlowContext.execution;
|
|
48
|
+
const data = (0, _react().useMemo)(() => {
|
|
49
|
+
var _execution$jobs;
|
|
50
|
+
return {
|
|
51
|
+
$context: execution === null || execution === void 0 ? void 0 : execution.context,
|
|
52
|
+
$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, {
|
|
53
|
+
[job.nodeId]: job.result
|
|
54
|
+
}), {})
|
|
55
|
+
};
|
|
56
|
+
}, [execution]);
|
|
57
|
+
const result = (0, _react().useMemo)(() => (0, _client2().parse)(dataSource)(data), [execution]);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
function DetailsBlockProvider(props) {
|
|
61
|
+
const field = (0, _react2().useField)();
|
|
62
|
+
const formBlockRef = (0, _react().useRef)(null);
|
|
63
|
+
const _useAssociationNames = (0, _client().useAssociationNames)(),
|
|
64
|
+
appends = _useAssociationNames.appends,
|
|
65
|
+
updateAssociationValues = _useAssociationNames.updateAssociationValues;
|
|
66
|
+
const values = useFlowContextData(props.dataSource);
|
|
67
|
+
const form = (0, _react().useMemo)(() => (0, _core().createForm)({
|
|
68
|
+
values,
|
|
69
|
+
readPretty: true
|
|
70
|
+
}), [values]);
|
|
71
|
+
const params = {
|
|
72
|
+
appends
|
|
73
|
+
};
|
|
74
|
+
const service = {
|
|
75
|
+
loading: false,
|
|
76
|
+
data: {
|
|
77
|
+
data: values
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const api = (0, _client().useAPIClient)();
|
|
81
|
+
const resource = api.resource(props.collection);
|
|
82
|
+
const __parent = (0, _react().useContext)(_client().BlockRequestContext);
|
|
83
|
+
return _react().default.createElement(_client().CollectionProvider, {
|
|
84
|
+
collection: props.collection
|
|
85
|
+
}, _react().default.createElement(_client().RecordProvider, {
|
|
86
|
+
record: values,
|
|
87
|
+
parent: false
|
|
88
|
+
}, _react().default.createElement(_client().BlockRequestContext.Provider, {
|
|
89
|
+
value: {
|
|
90
|
+
block: 'form',
|
|
91
|
+
field,
|
|
92
|
+
service,
|
|
93
|
+
resource,
|
|
94
|
+
__parent
|
|
95
|
+
}
|
|
96
|
+
}, _react().default.createElement(_client().FormBlockContext.Provider, {
|
|
97
|
+
value: {
|
|
98
|
+
params,
|
|
99
|
+
form,
|
|
100
|
+
field,
|
|
101
|
+
service,
|
|
102
|
+
updateAssociationValues,
|
|
103
|
+
formBlockRef
|
|
104
|
+
}
|
|
105
|
+
}, props.children))));
|
|
106
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FormBlockInitializer = FormBlockInitializer;
|
|
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 _utils = require("./utils");
|
|
22
|
+
var _constants = require("../../constants");
|
|
23
|
+
var _locale = require("../../locale");
|
|
24
|
+
const _excluded = ["insert", "schema"];
|
|
25
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
+
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."); }
|
|
28
|
+
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); }
|
|
29
|
+
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; }
|
|
30
|
+
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; } }
|
|
31
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
32
|
+
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; }
|
|
33
|
+
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; }
|
|
34
|
+
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; }
|
|
35
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
36
|
+
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); }
|
|
37
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
38
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
39
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
40
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
41
|
+
function InternalFormBlockInitializer(_ref) {
|
|
42
|
+
let insert = _ref.insert,
|
|
43
|
+
schema = _ref.schema,
|
|
44
|
+
others = _objectWithoutProperties(_ref, _excluded);
|
|
45
|
+
const _useSchemaTemplateMan = (0, _client().useSchemaTemplateManager)(),
|
|
46
|
+
getTemplateSchemaByMode = _useSchemaTemplateMan.getTemplateSchemaByMode;
|
|
47
|
+
const items = (0, _client().useRecordCollectionDataSourceItems)('FormItem');
|
|
48
|
+
function onConfirm(_x) {
|
|
49
|
+
return _onConfirm.apply(this, arguments);
|
|
50
|
+
}
|
|
51
|
+
function _onConfirm() {
|
|
52
|
+
_onConfirm = _asyncToGenerator(function* ({
|
|
53
|
+
item
|
|
54
|
+
}) {
|
|
55
|
+
const template = item.template ? yield getTemplateSchemaByMode(item) : null;
|
|
56
|
+
const result = (0, _client().createFormBlockSchema)(_objectSpread(_objectSpread({
|
|
57
|
+
actionInitializers: 'AddActionButton',
|
|
58
|
+
actions: {
|
|
59
|
+
resolve: {
|
|
60
|
+
type: 'void',
|
|
61
|
+
title: `{{t("Continue the process", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
62
|
+
'x-decorator': 'ManualActionStatusProvider',
|
|
63
|
+
'x-decorator-props': {
|
|
64
|
+
value: _constants.JOB_STATUS.RESOLVED
|
|
65
|
+
},
|
|
66
|
+
'x-component': 'Action',
|
|
67
|
+
'x-component-props': {
|
|
68
|
+
type: 'primary',
|
|
69
|
+
useAction: '{{ useSubmit }}'
|
|
70
|
+
},
|
|
71
|
+
'x-designer': 'Action.Designer',
|
|
72
|
+
'x-designer-props': {
|
|
73
|
+
type: 'record'
|
|
74
|
+
},
|
|
75
|
+
'x-action': `${_constants.JOB_STATUS.RESOLVED}`
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, schema), {}, {
|
|
79
|
+
template
|
|
80
|
+
}));
|
|
81
|
+
delete result['x-acl-action-props'];
|
|
82
|
+
delete result['x-acl-action'];
|
|
83
|
+
const _Object$keys = Object.keys(result.properties),
|
|
84
|
+
_Object$keys2 = _slicedToArray(_Object$keys, 1),
|
|
85
|
+
formKey = _Object$keys2[0];
|
|
86
|
+
result.properties[formKey].properties.actions['x-decorator'] = 'ActionBarProvider';
|
|
87
|
+
(0, _utils.traverseSchema)(result, node => {
|
|
88
|
+
if (node['x-uid']) {
|
|
89
|
+
delete node['x-uid'];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
insert(result);
|
|
93
|
+
});
|
|
94
|
+
return _onConfirm.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
return _react().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({}, others), {}, {
|
|
97
|
+
onClick: onConfirm,
|
|
98
|
+
items: items
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
function FormBlockInitializer(props) {
|
|
102
|
+
var _props$schema;
|
|
103
|
+
return _react().default.createElement(_client().CollectionProvider, {
|
|
104
|
+
collection: (_props$schema = props.schema) === null || _props$schema === void 0 ? void 0 : _props$schema.collection
|
|
105
|
+
}, _react().default.createElement(InternalFormBlockInitializer, _objectSpread({}, props)));
|
|
106
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FormBlockProvider = FormBlockProvider;
|
|
7
|
+
function _react() {
|
|
8
|
+
const data = _interopRequireWildcard(require("react"));
|
|
9
|
+
_react = function _react() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _core() {
|
|
15
|
+
const data = require("@formily/core");
|
|
16
|
+
_core = function _core() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _react2() {
|
|
22
|
+
const data = require("@formily/react");
|
|
23
|
+
_react2 = function _react2() {
|
|
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
|
+
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); }
|
|
36
|
+
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; }
|
|
37
|
+
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; }
|
|
38
|
+
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; }
|
|
39
|
+
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; }
|
|
40
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
41
|
+
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); }
|
|
42
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
43
|
+
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."); }
|
|
44
|
+
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); }
|
|
45
|
+
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; }
|
|
46
|
+
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; } }
|
|
47
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
48
|
+
function FormBlockProvider(props) {
|
|
49
|
+
var _fieldSchema$toJSON$p, _userJob$result, _field$component;
|
|
50
|
+
const userJob = (0, _client().useRecord)();
|
|
51
|
+
const fieldSchema = (0, _react2().useFieldSchema)();
|
|
52
|
+
const field = (0, _react2().useField)();
|
|
53
|
+
const formBlockRef = (0, _react().useRef)(null);
|
|
54
|
+
const _useAssociationNames = (0, _client().useAssociationNames)(),
|
|
55
|
+
appends = _useAssociationNames.appends,
|
|
56
|
+
updateAssociationValues = _useAssociationNames.updateAssociationValues;
|
|
57
|
+
const _Object$keys = Object.keys((_fieldSchema$toJSON$p = fieldSchema.toJSON().properties) !== null && _fieldSchema$toJSON$p !== void 0 ? _fieldSchema$toJSON$p : {}),
|
|
58
|
+
_Object$keys2 = _slicedToArray(_Object$keys, 1),
|
|
59
|
+
formKey = _Object$keys2[0];
|
|
60
|
+
const values = userJob === null || userJob === void 0 ? void 0 : (_userJob$result = userJob.result) === null || _userJob$result === void 0 ? void 0 : _userJob$result[formKey];
|
|
61
|
+
const _useDesignable = (0, _client().useDesignable)(),
|
|
62
|
+
findComponent = _useDesignable.findComponent;
|
|
63
|
+
const Component = findComponent((_field$component = field.component) === null || _field$component === void 0 ? void 0 : _field$component[0]) || _react().default.Fragment;
|
|
64
|
+
const form = (0, _react().useMemo)(() => (0, _core().createForm)({
|
|
65
|
+
initialValues: values
|
|
66
|
+
}), [values]);
|
|
67
|
+
const params = _objectSpread({
|
|
68
|
+
appends
|
|
69
|
+
}, props.params);
|
|
70
|
+
const service = {
|
|
71
|
+
loading: false,
|
|
72
|
+
data: {
|
|
73
|
+
data: values
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const api = (0, _client().useAPIClient)();
|
|
77
|
+
const resource = api.resource(props.collection);
|
|
78
|
+
const __parent = (0, _react().useContext)(_client().BlockRequestContext);
|
|
79
|
+
return _react().default.createElement(_client().CollectionProvider, {
|
|
80
|
+
collection: props.collection
|
|
81
|
+
}, _react().default.createElement(_client().RecordProvider, {
|
|
82
|
+
record: values,
|
|
83
|
+
parent: false
|
|
84
|
+
}, _react().default.createElement(_client().BlockRequestContext.Provider, {
|
|
85
|
+
value: {
|
|
86
|
+
block: 'form',
|
|
87
|
+
props,
|
|
88
|
+
field,
|
|
89
|
+
service,
|
|
90
|
+
resource,
|
|
91
|
+
__parent
|
|
92
|
+
}
|
|
93
|
+
}, _react().default.createElement(_client().FormBlockContext.Provider, {
|
|
94
|
+
value: {
|
|
95
|
+
params,
|
|
96
|
+
form,
|
|
97
|
+
field,
|
|
98
|
+
service,
|
|
99
|
+
updateAssociationValues,
|
|
100
|
+
formBlockRef
|
|
101
|
+
}
|
|
102
|
+
}, _react().default.createElement(Component, _objectSpread({}, field.componentProps), _react().default.createElement(_client().FormV2.Templates, {
|
|
103
|
+
style: {
|
|
104
|
+
marginBottom: 18
|
|
105
|
+
},
|
|
106
|
+
form: form
|
|
107
|
+
}), _react().default.createElement("div", {
|
|
108
|
+
ref: formBlockRef
|
|
109
|
+
}, _react().default.createElement(_react2().RecursionField, {
|
|
110
|
+
schema: fieldSchema,
|
|
111
|
+
onlyRenderProperties: true
|
|
112
|
+
})))))));
|
|
113
|
+
}
|
|
@@ -1,6 +1,46 @@
|
|
|
1
|
-
|
|
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 {};
|