@nocobase/plugin-workflow 0.9.0-alpha.1 → 0.9.1-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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/lib/client/AddButton.d.ts +1 -1
- package/lib/client/AddButton.js +7 -2
- package/lib/client/Branch.d.ts +1 -1
- package/lib/client/ExecutionCanvas.js +5 -10
- package/lib/client/WorkflowCanvas.js +11 -40
- package/lib/client/WorkflowProvider.js +10 -1
- package/lib/client/components/CollectionBlockInitializer.d.ts +7 -0
- package/lib/client/components/CollectionBlockInitializer.js +81 -0
- package/lib/client/components/CollectionFieldInitializers.d.ts +2 -0
- package/lib/client/components/CollectionFieldInitializers.js +89 -0
- package/lib/client/components/CollectionFieldset.js +21 -25
- package/lib/client/components/FilterDynamicComponent.d.ts +6 -0
- package/lib/client/components/FilterDynamicComponent.js +43 -0
- package/lib/client/components/NullRender.d.ts +1 -0
- package/lib/client/components/NullRender.js +10 -0
- package/lib/client/components/RadioWithTooltip.d.ts +7 -0
- package/lib/client/components/RadioWithTooltip.js +94 -0
- package/lib/client/constants.d.ts +10 -8
- package/lib/client/constants.js +52 -14
- package/lib/client/index.d.ts +0 -1
- package/lib/client/index.js +1 -10
- package/lib/client/locale/en-US.d.ts +38 -13
- package/lib/client/locale/en-US.js +39 -14
- package/lib/client/locale/index.js +12 -29
- package/lib/client/locale/zh-CN.d.ts +47 -20
- package/lib/client/locale/zh-CN.js +48 -21
- package/lib/client/nodes/calculation.d.ts +40 -6
- package/lib/client/nodes/calculation.js +171 -19
- package/lib/client/nodes/condition.d.ts +67 -0
- package/lib/client/nodes/condition.js +287 -27
- package/lib/client/nodes/create.d.ts +8 -6
- package/lib/client/nodes/create.js +27 -33
- package/lib/client/nodes/delay.d.ts +2 -0
- package/lib/client/nodes/delay.js +8 -4
- package/lib/client/nodes/destroy.d.ts +2 -2
- package/lib/client/nodes/destroy.js +2 -2
- package/lib/client/nodes/index.d.ts +10 -2
- package/lib/client/nodes/index.js +73 -27
- package/lib/client/nodes/manual/AssigneesSelect.d.ts +6 -0
- package/lib/client/nodes/manual/AssigneesSelect.js +64 -0
- package/lib/client/nodes/manual/ModeConfig.d.ts +5 -0
- package/lib/client/nodes/manual/ModeConfig.js +160 -0
- package/lib/client/nodes/manual/SchemaConfig.d.ts +6 -0
- package/lib/client/nodes/manual/SchemaConfig.js +715 -0
- package/lib/client/nodes/manual/WorkflowTodo.d.ts +8 -0
- package/lib/client/nodes/manual/WorkflowTodo.js +691 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +5 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +75 -0
- package/lib/client/nodes/manual/index.d.ts +64 -0
- package/lib/client/nodes/manual/index.js +146 -0
- package/lib/client/nodes/parallel.d.ts +11 -5
- package/lib/client/nodes/parallel.js +22 -34
- package/lib/client/nodes/query.d.ts +9 -14
- package/lib/client/nodes/query.js +38 -44
- package/lib/client/nodes/request.d.ts +75 -33
- package/lib/client/nodes/request.js +124 -63
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +2 -2
- package/lib/client/schemas/collection.js +1 -1
- package/lib/client/schemas/executions.js +1 -1
- package/lib/client/schemas/workflows.js +1 -1
- package/lib/client/style.js +0 -4
- package/lib/client/triggers/collection.d.ts +7 -3
- package/lib/client/triggers/collection.js +39 -48
- package/lib/client/triggers/index.d.ts +5 -2
- package/lib/client/triggers/index.js +34 -12
- package/lib/client/triggers/schedule/index.d.ts +7 -5
- package/lib/client/triggers/schedule/index.js +38 -79
- package/lib/client/utils.d.ts +1 -0
- package/lib/client/utils.js +38 -0
- package/lib/client/variable.d.ts +21 -0
- package/lib/client/variable.js +147 -0
- package/lib/server/Plugin.d.ts +3 -3
- package/lib/server/Plugin.js +12 -21
- package/lib/server/Processor.d.ts +9 -2
- package/lib/server/Processor.js +39 -43
- package/lib/server/actions/index.js +2 -4
- package/lib/server/actions/workflows.d.ts +1 -0
- package/lib/server/actions/workflows.js +80 -23
- package/lib/server/collections/executions.js +5 -7
- package/lib/server/collections/flow_nodes.js +6 -18
- package/lib/server/collections/jobs.js +3 -1
- package/lib/server/collections/workflows.js +8 -4
- package/lib/server/constants.d.ts +9 -3
- package/lib/server/constants.js +11 -5
- package/lib/server/functions/index.d.ts +4 -0
- package/lib/server/functions/index.js +38 -0
- package/lib/server/index.d.ts +0 -1
- package/lib/server/index.js +0 -14
- package/lib/server/instructions/calculation.d.ts +2 -7
- package/lib/server/instructions/calculation.js +32 -37
- package/lib/server/instructions/condition.d.ts +4 -4
- package/lib/server/instructions/condition.js +126 -54
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/manual/actions.js +101 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.d.ts +2 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.js +2 -1
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.js +10 -10
- package/lib/server/instructions/manual/index.d.ts +25 -0
- package/lib/server/instructions/manual/index.js +200 -0
- package/lib/server/instructions/parallel.js +11 -7
- package/lib/server/instructions/request.d.ts +8 -4
- package/lib/server/instructions/request.js +60 -94
- package/lib/server/migrations/20230221032941-change-request-body-type.d.ts +5 -0
- package/lib/server/migrations/20230221032941-change-request-body-type.js +113 -0
- package/lib/server/migrations/20230221071831-calculation-expression.d.ts +4 -0
- package/lib/server/migrations/20230221071831-calculation-expression.js +143 -0
- package/lib/server/migrations/20230221121203-condition-calculation.d.ts +4 -0
- package/lib/server/migrations/20230221121203-condition-calculation.js +126 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.d.ts +4 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +81 -0
- package/lib/server/triggers/schedule.js +11 -3
- package/package.json +11 -10
- package/lib/client/calculators.d.ts +0 -89
- package/lib/client/calculators.js +0 -668
- package/lib/client/components/CollectionFieldSelect.d.ts +0 -2
- package/lib/client/components/CollectionFieldSelect.js +0 -106
- package/lib/client/components/EjsTextArea.d.ts +0 -2
- package/lib/client/components/EjsTextArea.js +0 -232
- package/lib/server/actions/jobs.d.ts +0 -2
- package/lib/server/actions/jobs.js +0 -39
- package/lib/server/calculators/index.d.ts +0 -40
- package/lib/server/calculators/index.js +0 -187
- package/lib/server/extensions/assignees/actions.js +0 -75
- package/lib/server/extensions/assignees/index.d.ts +0 -2
- package/lib/server/extensions/assignees/index.js +0 -273
- package/lib/server/extensions/index.d.ts +0 -3
- package/lib/server/extensions/index.js +0 -13
- package/lib/server/instructions/prompt.d.ts +0 -19
- package/lib/server/instructions/prompt.js +0 -131
- /package/lib/server/{extensions/assignees → instructions/manual}/actions.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.js +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.d.ts +0 -0
package/README.md
ADDED
package/README.zh-CN.md
ADDED
package/lib/client/AddButton.js
CHANGED
|
@@ -119,8 +119,10 @@ function AddButton({
|
|
|
119
119
|
optionKey = _keyPath[0];
|
|
120
120
|
|
|
121
121
|
if (optionKey) {
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
var _instructions$get$opt, _instructions$get, _instructions$get$opt2;
|
|
123
|
+
|
|
124
|
+
const _ref2 = (_instructions$get$opt = (_instructions$get = _nodes.instructions.get(type)) === null || _instructions$get === void 0 ? void 0 : (_instructions$get$opt2 = _instructions$get.options) === null || _instructions$get$opt2 === void 0 ? void 0 : _instructions$get$opt2.find(item => item.key === optionKey)) !== null && _instructions$get$opt !== void 0 ? _instructions$get$opt : {},
|
|
125
|
+
value = _ref2.value;
|
|
124
126
|
|
|
125
127
|
Object.assign(config, value);
|
|
126
128
|
}
|
|
@@ -146,6 +148,9 @@ function AddButton({
|
|
|
146
148
|
}, {
|
|
147
149
|
value: 'collection',
|
|
148
150
|
name: `{{t("Collection operations", { ns: "${_locale.NAMESPACE}" })}}`
|
|
151
|
+
}, {
|
|
152
|
+
value: 'manual',
|
|
153
|
+
name: `{{t("Manual", { ns: "${_locale.NAMESPACE}" })}}`
|
|
149
154
|
}, {
|
|
150
155
|
value: 'extended',
|
|
151
156
|
name: `{{t("Extended types", { ns: "${_locale.NAMESPACE}" })}}`
|
package/lib/client/Branch.d.ts
CHANGED
|
@@ -77,6 +77,8 @@ var _constants = require("./constants");
|
|
|
77
77
|
|
|
78
78
|
var _locale = require("./locale");
|
|
79
79
|
|
|
80
|
+
var _utils = require("./utils");
|
|
81
|
+
|
|
80
82
|
const _excluded = ["nodes", "revisions"],
|
|
81
83
|
_excluded2 = ["jobs", "workflow"];
|
|
82
84
|
|
|
@@ -94,7 +96,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
94
96
|
|
|
95
97
|
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; }
|
|
96
98
|
|
|
97
|
-
function
|
|
99
|
+
function attachJobs(nodes, jobs = []) {
|
|
98
100
|
const nodesMap = new Map();
|
|
99
101
|
nodes.forEach(item => nodesMap.set(item.id, item));
|
|
100
102
|
const jobsMap = new Map();
|
|
@@ -107,14 +109,6 @@ function makeNodes(nodes, jobs = []) {
|
|
|
107
109
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
108
110
|
let node = _step.value;
|
|
109
111
|
|
|
110
|
-
if (node.upstreamId) {
|
|
111
|
-
node.upstream = nodesMap.get(node.upstreamId);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (node.downstreamId) {
|
|
115
|
-
node.downstream = nodesMap.get(node.downstreamId);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
112
|
if (jobsMap.has(node.id)) {
|
|
119
113
|
node.job = jobsMap.get(node.id);
|
|
120
114
|
}
|
|
@@ -167,7 +161,8 @@ function ExecutionCanvas() {
|
|
|
167
161
|
workflow = _objectWithoutProperties(_ref2$workflow2, _excluded),
|
|
168
162
|
execution = _objectWithoutProperties(_ref2, _excluded2);
|
|
169
163
|
|
|
170
|
-
|
|
164
|
+
(0, _utils.linkNodes)(nodes);
|
|
165
|
+
attachJobs(nodes, jobs);
|
|
171
166
|
const entry = nodes.find(item => !item.upstream);
|
|
172
167
|
const statusOption = _constants.ExecutionStatusOptionsMap[execution.status];
|
|
173
168
|
return _react().default.createElement(_FlowContext.FlowContext.Provider, {
|
|
@@ -99,6 +99,8 @@ var _ExecutionLink = require("./ExecutionLink");
|
|
|
99
99
|
|
|
100
100
|
var _locale = require("./locale");
|
|
101
101
|
|
|
102
|
+
var _utils = require("./utils");
|
|
103
|
+
|
|
102
104
|
const _excluded = ["request", "filter"],
|
|
103
105
|
_excluded2 = ["nodes", "revisions"];
|
|
104
106
|
|
|
@@ -116,16 +118,14 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
116
118
|
|
|
117
119
|
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."); }
|
|
118
120
|
|
|
119
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
120
|
-
|
|
121
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
122
|
-
|
|
123
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
124
|
-
|
|
125
121
|
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); }
|
|
126
122
|
|
|
127
123
|
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; }
|
|
128
124
|
|
|
125
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
126
|
+
|
|
127
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
128
|
+
|
|
129
129
|
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; }
|
|
130
130
|
|
|
131
131
|
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; }
|
|
@@ -160,32 +160,6 @@ function ExecutionResourceProvider(_ref) {
|
|
|
160
160
|
return _react().default.createElement(_client().ResourceActionProvider, _objectSpread({}, props));
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
function makeNodes(nodes) {
|
|
164
|
-
const nodesMap = new Map();
|
|
165
|
-
nodes.forEach(item => nodesMap.set(item.id, item));
|
|
166
|
-
|
|
167
|
-
var _iterator = _createForOfIteratorHelper(nodesMap.values()),
|
|
168
|
-
_step;
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
172
|
-
let node = _step.value;
|
|
173
|
-
|
|
174
|
-
if (node.upstreamId) {
|
|
175
|
-
node.upstream = nodesMap.get(node.upstreamId);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (node.downstreamId) {
|
|
179
|
-
node.downstream = nodesMap.get(node.downstreamId);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
} catch (err) {
|
|
183
|
-
_iterator.e(err);
|
|
184
|
-
} finally {
|
|
185
|
-
_iterator.f();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
163
|
function WorkflowCanvas() {
|
|
190
164
|
var _data$data2;
|
|
191
165
|
|
|
@@ -200,8 +174,7 @@ function WorkflowCanvas() {
|
|
|
200
174
|
loading = _useResourceActionCon.loading;
|
|
201
175
|
|
|
202
176
|
const _useResourceContext = (0, _client().useResourceContext)(),
|
|
203
|
-
resource = _useResourceContext.resource
|
|
204
|
-
targetKey = _useResourceContext.targetKey;
|
|
177
|
+
resource = _useResourceContext.resource;
|
|
205
178
|
|
|
206
179
|
const _useDocumentTitle = (0, _client().useDocumentTitle)(),
|
|
207
180
|
setTitle = _useDocumentTitle.setTitle;
|
|
@@ -231,7 +204,7 @@ function WorkflowCanvas() {
|
|
|
231
204
|
revisions = _ref3$revisions === void 0 ? [] : _ref3$revisions,
|
|
232
205
|
workflow = _objectWithoutProperties(_ref3, _excluded2);
|
|
233
206
|
|
|
234
|
-
|
|
207
|
+
(0, _utils.linkNodes)(nodes);
|
|
235
208
|
const entry = nodes.find(item => !item.upstream);
|
|
236
209
|
|
|
237
210
|
function onSwitchVersion({
|
|
@@ -249,11 +222,9 @@ function WorkflowCanvas() {
|
|
|
249
222
|
function _onToggle() {
|
|
250
223
|
_onToggle = _asyncToGenerator(function* (value) {
|
|
251
224
|
yield resource.update({
|
|
252
|
-
filterByTk: workflow
|
|
225
|
+
filterByTk: workflow.id,
|
|
253
226
|
values: {
|
|
254
|
-
enabled: value
|
|
255
|
-
// NOTE: keep `key` field to adapt for backend
|
|
256
|
-
key: workflow.key
|
|
227
|
+
enabled: value
|
|
257
228
|
}
|
|
258
229
|
});
|
|
259
230
|
refresh();
|
|
@@ -268,7 +239,7 @@ function WorkflowCanvas() {
|
|
|
268
239
|
function _onRevision() {
|
|
269
240
|
_onRevision = _asyncToGenerator(function* () {
|
|
270
241
|
const _yield$resource$revis = yield resource.revision({
|
|
271
|
-
filterByTk: workflow
|
|
242
|
+
filterByTk: workflow.id,
|
|
272
243
|
filter: {
|
|
273
244
|
key: workflow.key
|
|
274
245
|
}
|
|
@@ -56,6 +56,10 @@ var _ExecutionLink = require("./ExecutionLink");
|
|
|
56
56
|
|
|
57
57
|
var _OpenDrawer = _interopRequireDefault(require("./components/OpenDrawer"));
|
|
58
58
|
|
|
59
|
+
var _WorkflowTodo = require("./nodes/manual/WorkflowTodo");
|
|
60
|
+
|
|
61
|
+
var _WorkflowTodoBlockInitializer = require("./nodes/manual/WorkflowTodoBlockInitializer");
|
|
62
|
+
|
|
59
63
|
const _excluded = ["routes", "components"];
|
|
60
64
|
|
|
61
65
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -143,12 +147,17 @@ const WorkflowProvider = props => {
|
|
|
143
147
|
}, others), {}, {
|
|
144
148
|
routes
|
|
145
149
|
})
|
|
150
|
+
}, _react().default.createElement(_client().SchemaComponentOptions, {
|
|
151
|
+
components: {
|
|
152
|
+
WorkflowTodo: _WorkflowTodo.WorkflowTodo,
|
|
153
|
+
WorkflowTodoBlockInitializer: _WorkflowTodoBlockInitializer.WorkflowTodoBlockInitializer
|
|
154
|
+
}
|
|
146
155
|
}, _react().default.createElement(WorkflowContext.Provider, {
|
|
147
156
|
value: {
|
|
148
157
|
triggers: _triggers.triggers,
|
|
149
158
|
instructions: _nodes.instructions
|
|
150
159
|
}
|
|
151
|
-
}, props.children))));
|
|
160
|
+
}, props.children)))));
|
|
152
161
|
};
|
|
153
162
|
|
|
154
163
|
exports.WorkflowProvider = WorkflowProvider;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CollectionBlockInitializer = CollectionBlockInitializer;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = _interopRequireDefault(require("react"));
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _client() {
|
|
19
|
+
const data = require("@nocobase/client");
|
|
20
|
+
|
|
21
|
+
_client = function _client() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const _excluded = ["insert", "collection", "dataSource"];
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
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
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
|
|
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
|
+
|
|
42
|
+
function CollectionBlockInitializer(_ref) {
|
|
43
|
+
let insert = _ref.insert,
|
|
44
|
+
collection = _ref.collection,
|
|
45
|
+
dataSource = _ref.dataSource,
|
|
46
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
+
|
|
48
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
49
|
+
getCollection = _useCollectionManager.getCollection;
|
|
50
|
+
|
|
51
|
+
const resovledCollection = getCollection(collection);
|
|
52
|
+
return _react().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({}, props), {}, {
|
|
53
|
+
onClick: () => {
|
|
54
|
+
insert({
|
|
55
|
+
type: 'void',
|
|
56
|
+
name: resovledCollection.name,
|
|
57
|
+
title: resovledCollection.title,
|
|
58
|
+
'x-decorator': 'CollectionProvider',
|
|
59
|
+
'x-decorator-props': {
|
|
60
|
+
collection
|
|
61
|
+
},
|
|
62
|
+
'x-component': 'CardItem',
|
|
63
|
+
'x-component-props': {// title: props.title
|
|
64
|
+
},
|
|
65
|
+
'x-designer': 'SimpleDesigner',
|
|
66
|
+
properties: {
|
|
67
|
+
grid: {
|
|
68
|
+
type: 'void',
|
|
69
|
+
'x-decorator': 'Form',
|
|
70
|
+
'x-decorator-props': {
|
|
71
|
+
useValues: '{{ useFlowRecordFromBlock }}'
|
|
72
|
+
},
|
|
73
|
+
'x-component': 'Grid',
|
|
74
|
+
'x-initializer': 'CollectionFieldInitializers',
|
|
75
|
+
'x-context-datasource': dataSource
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CollectionFieldInitializers = CollectionFieldInitializers;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = _interopRequireDefault(require("react"));
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _lodash() {
|
|
19
|
+
const data = require("lodash");
|
|
20
|
+
|
|
21
|
+
_lodash = function _lodash() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _client() {
|
|
29
|
+
const data = require("@nocobase/client");
|
|
30
|
+
|
|
31
|
+
_client = function _client() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const _excluded = ["field"];
|
|
39
|
+
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
+
|
|
42
|
+
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; }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
45
|
+
|
|
46
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
|
+
|
|
48
|
+
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; }
|
|
49
|
+
|
|
50
|
+
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; }
|
|
51
|
+
|
|
52
|
+
function CollectionFieldInitializer(_ref) {
|
|
53
|
+
var _uiSchema$title;
|
|
54
|
+
|
|
55
|
+
let field = _ref.field,
|
|
56
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
57
|
+
|
|
58
|
+
const uiSchema = (0, _lodash().cloneDeep)(field.uiSchema);
|
|
59
|
+
delete uiSchema['x-uid'];
|
|
60
|
+
return _react().default.createElement(_client().InitializerWithSwitch, _objectSpread(_objectSpread({}, props), {}, {
|
|
61
|
+
schema: _objectSpread(_objectSpread({}, uiSchema), {}, {
|
|
62
|
+
name: field.name,
|
|
63
|
+
title: (_uiSchema$title = uiSchema.title) !== null && _uiSchema$title !== void 0 ? _uiSchema$title : field.name,
|
|
64
|
+
'x-decorator': 'FormItem',
|
|
65
|
+
'x-read-pretty': true,
|
|
66
|
+
'x-designer': 'FormItem.Designer',
|
|
67
|
+
'x-collection-field': field.name
|
|
68
|
+
}),
|
|
69
|
+
type: "x-collection-field"
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function CollectionFieldInitializers(props) {
|
|
74
|
+
const _useCollection = (0, _client().useCollection)(),
|
|
75
|
+
fields = _useCollection.fields;
|
|
76
|
+
|
|
77
|
+
const items = fields.filter(field => !['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type) && field.uiSchema).map(field => ({
|
|
78
|
+
key: field.name,
|
|
79
|
+
type: 'item',
|
|
80
|
+
title: field.uiSchema.title,
|
|
81
|
+
component: CollectionFieldInitializer,
|
|
82
|
+
field
|
|
83
|
+
}));
|
|
84
|
+
return _react().default.createElement(_client().SchemaInitializer.Button, _objectSpread(_objectSpread({}, props), {}, {
|
|
85
|
+
items: items,
|
|
86
|
+
title: "{{t('Configure fields')}}",
|
|
87
|
+
wrap: _client().gridRowColWrap
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
@@ -75,10 +75,10 @@ function _client() {
|
|
|
75
75
|
return data;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
var _calculators = require("../calculators");
|
|
79
|
-
|
|
80
78
|
var _locale = require("../locale");
|
|
81
79
|
|
|
80
|
+
var _variable = require("../variable");
|
|
81
|
+
|
|
82
82
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
83
83
|
|
|
84
84
|
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; }
|
|
@@ -130,6 +130,7 @@ function AssociationInput(props) {
|
|
|
130
130
|
|
|
131
131
|
var _default = (0, _react2().observer)(({
|
|
132
132
|
value,
|
|
133
|
+
disabled,
|
|
133
134
|
onChange: _onChange
|
|
134
135
|
}) => {
|
|
135
136
|
var _data$config2;
|
|
@@ -138,6 +139,7 @@ var _default = (0, _react2().observer)(({
|
|
|
138
139
|
t = _useTranslation.t;
|
|
139
140
|
|
|
140
141
|
const compile = (0, _client().useCompile)();
|
|
142
|
+
const form = (0, _react2().useForm)();
|
|
141
143
|
|
|
142
144
|
const _useCollectionManager2 = (0, _client().useCollectionManager)(),
|
|
143
145
|
getCollection = _useCollectionManager2.getCollection,
|
|
@@ -147,9 +149,11 @@ var _default = (0, _react2().observer)(({
|
|
|
147
149
|
data = _useForm2.values;
|
|
148
150
|
|
|
149
151
|
const collectionName = data === null || data === void 0 ? void 0 : (_data$config2 = data.config) === null || _data$config2 === void 0 ? void 0 : _data$config2.collection;
|
|
150
|
-
const fields = getCollectionFields(collectionName).filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false) //
|
|
151
|
-
);
|
|
152
|
+
const fields = getCollectionFields(collectionName).filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false) // TODO: should use some field option but not type to control this
|
|
153
|
+
&& !['formula'].includes(field.type));
|
|
152
154
|
const unassignedFields = fields.filter(field => !(field.name in value));
|
|
155
|
+
const scope = (0, _variable.useWorkflowVariableOptions)();
|
|
156
|
+
const mergedDisabled = disabled || form.disabled;
|
|
153
157
|
return _react().default.createElement("fieldset", {
|
|
154
158
|
className: (0, _css().css)`
|
|
155
159
|
margin-top: .5em;
|
|
@@ -167,16 +171,9 @@ var _default = (0, _react2().observer)(({
|
|
|
167
171
|
}, fields.filter(field => field.name in value).map(field => {
|
|
168
172
|
var _field$uiSchema$title, _field$uiSchema;
|
|
169
173
|
|
|
170
|
-
|
|
171
|
-
constant: {
|
|
172
|
-
title: `{{t("Constant", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
173
|
-
value: 'constant'
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const operand = (0, _calculators.parseValue)(value[field.name], VTypes); // constant for associations to use Input, others to use CollectionField
|
|
174
|
+
// constant for associations to use Input, others to use CollectionField
|
|
178
175
|
// dynamic values only support belongsTo/hasOne association, other association type should disable
|
|
179
|
-
// TODO: try to use <ObjectField> to replace this map
|
|
176
|
+
const ConstantCompoent = ['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type) ? AssociationInput : _client().CollectionField; // TODO: try to use <ObjectField> to replace this map
|
|
180
177
|
|
|
181
178
|
return _react().default.createElement(_antd().Form.Item, {
|
|
182
179
|
key: field.name,
|
|
@@ -187,30 +184,29 @@ var _default = (0, _react2().observer)(({
|
|
|
187
184
|
display: flex;
|
|
188
185
|
}
|
|
189
186
|
`
|
|
190
|
-
}, _react().default.createElement(
|
|
191
|
-
|
|
192
|
-
}, _react().default.createElement(_calculators.Operand, {
|
|
187
|
+
}, _react().default.createElement(_client().Variable.Input, {
|
|
188
|
+
scope: ['hasMany', 'belongsToMany'].includes(field.type) ? [] : scope,
|
|
193
189
|
value: value[field.name],
|
|
194
190
|
onChange: next => {
|
|
195
191
|
_onChange(_objectSpread(_objectSpread({}, value), {}, {
|
|
196
192
|
[field.name]: next
|
|
197
193
|
}));
|
|
198
194
|
}
|
|
199
|
-
},
|
|
195
|
+
}, _react().default.createElement(_client().SchemaComponent, {
|
|
200
196
|
schema: {
|
|
201
197
|
type: 'void',
|
|
202
198
|
properties: {
|
|
203
199
|
[field.name]: {
|
|
204
|
-
'x-component':
|
|
200
|
+
'x-component': ConstantCompoent,
|
|
201
|
+
|
|
202
|
+
['x-validator']() {
|
|
203
|
+
return '';
|
|
204
|
+
}
|
|
205
|
+
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
|
-
},
|
|
208
|
-
components: {
|
|
209
|
-
CollectionField: _client().CollectionField,
|
|
210
|
-
AssociationInput
|
|
211
208
|
}
|
|
212
|
-
})
|
|
213
|
-
: null), _react().default.createElement(_antd().Button, {
|
|
209
|
+
})), !mergedDisabled ? _react().default.createElement(_antd().Button, {
|
|
214
210
|
type: "link",
|
|
215
211
|
icon: _react().default.createElement(_icons().CloseCircleOutlined, null),
|
|
216
212
|
onClick: () => {
|
|
@@ -220,7 +216,7 @@ var _default = (0, _react2().observer)(({
|
|
|
220
216
|
|
|
221
217
|
_onChange(rest);
|
|
222
218
|
}
|
|
223
|
-
}))
|
|
219
|
+
}) : null);
|
|
224
220
|
}), unassignedFields.length ? _react().default.createElement(_antd().Dropdown, {
|
|
225
221
|
overlay: _react().default.createElement(_antd().Menu, {
|
|
226
222
|
onClick: ({
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FilterDynamicComponent = FilterDynamicComponent;
|
|
7
|
+
|
|
8
|
+
function _react() {
|
|
9
|
+
const data = _interopRequireDefault(require("react"));
|
|
10
|
+
|
|
11
|
+
_react = function _react() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _client() {
|
|
19
|
+
const data = require("@nocobase/client");
|
|
20
|
+
|
|
21
|
+
_client = function _client() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _variable = require("../variable");
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
32
|
+
function FilterDynamicComponent({
|
|
33
|
+
value,
|
|
34
|
+
onChange,
|
|
35
|
+
renderSchemaComponent
|
|
36
|
+
}) {
|
|
37
|
+
const scope = (0, _variable.useWorkflowVariableOptions)();
|
|
38
|
+
return _react().default.createElement(_client().Variable.Input, {
|
|
39
|
+
value: value,
|
|
40
|
+
onChange: onChange,
|
|
41
|
+
scope: scope
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function NullRender(): any;
|