@nocobase/plugin-workflow 0.9.1-alpha.1 → 0.9.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/AddButton.js +50 -86
- package/lib/client/Branch.js +0 -13
- package/lib/client/ExecutionCanvas.js +16 -63
- package/lib/client/ExecutionLink.js +3 -21
- package/lib/client/ExecutionPage.js +1 -19
- package/lib/client/ExecutionResourceProvider.js +6 -23
- package/lib/client/FlowContext.js +0 -8
- package/lib/client/WorkflowCanvas.js +57 -129
- package/lib/client/WorkflowLink.js +3 -21
- package/lib/client/WorkflowPage.js +1 -19
- package/lib/client/WorkflowProvider.js +24 -47
- package/lib/client/WorkflowShortcut.js +0 -16
- package/lib/client/components/CollectionBlockInitializer.js +12 -22
- package/lib/client/components/CollectionFieldInitializers.js +5 -24
- package/lib/client/components/CollectionFieldset.js +33 -85
- package/lib/client/components/Duration.js +0 -14
- package/lib/client/components/DynamicExpression.d.ts +4 -0
- package/lib/client/components/DynamicExpression.js +102 -0
- package/lib/client/components/FieldsSelect.d.ts +2 -0
- package/lib/client/components/FieldsSelect.js +66 -0
- package/lib/client/components/FilterDynamicComponent.js +1 -10
- package/lib/client/components/NullRender.js +0 -1
- package/lib/client/components/OpenDrawer.js +10 -35
- package/lib/client/components/RadioWithTooltip.js +5 -27
- package/lib/client/components/renderEngineReference.d.ts +1 -0
- package/lib/client/components/renderEngineReference.js +55 -0
- package/lib/client/constants.js +0 -9
- package/lib/client/index.js +0 -6
- package/lib/client/interfaces/expression.d.ts +3 -0
- package/lib/client/interfaces/expression.js +37 -0
- package/lib/client/locale/index.js +5 -15
- package/lib/client/locale/pt-BR.d.ts +130 -0
- package/lib/client/locale/pt-BR.js +136 -0
- package/lib/client/locale/zh-CN.d.ts +16 -1
- package/lib/client/locale/zh-CN.js +17 -2
- package/lib/client/nodes/calculation.d.ts +56 -7
- package/lib/client/nodes/calculation.js +141 -74
- package/lib/client/nodes/condition.d.ts +5 -9
- package/lib/client/nodes/condition.js +30 -93
- package/lib/client/nodes/create.d.ts +36 -12
- package/lib/client/nodes/create.js +14 -28
- package/lib/client/nodes/delay.d.ts +3 -7
- package/lib/client/nodes/delay.js +5 -14
- package/lib/client/nodes/destroy.d.ts +3 -11
- package/lib/client/nodes/destroy.js +14 -12
- package/lib/client/nodes/index.d.ts +2 -2
- package/lib/client/nodes/index.js +181 -222
- package/lib/client/nodes/manual/AssigneesSelect.js +8 -18
- package/lib/client/nodes/manual/ModeConfig.js +0 -27
- package/lib/client/nodes/manual/SchemaConfig.js +87 -449
- package/lib/client/nodes/manual/WorkflowTodo.js +99 -163
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +4 -20
- package/lib/client/nodes/manual/forms/customForm.d.ts +40 -0
- package/lib/client/nodes/manual/forms/customForm.js +411 -0
- package/lib/client/nodes/manual/index.d.ts +15 -6
- package/lib/client/nodes/manual/index.js +58 -54
- package/lib/client/nodes/parallel.d.ts +1 -2
- package/lib/client/nodes/parallel.js +16 -45
- package/lib/client/nodes/query.d.ts +30 -12
- package/lib/client/nodes/query.js +17 -25
- package/lib/client/nodes/request.d.ts +9 -17
- package/lib/client/nodes/request.js +13 -37
- package/lib/client/nodes/update.d.ts +27 -28
- package/lib/client/nodes/update.js +17 -18
- package/lib/client/schemas/collection.d.ts +20 -7
- package/lib/client/schemas/collection.js +27 -28
- package/lib/client/schemas/executions.js +3 -18
- package/lib/client/schemas/workflows.js +10 -33
- package/lib/client/style.js +75 -26
- package/lib/client/triggers/collection.d.ts +47 -18
- package/lib/client/triggers/collection.js +65 -123
- package/lib/client/triggers/index.d.ts +3 -6
- package/lib/client/triggers/index.js +146 -146
- package/lib/client/triggers/schedule/DateFieldsSelect.js +7 -32
- package/lib/client/triggers/schedule/EndsByField.js +1 -18
- package/lib/client/triggers/schedule/OnField.js +10 -38
- package/lib/client/triggers/schedule/RepeatField.js +4 -32
- package/lib/client/triggers/schedule/ScheduleConfig.js +25 -68
- package/lib/client/triggers/schedule/index.d.ts +21 -1
- package/lib/client/triggers/schedule/index.js +22 -24
- package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +8 -4
- package/lib/client/utils.d.ts +1 -0
- package/lib/client/utils.js +31 -10
- package/lib/client/variable.d.ts +7 -6
- package/lib/client/variable.js +132 -71
- package/lib/index.js +0 -2
- package/lib/server/Plugin.d.ts +7 -7
- package/lib/server/Plugin.js +76 -111
- package/lib/server/Processor.d.ts +2 -0
- package/lib/server/Processor.js +62 -125
- package/lib/server/actions/index.js +3 -10
- package/lib/server/actions/nodes.js +34 -87
- package/lib/server/actions/workflows.js +46 -96
- package/lib/server/collections/executions.js +1 -1
- package/lib/server/collections/flow_nodes.js +7 -4
- package/lib/server/collections/jobs.js +1 -1
- package/lib/server/collections/workflows.js +3 -4
- package/lib/server/fields/expression-field.d.ts +8 -0
- package/lib/server/fields/expression-field.js +26 -0
- package/lib/server/fields/index.d.ts +1 -0
- package/lib/server/fields/index.js +12 -0
- package/lib/server/functions/index.js +3 -14
- package/lib/server/index.js +0 -6
- package/lib/server/instructions/calculation.js +22 -17
- package/lib/server/instructions/condition.js +8 -52
- package/lib/server/instructions/create.js +31 -15
- package/lib/server/instructions/delay.js +4 -32
- package/lib/server/instructions/destroy.js +6 -12
- package/lib/server/instructions/index.js +6 -23
- package/lib/server/instructions/manual/actions.js +22 -31
- package/lib/server/instructions/manual/collecions/users_jobs.js +1 -1
- package/lib/server/instructions/manual/index.d.ts +13 -12
- package/lib/server/instructions/manual/index.js +9 -47
- package/lib/server/instructions/parallel.js +9 -36
- package/lib/server/instructions/query.js +17 -15
- package/lib/server/instructions/request.js +7 -30
- package/lib/server/instructions/update.js +8 -14
- package/lib/server/migrations/20221129153547-calculation-variables.js +3 -27
- package/lib/server/migrations/20230221032941-change-request-body-type.js +3 -26
- package/lib/server/migrations/20230221071831-calculation-expression.js +1 -33
- package/lib/server/migrations/20230221121203-condition-calculation.js +5 -28
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +3 -18
- package/lib/server/migrations/20230411034722-manual-multi-form.d.ts +4 -0
- package/lib/server/migrations/20230411034722-manual-multi-form.js +303 -0
- package/lib/server/models/Execution.js +0 -5
- package/lib/server/models/FlowNode.js +0 -5
- package/lib/server/models/Job.js +0 -5
- package/lib/server/models/Workflow.js +0 -5
- package/lib/server/triggers/collection.js +39 -61
- package/lib/server/triggers/index.js +3 -22
- package/lib/server/triggers/schedule.js +72 -194
- package/package.json +14 -11
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _react() {
|
|
8
|
+
const data = _interopRequireWildcard(require("react"));
|
|
9
|
+
_react = function _react() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _lodash() {
|
|
15
|
+
const data = require("lodash");
|
|
16
|
+
_lodash = function _lodash() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _core() {
|
|
22
|
+
const data = require("@formily/core");
|
|
23
|
+
_core = function _core() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _react2() {
|
|
29
|
+
const data = require("@formily/react");
|
|
30
|
+
_react2 = function _react2() {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _antd() {
|
|
36
|
+
const data = require("@formily/antd");
|
|
37
|
+
_antd = function _antd() {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _client() {
|
|
43
|
+
const data = require("@nocobase/client");
|
|
44
|
+
_client = function _client() {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _client2() {
|
|
50
|
+
const data = require("@nocobase/utils/client");
|
|
51
|
+
_client2 = function _client2() {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
var _constants = require("../../../constants");
|
|
57
|
+
var _locale = require("../../../locale");
|
|
58
|
+
const _excluded = ["insert"],
|
|
59
|
+
_excluded2 = ["unique", "type"],
|
|
60
|
+
_excluded3 = ["properties"];
|
|
61
|
+
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); }
|
|
62
|
+
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; }
|
|
63
|
+
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); } }
|
|
64
|
+
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); }); }; }
|
|
65
|
+
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; }
|
|
66
|
+
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; }
|
|
67
|
+
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; }
|
|
68
|
+
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; }
|
|
69
|
+
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; }
|
|
70
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
71
|
+
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); }
|
|
72
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
73
|
+
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."); }
|
|
74
|
+
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); }
|
|
75
|
+
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
|
+
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
|
+
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;
|
|
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
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
+
fields = _useState2[0],
|
|
84
|
+
setCollectionFields = _useState2[1];
|
|
85
|
+
return _react().default.createElement(FormCollectionContext.Provider, {
|
|
86
|
+
value: {
|
|
87
|
+
setCollectionFields
|
|
88
|
+
}
|
|
89
|
+
}, _react().default.createElement(_client().CollectionProvider, {
|
|
90
|
+
collection: _objectSpread(_objectSpread({}, props.collection), {}, {
|
|
91
|
+
fields
|
|
92
|
+
})
|
|
93
|
+
}, props.children));
|
|
94
|
+
}
|
|
95
|
+
function CustomFormBlockInitializer(_ref) {
|
|
96
|
+
let insert = _ref.insert,
|
|
97
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
98
|
+
return _react().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({}, props), {}, {
|
|
99
|
+
onClick: () => {
|
|
100
|
+
insert({
|
|
101
|
+
type: 'void',
|
|
102
|
+
'x-decorator': 'FormCollectionProvider',
|
|
103
|
+
'x-decorator-props': {
|
|
104
|
+
collection: {
|
|
105
|
+
name: (0, _client2().uid)(),
|
|
106
|
+
fields: []
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
'x-component': 'CardItem',
|
|
110
|
+
'x-component-props': {
|
|
111
|
+
title: '{{t("Form")}}'
|
|
112
|
+
},
|
|
113
|
+
'x-designer': 'SimpleDesigner',
|
|
114
|
+
'x-designer-props': {
|
|
115
|
+
type: 'customForm'
|
|
116
|
+
},
|
|
117
|
+
properties: {
|
|
118
|
+
[(0, _client2().uid)()]: {
|
|
119
|
+
type: 'void',
|
|
120
|
+
'x-component': 'FormV2',
|
|
121
|
+
'x-component-props': {
|
|
122
|
+
// disabled / read-pretty / initialValues
|
|
123
|
+
useProps: '{{ useFormBlockProps }}'
|
|
124
|
+
},
|
|
125
|
+
properties: {
|
|
126
|
+
grid: {
|
|
127
|
+
type: 'void',
|
|
128
|
+
'x-component': 'Grid',
|
|
129
|
+
'x-initializer': 'AddCustomFormField'
|
|
130
|
+
},
|
|
131
|
+
actions: {
|
|
132
|
+
type: 'void',
|
|
133
|
+
'x-decorator': 'ActionBarProvider',
|
|
134
|
+
'x-component': 'ActionBar',
|
|
135
|
+
'x-component-props': {
|
|
136
|
+
layout: 'one-column',
|
|
137
|
+
style: {
|
|
138
|
+
marginTop: '1.5em'
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
'x-initializer': 'AddActionButton',
|
|
142
|
+
properties: {
|
|
143
|
+
resolve: {
|
|
144
|
+
type: 'void',
|
|
145
|
+
title: `{{t("Continue the process", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
146
|
+
'x-decorator': 'ManualActionStatusProvider',
|
|
147
|
+
'x-decorator-props': {
|
|
148
|
+
value: _constants.JOB_STATUS.RESOLVED
|
|
149
|
+
},
|
|
150
|
+
'x-component': 'Action',
|
|
151
|
+
'x-component-props': {
|
|
152
|
+
type: 'primary',
|
|
153
|
+
useAction: '{{ useSubmit }}'
|
|
154
|
+
},
|
|
155
|
+
'x-designer': 'Action.Designer',
|
|
156
|
+
'x-action': `${_constants.JOB_STATUS.RESOLVED}`
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
const GroupLabels = {
|
|
168
|
+
basic: '{{t("Basic")}}',
|
|
169
|
+
choices: '{{t("Choices")}}',
|
|
170
|
+
media: '{{t("Media")}}',
|
|
171
|
+
datetime: '{{t("Date & Time")}}',
|
|
172
|
+
relation: '{{t("Relation")}}',
|
|
173
|
+
advanced: '{{t("Advanced type")}}',
|
|
174
|
+
systemInfo: '{{t("System info")}}',
|
|
175
|
+
others: '{{t("Others")}}'
|
|
176
|
+
};
|
|
177
|
+
function getOptions(interfaces) {
|
|
178
|
+
const fields = {};
|
|
179
|
+
Object.keys(interfaces).forEach(type => {
|
|
180
|
+
const schema = interfaces[type];
|
|
181
|
+
const _schema$group = schema.group,
|
|
182
|
+
group = _schema$group === void 0 ? 'others' : _schema$group;
|
|
183
|
+
fields[group] = fields[group] || {};
|
|
184
|
+
(0, _lodash().set)(fields, [group, type], schema);
|
|
185
|
+
});
|
|
186
|
+
return Object.keys(GroupLabels).filter(groupName => ['basic', 'choices', 'datetime', 'media'].includes(groupName)).map(groupName => ({
|
|
187
|
+
title: GroupLabels[groupName],
|
|
188
|
+
children: Object.keys(fields[groupName] || {}).map(type => {
|
|
189
|
+
const field = fields[groupName][type];
|
|
190
|
+
return _objectSpread({
|
|
191
|
+
value: type,
|
|
192
|
+
title: field.title,
|
|
193
|
+
name: type
|
|
194
|
+
}, fields[groupName][type]);
|
|
195
|
+
}).sort((a, b) => a.order - b.order)
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
function useCommonInterfaceInitializers() {
|
|
199
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
200
|
+
interfaces = _useCollectionManager.interfaces;
|
|
201
|
+
const options = getOptions(interfaces);
|
|
202
|
+
return options.map(group => ({
|
|
203
|
+
key: group.title,
|
|
204
|
+
type: 'itemGroup',
|
|
205
|
+
title: group.title,
|
|
206
|
+
children: group.children.map(item => ({
|
|
207
|
+
key: item.name,
|
|
208
|
+
type: 'item',
|
|
209
|
+
title: item.title,
|
|
210
|
+
component: CustomFormFieldInitializer,
|
|
211
|
+
fieldInterface: item.name
|
|
212
|
+
}))
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
const AddCustomFormFieldButtonContext = _react().default.createContext({});
|
|
216
|
+
function AddCustomFormField(props) {
|
|
217
|
+
const _props$insertPosition = props.insertPosition,
|
|
218
|
+
insertPosition = _props$insertPosition === void 0 ? 'beforeEnd' : _props$insertPosition,
|
|
219
|
+
component = props.component;
|
|
220
|
+
const items = useCommonInterfaceInitializers();
|
|
221
|
+
const collection = (0, _react().useContext)(_client().CollectionContext);
|
|
222
|
+
const _useState3 = (0, _react().useState)(null),
|
|
223
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
224
|
+
interfaceOptions = _useState4[0],
|
|
225
|
+
setInterface = _useState4[1];
|
|
226
|
+
const _useState5 = (0, _react().useState)(),
|
|
227
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
228
|
+
insert = _useState6[0],
|
|
229
|
+
setCallback = _useState6[1];
|
|
230
|
+
const _useContext = (0, _react().useContext)(FormCollectionContext),
|
|
231
|
+
setCollectionFields = _useContext.setCollectionFields;
|
|
232
|
+
return _react().default.createElement(AddCustomFormFieldButtonContext.Provider, {
|
|
233
|
+
value: {
|
|
234
|
+
onAddField(item) {
|
|
235
|
+
const _cloneDeep = (0, _lodash().cloneDeep)(item),
|
|
236
|
+
_cloneDeep$properties = _cloneDeep.properties,
|
|
237
|
+
unique = _cloneDeep$properties.unique,
|
|
238
|
+
type = _cloneDeep$properties.type,
|
|
239
|
+
properties = _objectWithoutProperties(_cloneDeep$properties, _excluded2),
|
|
240
|
+
options = _objectWithoutProperties(_cloneDeep, _excluded3);
|
|
241
|
+
delete properties.name['x-disabled'];
|
|
242
|
+
setInterface(_objectSpread(_objectSpread({}, options), {}, {
|
|
243
|
+
properties
|
|
244
|
+
}));
|
|
245
|
+
},
|
|
246
|
+
setCallback
|
|
247
|
+
}
|
|
248
|
+
}, _react().default.createElement(_client().SchemaInitializer.Button, {
|
|
249
|
+
wrap: _client().gridRowColWrap,
|
|
250
|
+
insertPosition: insertPosition,
|
|
251
|
+
items: items,
|
|
252
|
+
component: component,
|
|
253
|
+
title: "{{t('Configure fields')}}"
|
|
254
|
+
}), _react().default.createElement(_client().ActionContext.Provider, {
|
|
255
|
+
value: {
|
|
256
|
+
visible: Boolean(interfaceOptions)
|
|
257
|
+
}
|
|
258
|
+
}, interfaceOptions ? _react().default.createElement(_client().SchemaComponent, {
|
|
259
|
+
schema: {
|
|
260
|
+
type: 'void',
|
|
261
|
+
name: 'drawer',
|
|
262
|
+
title: '{{t("Configure field")}}',
|
|
263
|
+
'x-decorator': 'Form',
|
|
264
|
+
'x-component': 'Action.Drawer',
|
|
265
|
+
properties: _objectSpread(_objectSpread({}, interfaceOptions.properties), {}, {
|
|
266
|
+
footer: {
|
|
267
|
+
type: 'void',
|
|
268
|
+
'x-component': 'Action.Drawer.Footer',
|
|
269
|
+
properties: {
|
|
270
|
+
cancel: {
|
|
271
|
+
type: 'void',
|
|
272
|
+
title: '{{t("Cancel")}}',
|
|
273
|
+
'x-component': 'Action',
|
|
274
|
+
'x-component-props': {
|
|
275
|
+
useAction() {
|
|
276
|
+
const form = (0, _react2().useForm)();
|
|
277
|
+
return {
|
|
278
|
+
run() {
|
|
279
|
+
return _asyncToGenerator(function* () {
|
|
280
|
+
setCallback(null);
|
|
281
|
+
setInterface(null);
|
|
282
|
+
form.reset();
|
|
283
|
+
})();
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
submit: {
|
|
290
|
+
type: 'void',
|
|
291
|
+
title: '{{t("Submit")}}',
|
|
292
|
+
'x-component': 'Action',
|
|
293
|
+
'x-component-props': {
|
|
294
|
+
type: 'primary',
|
|
295
|
+
useAction() {
|
|
296
|
+
const _useForm = (0, _react2().useForm)(),
|
|
297
|
+
values = _useForm.values,
|
|
298
|
+
query = _useForm.query;
|
|
299
|
+
return {
|
|
300
|
+
run() {
|
|
301
|
+
return _asyncToGenerator(function* () {
|
|
302
|
+
var _values$name, _values$uiSchema$titl, _values$uiSchema, _collection$fields;
|
|
303
|
+
const options = interfaceOptions.default;
|
|
304
|
+
const defaultName = (0, _client2().uid)();
|
|
305
|
+
options.name = (_values$name = values.name) !== null && _values$name !== void 0 ? _values$name : defaultName;
|
|
306
|
+
options.uiSchema.title = (_values$uiSchema$titl = (_values$uiSchema = values.uiSchema) === null || _values$uiSchema === void 0 ? void 0 : _values$uiSchema.title) !== null && _values$uiSchema$titl !== void 0 ? _values$uiSchema$titl : defaultName;
|
|
307
|
+
options.interface = interfaceOptions.name;
|
|
308
|
+
const existed = (_collection$fields = collection.fields) === null || _collection$fields === void 0 ? void 0 : _collection$fields.find(item => item.name === options.name);
|
|
309
|
+
if (existed) {
|
|
310
|
+
const field = query('name').take();
|
|
311
|
+
field.setFeedback({
|
|
312
|
+
type: 'error',
|
|
313
|
+
// code: 'FormulaError',
|
|
314
|
+
messages: [(0, _locale.lang)('Field name existed in form')]
|
|
315
|
+
});
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const newField = (0, _client2().merge)(options, values);
|
|
319
|
+
setCollectionFields([...collection.fields, newField]);
|
|
320
|
+
insert({
|
|
321
|
+
name: options.name,
|
|
322
|
+
type: options.uiSchema.type,
|
|
323
|
+
'x-decorator': 'FormItem',
|
|
324
|
+
'x-component': 'CollectionField',
|
|
325
|
+
'x-interface-options': newField,
|
|
326
|
+
'x-collection-field': `${collection.name}.${options.name}`,
|
|
327
|
+
'x-designer': 'FormItem.Designer'
|
|
328
|
+
});
|
|
329
|
+
setCallback(null);
|
|
330
|
+
setInterface(null);
|
|
331
|
+
})();
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
},
|
|
341
|
+
components: {
|
|
342
|
+
ArrayTable: _antd().ArrayTable
|
|
343
|
+
}
|
|
344
|
+
}) : null));
|
|
345
|
+
}
|
|
346
|
+
function CustomFormFieldInitializer(props) {
|
|
347
|
+
const item = props.item,
|
|
348
|
+
insert = props.insert;
|
|
349
|
+
const _useContext2 = (0, _react().useContext)(AddCustomFormFieldButtonContext),
|
|
350
|
+
onAddField = _useContext2.onAddField,
|
|
351
|
+
setCallback = _useContext2.setCallback;
|
|
352
|
+
const _useCollectionManager2 = (0, _client().useCollectionManager)(),
|
|
353
|
+
getInterface = _useCollectionManager2.getInterface;
|
|
354
|
+
const interfaceOptions = getInterface(item.fieldInterface);
|
|
355
|
+
return _react().default.createElement(_client().SchemaInitializer.Item, {
|
|
356
|
+
key: item.fieldInterface,
|
|
357
|
+
onClick: () => {
|
|
358
|
+
setCallback(() => insert);
|
|
359
|
+
onAddField(interfaceOptions);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
;
|
|
364
|
+
function useFormBlockProps() {
|
|
365
|
+
var _user$data;
|
|
366
|
+
const _useRecord = (0, _client().useRecord)(),
|
|
367
|
+
status = _useRecord.status,
|
|
368
|
+
result = _useRecord.result,
|
|
369
|
+
userId = _useRecord.userId;
|
|
370
|
+
const _useCurrentUserContex = (0, _client().useCurrentUserContext)(),
|
|
371
|
+
user = _useCurrentUserContex.data;
|
|
372
|
+
const _useFieldSchema = (0, _react2().useFieldSchema)(),
|
|
373
|
+
name = _useFieldSchema.name;
|
|
374
|
+
const pattern = Boolean(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';
|
|
375
|
+
const form = (0, _react().useMemo)(() => {
|
|
376
|
+
var _result$name;
|
|
377
|
+
return (0, _core().createForm)({
|
|
378
|
+
pattern,
|
|
379
|
+
initialValues: (_result$name = result === null || result === void 0 ? void 0 : result[name]) !== null && _result$name !== void 0 ? _result$name : {}
|
|
380
|
+
});
|
|
381
|
+
}, [result, name]);
|
|
382
|
+
return {
|
|
383
|
+
form
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
var _default = {
|
|
387
|
+
title: `{{t("Custom form", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
388
|
+
config: {
|
|
389
|
+
initializer: {
|
|
390
|
+
key: 'customForm',
|
|
391
|
+
type: 'item',
|
|
392
|
+
title: `{{t("Custom form", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
393
|
+
component: CustomFormBlockInitializer
|
|
394
|
+
},
|
|
395
|
+
initializers: {
|
|
396
|
+
AddCustomFormField
|
|
397
|
+
},
|
|
398
|
+
components: {
|
|
399
|
+
FormCollectionProvider
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
block: {
|
|
403
|
+
scope: {
|
|
404
|
+
useFormBlockProps
|
|
405
|
+
},
|
|
406
|
+
components: {
|
|
407
|
+
FormCollectionProvider: _client().CollectionProvider
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
exports.default = _default;
|
|
@@ -8,9 +8,8 @@ declare const _default: {
|
|
|
8
8
|
type: string;
|
|
9
9
|
group: string;
|
|
10
10
|
fieldset: {
|
|
11
|
-
|
|
11
|
+
assignees: {
|
|
12
12
|
type: string;
|
|
13
|
-
name: string;
|
|
14
13
|
title: string;
|
|
15
14
|
'x-decorator': string;
|
|
16
15
|
'x-component': string;
|
|
@@ -18,9 +17,8 @@ declare const _default: {
|
|
|
18
17
|
required: boolean;
|
|
19
18
|
default: any[];
|
|
20
19
|
};
|
|
21
|
-
|
|
20
|
+
mode: {
|
|
22
21
|
type: string;
|
|
23
|
-
name: string;
|
|
24
22
|
title: string;
|
|
25
23
|
'x-decorator': string;
|
|
26
24
|
'x-component': string;
|
|
@@ -34,7 +32,7 @@ declare const _default: {
|
|
|
34
32
|
};
|
|
35
33
|
};
|
|
36
34
|
};
|
|
37
|
-
|
|
35
|
+
schema: {
|
|
38
36
|
type: string;
|
|
39
37
|
title: string;
|
|
40
38
|
'x-decorator': string;
|
|
@@ -43,9 +41,14 @@ declare const _default: {
|
|
|
43
41
|
schema: {
|
|
44
42
|
type: string;
|
|
45
43
|
'x-component': string;
|
|
44
|
+
default: any;
|
|
46
45
|
};
|
|
47
46
|
};
|
|
48
47
|
};
|
|
48
|
+
forms: {
|
|
49
|
+
type: string;
|
|
50
|
+
default: {};
|
|
51
|
+
};
|
|
49
52
|
};
|
|
50
53
|
view: {};
|
|
51
54
|
scope: {};
|
|
@@ -55,7 +58,13 @@ declare const _default: {
|
|
|
55
58
|
ModeConfig: typeof ModeConfig;
|
|
56
59
|
AssigneesSelect: typeof AssigneesSelect;
|
|
57
60
|
};
|
|
58
|
-
getOptions(config: any, types: any):
|
|
61
|
+
getOptions(config: any, types: any): {
|
|
62
|
+
key: string;
|
|
63
|
+
value: string;
|
|
64
|
+
label: any;
|
|
65
|
+
title: any;
|
|
66
|
+
children: any;
|
|
67
|
+
}[];
|
|
59
68
|
useInitializers(node: any): SchemaInitializerItemOptions | null;
|
|
60
69
|
initializers: {
|
|
61
70
|
CollectionFieldInitializers: typeof CollectionFieldInitializers;
|
|
@@ -4,41 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
function _client() {
|
|
9
8
|
const data = require("@nocobase/client");
|
|
10
|
-
|
|
11
9
|
_client = function _client() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
var _CollectionBlockInitializer = require("../../components/CollectionBlockInitializer");
|
|
19
|
-
|
|
20
15
|
var _CollectionFieldInitializers = require("../../components/CollectionFieldInitializers");
|
|
21
|
-
|
|
22
16
|
var _variable = require("../../variable");
|
|
23
|
-
|
|
24
17
|
var _locale = require("../../locale");
|
|
25
|
-
|
|
26
18
|
var _SchemaConfig = require("./SchemaConfig");
|
|
27
|
-
|
|
28
19
|
var _ModeConfig = require("./ModeConfig");
|
|
29
|
-
|
|
30
20
|
var _AssigneesSelect = require("./AssigneesSelect");
|
|
31
|
-
|
|
32
21
|
const MULTIPLE_ASSIGNED_MODE = {
|
|
33
22
|
SINGLE: Symbol('single'),
|
|
34
23
|
ALL: Symbol('all'),
|
|
35
24
|
ANY: Symbol('any'),
|
|
36
25
|
ALL_PERCENTAGE: Symbol('all percentage'),
|
|
37
26
|
ANY_PERCENTAGE: Symbol('any percentage')
|
|
38
|
-
};
|
|
39
|
-
|
|
27
|
+
};
|
|
28
|
+
// TODO(optimize): change to register way
|
|
40
29
|
const initializerGroup = _client().BlockInitializers.items.find(group => group.key === 'media');
|
|
41
|
-
|
|
42
30
|
if (!initializerGroup.children.find(item => item.key === 'workflowTodos')) {
|
|
43
31
|
initializerGroup.children.push({
|
|
44
32
|
key: 'workflowTodos',
|
|
@@ -48,39 +36,30 @@ if (!initializerGroup.children.find(item => item.key === 'workflowTodos')) {
|
|
|
48
36
|
icon: 'CheckSquareOutlined'
|
|
49
37
|
});
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
var _default = {
|
|
53
40
|
title: `{{t("Manual", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
54
41
|
type: 'manual',
|
|
55
42
|
group: 'manual',
|
|
56
43
|
fieldset: {
|
|
57
|
-
|
|
44
|
+
assignees: {
|
|
58
45
|
type: 'array',
|
|
59
|
-
name: 'config.assignees',
|
|
60
46
|
title: `{{t("Assignees", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
61
47
|
'x-decorator': 'FormItem',
|
|
62
48
|
'x-component': 'AssigneesSelect',
|
|
63
|
-
'x-component-props': {
|
|
64
|
-
//
|
|
65
|
-
// label: 'nickname',
|
|
66
|
-
// value: 'id',
|
|
67
|
-
// },
|
|
68
|
-
// service: {
|
|
69
|
-
// resource: 'users'
|
|
70
|
-
// },
|
|
49
|
+
'x-component-props': {
|
|
50
|
+
// multiple: true,
|
|
71
51
|
},
|
|
72
52
|
required: true,
|
|
73
53
|
default: []
|
|
74
54
|
},
|
|
75
|
-
|
|
55
|
+
mode: {
|
|
76
56
|
type: 'number',
|
|
77
|
-
name: 'config.mode',
|
|
78
57
|
title: `{{t("Mode", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
79
58
|
'x-decorator': 'FormItem',
|
|
80
59
|
'x-component': 'ModeConfig',
|
|
81
60
|
default: 1,
|
|
82
61
|
'x-reactions': {
|
|
83
|
-
dependencies: ['
|
|
62
|
+
dependencies: ['assignees'],
|
|
84
63
|
fulfill: {
|
|
85
64
|
state: {
|
|
86
65
|
visible: '{{$deps[0].length > 1}}'
|
|
@@ -88,7 +67,7 @@ var _default = {
|
|
|
88
67
|
}
|
|
89
68
|
}
|
|
90
69
|
},
|
|
91
|
-
|
|
70
|
+
schema: {
|
|
92
71
|
type: 'void',
|
|
93
72
|
title: `{{t("User interface", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
94
73
|
'x-decorator': 'FormItem',
|
|
@@ -96,9 +75,14 @@ var _default = {
|
|
|
96
75
|
properties: {
|
|
97
76
|
schema: {
|
|
98
77
|
type: 'object',
|
|
99
|
-
'x-component': 'SchemaConfig'
|
|
78
|
+
'x-component': 'SchemaConfig',
|
|
79
|
+
default: null
|
|
100
80
|
}
|
|
101
81
|
}
|
|
82
|
+
},
|
|
83
|
+
forms: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
default: {}
|
|
102
86
|
}
|
|
103
87
|
},
|
|
104
88
|
view: {},
|
|
@@ -109,36 +93,56 @@ var _default = {
|
|
|
109
93
|
ModeConfig: _ModeConfig.ModeConfig,
|
|
110
94
|
AssigneesSelect: _AssigneesSelect.AssigneesSelect
|
|
111
95
|
},
|
|
112
|
-
|
|
113
96
|
getOptions(config, types) {
|
|
114
|
-
var _config$
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
97
|
+
var _config$forms;
|
|
98
|
+
const formKeys = Object.keys((_config$forms = config.forms) !== null && _config$forms !== void 0 ? _config$forms : {});
|
|
99
|
+
if (!formKeys.length) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const options = formKeys.map(formKey => {
|
|
103
|
+
var _form$collection$fiel, _form$collection;
|
|
104
|
+
const form = config.forms[formKey];
|
|
105
|
+
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 => ({
|
|
106
|
+
key: field.name,
|
|
107
|
+
value: field.name,
|
|
108
|
+
label: field.uiSchema.title,
|
|
109
|
+
title: field.uiSchema.title
|
|
110
|
+
}));
|
|
111
|
+
const filteredFields = (0, _variable.filterTypedFields)(fields, types);
|
|
112
|
+
return filteredFields.length ? {
|
|
113
|
+
key: formKey,
|
|
114
|
+
value: formKey,
|
|
115
|
+
label: form.title || formKey,
|
|
116
|
+
title: form.title || formKey,
|
|
117
|
+
children: filteredFields
|
|
118
|
+
} : null;
|
|
119
|
+
}).filter(Boolean);
|
|
120
|
+
return options.length ? options : null;
|
|
124
121
|
},
|
|
125
|
-
|
|
126
122
|
useInitializers(node) {
|
|
127
|
-
var _node$config$
|
|
128
|
-
|
|
129
|
-
if (!
|
|
123
|
+
var _node$config$forms;
|
|
124
|
+
const formKeys = Object.keys((_node$config$forms = node.config.forms) !== null && _node$config$forms !== void 0 ? _node$config$forms : {});
|
|
125
|
+
if (!formKeys.length || node.config.mode) {
|
|
130
126
|
return null;
|
|
131
127
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
128
|
+
const forms = formKeys.map(formKey => {
|
|
129
|
+
var _form$collection2, _form$collection2$fie, _form$title;
|
|
130
|
+
const form = node.config.forms[formKey];
|
|
131
|
+
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) ? {
|
|
132
|
+
type: 'item',
|
|
133
|
+
title: (_form$title = form.title) !== null && _form$title !== void 0 ? _form$title : formKey,
|
|
134
|
+
component: _CollectionBlockInitializer.CollectionBlockInitializer,
|
|
135
|
+
collection: form.collection,
|
|
136
|
+
dataSource: `{{$jobsMapByNodeId.${node.id}.${formKey}}}`
|
|
137
|
+
} : null;
|
|
138
|
+
}).filter(Boolean);
|
|
139
|
+
return forms.length ? {
|
|
140
|
+
key: 'forms',
|
|
141
|
+
type: 'subMenu',
|
|
142
|
+
title: node.title,
|
|
143
|
+
children: forms
|
|
144
|
+
} : null;
|
|
140
145
|
},
|
|
141
|
-
|
|
142
146
|
initializers: {
|
|
143
147
|
CollectionFieldInitializers: _CollectionFieldInitializers.CollectionFieldInitializers
|
|
144
148
|
}
|