@nocobase/plugin-workflow 0.8.0-alpha.9 → 0.8.1-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.js +21 -13
- package/lib/client/ExecutionCanvas.js +9 -21
- package/lib/client/ExecutionResourceProvider.d.ts +2 -1
- package/lib/client/ExecutionResourceProvider.js +4 -3
- package/lib/client/FlowContext.js +1 -1
- package/lib/client/WorkflowCanvas.js +135 -36
- package/lib/client/WorkflowProvider.d.ts +3 -0
- package/lib/client/WorkflowProvider.js +71 -16
- package/lib/client/WorkflowShortcut.d.ts +0 -1
- package/lib/client/WorkflowShortcut.js +4 -47
- package/lib/client/calculators.d.ts +27 -37
- package/lib/client/calculators.js +168 -150
- package/lib/client/components/CollectionFieldset.js +10 -20
- package/lib/client/components/Duration.js +3 -14
- package/lib/client/components/EjsTextArea.d.ts +2 -0
- package/lib/client/components/EjsTextArea.js +232 -0
- package/lib/client/components/OpenDrawer.d.ts +6 -0
- package/lib/client/components/OpenDrawer.js +93 -0
- package/lib/client/constants.js +11 -9
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +14 -0
- package/lib/client/locale/en-US.d.ts +105 -0
- package/lib/client/locale/en-US.js +111 -0
- package/lib/client/locale/index.d.ts +3 -0
- package/lib/client/locale/index.js +69 -0
- package/lib/client/locale/ja-JP.d.ts +88 -0
- package/lib/client/locale/ja-JP.js +94 -0
- package/lib/client/locale/ru-RU.d.ts +88 -0
- package/lib/client/locale/ru-RU.js +94 -0
- package/lib/client/locale/tr-TR.d.ts +88 -0
- package/lib/client/locale/tr-TR.js +94 -0
- package/lib/client/locale/zh-CN.d.ts +130 -0
- package/lib/client/locale/zh-CN.js +136 -0
- package/lib/client/nodes/calculation.d.ts +0 -1
- package/lib/client/nodes/calculation.js +9 -17
- package/lib/client/nodes/condition.js +16 -22
- package/lib/client/nodes/create.d.ts +3 -1
- package/lib/client/nodes/create.js +11 -11
- package/lib/client/nodes/delay.js +8 -6
- package/lib/client/nodes/index.js +46 -14
- package/lib/client/nodes/parallel.d.ts +0 -1
- package/lib/client/nodes/parallel.js +11 -32
- package/lib/client/nodes/query.js +9 -17
- package/lib/client/nodes/request.d.ts +138 -0
- package/lib/client/nodes/request.js +167 -0
- package/lib/client/nodes/update.js +4 -2
- package/lib/client/schemas/collection.js +3 -1
- package/lib/client/schemas/executions.d.ts +211 -207
- package/lib/client/schemas/executions.js +102 -96
- package/lib/client/schemas/workflows.js +112 -22
- package/lib/client/style.js +7 -7
- package/lib/client/triggers/collection.d.ts +2 -1
- package/lib/client/triggers/collection.js +49 -34
- package/lib/client/triggers/index.d.ts +3 -3
- package/lib/client/triggers/index.js +46 -46
- package/lib/client/triggers/schedule/EndsByField.js +13 -39
- package/lib/client/triggers/schedule/OnField.js +10 -5
- package/lib/client/triggers/schedule/RepeatField.js +6 -14
- package/lib/client/triggers/schedule/ScheduleConfig.js +25 -20
- package/lib/client/triggers/schedule/constants.d.ts +4 -0
- package/lib/client/triggers/schedule/constants.js +11 -0
- package/lib/client/triggers/schedule/index.d.ts +2 -3
- package/lib/client/triggers/schedule/index.js +55 -40
- package/lib/server/Plugin.d.ts +15 -5
- package/lib/server/Plugin.js +176 -61
- package/lib/server/Processor.d.ts +1 -2
- package/lib/server/Processor.js +3 -19
- package/lib/server/actions/jobs.js +2 -3
- package/lib/server/actions/workflows.js +13 -5
- package/lib/server/calculators/index.d.ts +4 -2
- package/lib/server/calculators/index.js +6 -4
- package/lib/server/collections/executions.js +2 -1
- package/lib/server/constants.d.ts +1 -0
- package/lib/server/constants.js +1 -0
- package/lib/server/extensions/assignees/actions.js +2 -3
- package/lib/server/extensions/assignees/collections/users_jobs.js +9 -1
- package/lib/server/index.d.ts +3 -4
- package/lib/server/index.js +21 -44
- package/lib/server/instructions/condition.js +1 -1
- package/lib/server/instructions/create.js +3 -1
- package/lib/server/instructions/delay.js +2 -3
- package/lib/server/instructions/destroy.js +3 -1
- package/lib/server/instructions/index.d.ts +3 -2
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/prompt.js +2 -1
- package/lib/server/instructions/query.js +3 -1
- package/lib/server/instructions/request.d.ts +14 -0
- package/lib/server/instructions/request.js +154 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/instructions/update.js +3 -1
- package/lib/server/migrations/20221129153547-calculation-variables.d.ts +5 -0
- package/lib/server/migrations/20221129153547-calculation-variables.js +116 -0
- package/lib/server/triggers/collection.js +5 -7
- package/lib/server/triggers/schedule.js +17 -6
- package/package.json +13 -8
|
@@ -8,7 +8,8 @@ exports.Calculation = Calculation;
|
|
|
8
8
|
exports.Operand = Operand;
|
|
9
9
|
exports.VariableComponent = VariableComponent;
|
|
10
10
|
exports.calculators = exports.VariableTypesContext = exports.VariableTypes = void 0;
|
|
11
|
-
exports.
|
|
11
|
+
exports.parseValue = parseValue;
|
|
12
|
+
exports.useOperandContext = useOperandContext;
|
|
12
13
|
exports.useVariableTypes = useVariableTypes;
|
|
13
14
|
|
|
14
15
|
function _react() {
|
|
@@ -77,6 +78,8 @@ function _client2() {
|
|
|
77
78
|
return data;
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
var _locale = require("./locale");
|
|
82
|
+
|
|
80
83
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
81
84
|
|
|
82
85
|
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; }
|
|
@@ -189,22 +192,22 @@ calculators.register('notEndsWith', {
|
|
|
189
192
|
group: 'string'
|
|
190
193
|
});
|
|
191
194
|
calculators.register('concat', {
|
|
192
|
-
name:
|
|
195
|
+
name: `{{t("concat", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
193
196
|
type: 'string',
|
|
194
197
|
group: 'string'
|
|
195
198
|
});
|
|
196
199
|
const calculatorGroups = [{
|
|
197
200
|
value: 'boolean',
|
|
198
|
-
title: '{{t("
|
|
201
|
+
title: '{{t("Comparision")}}'
|
|
199
202
|
}, {
|
|
200
203
|
value: 'number',
|
|
201
|
-
title:
|
|
204
|
+
title: `{{t("Arithmetic calculation", { ns: "${_locale.NAMESPACE}" })}}`
|
|
202
205
|
}, {
|
|
203
206
|
value: 'string',
|
|
204
|
-
title:
|
|
207
|
+
title: `{{t("String operation", { ns: "${_locale.NAMESPACE}" })}}`
|
|
205
208
|
}, {
|
|
206
209
|
value: 'date',
|
|
207
|
-
title:
|
|
210
|
+
title: `{{t("Date", { ns: "${_locale.NAMESPACE}" })}}`
|
|
208
211
|
}];
|
|
209
212
|
|
|
210
213
|
function getGroupCalculators(group) {
|
|
@@ -213,9 +216,48 @@ function getGroupCalculators(group) {
|
|
|
213
216
|
|
|
214
217
|
const JT_VALUE_RE = /^\s*\{\{([\s\S]*)\}\}\s*$/;
|
|
215
218
|
|
|
216
|
-
function
|
|
219
|
+
function getType(value) {
|
|
220
|
+
if (value == null) {
|
|
221
|
+
return 'null';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const type = typeof value;
|
|
225
|
+
|
|
226
|
+
switch (type) {
|
|
227
|
+
case 'object':
|
|
228
|
+
break;
|
|
229
|
+
|
|
230
|
+
default:
|
|
231
|
+
// 'boolean'
|
|
232
|
+
// 'number'
|
|
233
|
+
// 'bigint'
|
|
234
|
+
// 'string'
|
|
235
|
+
// 'symbol'
|
|
236
|
+
return type;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (value instanceof Date) {
|
|
240
|
+
return 'date';
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return 'object';
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function parseValue(value, Types) {
|
|
217
247
|
var _type;
|
|
218
248
|
|
|
249
|
+
const valueType = getType(value);
|
|
250
|
+
|
|
251
|
+
if (valueType !== 'string') {
|
|
252
|
+
return {
|
|
253
|
+
type: 'constant',
|
|
254
|
+
value,
|
|
255
|
+
options: {
|
|
256
|
+
type: valueType
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
219
261
|
const matcher = value.match(JT_VALUE_RE);
|
|
220
262
|
|
|
221
263
|
if (!matcher) {
|
|
@@ -242,23 +284,23 @@ function parseStringValue(value, Types) {
|
|
|
242
284
|
const BaseTypeSet = new Set(['boolean', 'number', 'string', 'date']);
|
|
243
285
|
exports.BaseTypeSet = BaseTypeSet;
|
|
244
286
|
const ConstantTypes = {
|
|
287
|
+
null: {
|
|
288
|
+
title: `{{t("Null", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
289
|
+
value: 'null',
|
|
290
|
+
default: null,
|
|
291
|
+
component: NullRender
|
|
292
|
+
},
|
|
245
293
|
string: {
|
|
246
|
-
title:
|
|
294
|
+
title: `{{t("String", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
247
295
|
value: 'string',
|
|
248
296
|
|
|
249
297
|
component({
|
|
250
298
|
onChange: _onChange,
|
|
251
|
-
type,
|
|
252
|
-
options,
|
|
253
299
|
value
|
|
254
300
|
}) {
|
|
255
301
|
return _react().default.createElement(_antd().Input, {
|
|
256
302
|
value: value,
|
|
257
|
-
onChange: ev => _onChange(
|
|
258
|
-
value: ev.target.value,
|
|
259
|
-
type,
|
|
260
|
-
options
|
|
261
|
-
})
|
|
303
|
+
onChange: ev => _onChange(ev.target.value)
|
|
262
304
|
});
|
|
263
305
|
},
|
|
264
306
|
|
|
@@ -269,31 +311,23 @@ const ConstantTypes = {
|
|
|
269
311
|
value: 'number',
|
|
270
312
|
|
|
271
313
|
component({
|
|
272
|
-
onChange
|
|
273
|
-
type,
|
|
274
|
-
options,
|
|
314
|
+
onChange,
|
|
275
315
|
value
|
|
276
316
|
}) {
|
|
277
317
|
return _react().default.createElement(_antd().InputNumber, {
|
|
278
318
|
value: value,
|
|
279
|
-
onChange:
|
|
280
|
-
value: v,
|
|
281
|
-
type,
|
|
282
|
-
options
|
|
283
|
-
})
|
|
319
|
+
onChange: onChange
|
|
284
320
|
});
|
|
285
321
|
},
|
|
286
322
|
|
|
287
323
|
default: 0
|
|
288
324
|
},
|
|
289
325
|
boolean: {
|
|
290
|
-
title:
|
|
326
|
+
title: `{{t("Boolean", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
291
327
|
value: 'boolean',
|
|
292
328
|
|
|
293
329
|
component({
|
|
294
|
-
onChange
|
|
295
|
-
type,
|
|
296
|
-
options,
|
|
330
|
+
onChange,
|
|
297
331
|
value
|
|
298
332
|
}) {
|
|
299
333
|
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
@@ -301,17 +335,13 @@ const ConstantTypes = {
|
|
|
301
335
|
|
|
302
336
|
return _react().default.createElement(_antd().Select, {
|
|
303
337
|
value: value,
|
|
304
|
-
onChange:
|
|
305
|
-
value: v,
|
|
306
|
-
type,
|
|
307
|
-
options
|
|
308
|
-
}),
|
|
338
|
+
onChange: onChange,
|
|
309
339
|
placeholder: t('Select')
|
|
310
340
|
}, _react().default.createElement(_antd().Select.Option, {
|
|
311
341
|
value: true
|
|
312
|
-
},
|
|
342
|
+
}, (0, _locale.lang)('True')), _react().default.createElement(_antd().Select.Option, {
|
|
313
343
|
value: false
|
|
314
|
-
},
|
|
344
|
+
}, (0, _locale.lang)('False')));
|
|
315
345
|
},
|
|
316
346
|
|
|
317
347
|
default: false
|
|
@@ -327,21 +357,23 @@ const ConstantTypes = {
|
|
|
327
357
|
};
|
|
328
358
|
const VariableTypes = {
|
|
329
359
|
constant: {
|
|
330
|
-
title:
|
|
360
|
+
title: `{{t("Constant", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
331
361
|
value: 'constant',
|
|
332
362
|
options: Object.values(ConstantTypes).map(item => ({
|
|
333
363
|
value: item.value,
|
|
334
364
|
label: item.title
|
|
335
365
|
})),
|
|
336
366
|
|
|
337
|
-
component({
|
|
338
|
-
|
|
367
|
+
component(props) {
|
|
368
|
+
var _ConstantTypes$option;
|
|
369
|
+
|
|
370
|
+
const _useOperandContext = useOperandContext(),
|
|
371
|
+
_useOperandContext$op = _useOperandContext.options,
|
|
372
|
+
options = _useOperandContext$op === void 0 ? {
|
|
339
373
|
type: 'string'
|
|
340
|
-
}
|
|
341
|
-
}) {
|
|
342
|
-
var _ConstantTypes$option, _ConstantTypes$option2;
|
|
374
|
+
} : _useOperandContext$op;
|
|
343
375
|
|
|
344
|
-
return (_ConstantTypes$option =
|
|
376
|
+
return (_ConstantTypes$option = ConstantTypes[options.type]) === null || _ConstantTypes$option === void 0 ? void 0 : _ConstantTypes$option.component(props);
|
|
345
377
|
},
|
|
346
378
|
|
|
347
379
|
appendTypeValue({
|
|
@@ -352,21 +384,9 @@ const VariableTypes = {
|
|
|
352
384
|
return (options === null || options === void 0 ? void 0 : options.type) ? [options.type] : [];
|
|
353
385
|
},
|
|
354
386
|
|
|
355
|
-
onTypeChange(
|
|
356
|
-
var _old$options;
|
|
357
|
-
|
|
358
|
-
if ((old === null || old === void 0 ? void 0 : (_old$options = old.options) === null || _old$options === void 0 ? void 0 : _old$options.type) === optionsType) {
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
|
|
387
|
+
onTypeChange([type, optionsType], onChange) {
|
|
362
388
|
const value = ConstantTypes[optionsType].default;
|
|
363
|
-
onChange(
|
|
364
|
-
value,
|
|
365
|
-
type,
|
|
366
|
-
options: _objectSpread(_objectSpread({}, old.options), {}, {
|
|
367
|
-
type: optionsType
|
|
368
|
-
})
|
|
369
|
-
});
|
|
389
|
+
onChange(value);
|
|
370
390
|
},
|
|
371
391
|
|
|
372
392
|
parse(path) {
|
|
@@ -377,7 +397,7 @@ const VariableTypes = {
|
|
|
377
397
|
|
|
378
398
|
},
|
|
379
399
|
$jobsMapByNodeId: {
|
|
380
|
-
title:
|
|
400
|
+
title: `{{t("Node result", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
381
401
|
value: '$jobsMapByNodeId',
|
|
382
402
|
|
|
383
403
|
options() {
|
|
@@ -402,27 +422,26 @@ const VariableTypes = {
|
|
|
402
422
|
return stack;
|
|
403
423
|
},
|
|
404
424
|
|
|
405
|
-
component({
|
|
406
|
-
options
|
|
407
|
-
}) {
|
|
408
|
-
var _instruction$getter;
|
|
409
|
-
|
|
425
|
+
component(props) {
|
|
410
426
|
const _useFlowContext = (0, _FlowContext.useFlowContext)(),
|
|
411
427
|
nodes = _useFlowContext.nodes;
|
|
412
428
|
|
|
429
|
+
const _useOperandContext2 = useOperandContext(),
|
|
430
|
+
options = _useOperandContext2.options;
|
|
431
|
+
|
|
413
432
|
if (!(options === null || options === void 0 ? void 0 : options.nodeId)) {
|
|
414
|
-
return
|
|
433
|
+
return null;
|
|
415
434
|
}
|
|
416
435
|
|
|
417
436
|
const node = nodes.find(n => n.id == options.nodeId);
|
|
418
437
|
|
|
419
438
|
if (!node) {
|
|
420
|
-
return
|
|
439
|
+
return null;
|
|
421
440
|
}
|
|
422
441
|
|
|
423
442
|
const instruction = _nodes.instructions.get(node.type);
|
|
424
443
|
|
|
425
|
-
return
|
|
444
|
+
return instruction === null || instruction === void 0 ? void 0 : instruction.getter(props);
|
|
426
445
|
},
|
|
427
446
|
|
|
428
447
|
appendTypeValue({
|
|
@@ -431,14 +450,8 @@ const VariableTypes = {
|
|
|
431
450
|
return options.nodeId ? [Number.parseInt(options.nodeId, 10)] : [];
|
|
432
451
|
},
|
|
433
452
|
|
|
434
|
-
onTypeChange(
|
|
435
|
-
onChange({
|
|
436
|
-
// ...old,
|
|
437
|
-
type,
|
|
438
|
-
options: {
|
|
439
|
-
nodeId
|
|
440
|
-
}
|
|
441
|
-
});
|
|
453
|
+
onTypeChange([type, nodeId], onChange) {
|
|
454
|
+
onChange(`{{${type}.${nodeId}}}`);
|
|
442
455
|
},
|
|
443
456
|
|
|
444
457
|
parse([nodeId, ...path]) {
|
|
@@ -448,54 +461,55 @@ const VariableTypes = {
|
|
|
448
461
|
};
|
|
449
462
|
},
|
|
450
463
|
|
|
451
|
-
stringify({
|
|
452
|
-
|
|
453
|
-
}) {
|
|
454
|
-
const stack = ['$jobsMapByNodeId'];
|
|
455
|
-
|
|
456
|
-
if (options.nodeId) {
|
|
457
|
-
stack.push(options.nodeId);
|
|
458
|
-
|
|
459
|
-
if (options.path) {
|
|
460
|
-
stack.push(options.path);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
return `{{${stack.join('.')}}}`;
|
|
464
|
+
stringify(next) {
|
|
465
|
+
return `{{${next.join('.')}}}`;
|
|
465
466
|
}
|
|
466
467
|
|
|
467
468
|
},
|
|
468
469
|
$context: {
|
|
469
|
-
title:
|
|
470
|
+
title: `{{t("Trigger variables", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
470
471
|
value: '$context',
|
|
471
472
|
|
|
472
|
-
|
|
473
|
-
var _trigger$
|
|
473
|
+
options() {
|
|
474
|
+
var _trigger$getOptions, _trigger$getOptions2;
|
|
474
475
|
|
|
475
476
|
const _useFlowContext2 = (0, _FlowContext.useFlowContext)(),
|
|
476
477
|
workflow = _useFlowContext2.workflow;
|
|
477
478
|
|
|
478
479
|
const trigger = _triggers.triggers.get(workflow.type);
|
|
479
480
|
|
|
480
|
-
return (_trigger$
|
|
481
|
+
return (_trigger$getOptions = trigger === null || trigger === void 0 ? void 0 : (_trigger$getOptions2 = trigger.getOptions) === null || _trigger$getOptions2 === void 0 ? void 0 : _trigger$getOptions2.call(trigger, workflow.config)) !== null && _trigger$getOptions !== void 0 ? _trigger$getOptions : null;
|
|
481
482
|
},
|
|
482
483
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
484
|
+
component(props) {
|
|
485
|
+
const _useFlowContext3 = (0, _FlowContext.useFlowContext)(),
|
|
486
|
+
workflow = _useFlowContext3.workflow;
|
|
487
|
+
|
|
488
|
+
const trigger = _triggers.triggers.get(workflow.type);
|
|
489
|
+
|
|
490
|
+
return trigger === null || trigger === void 0 ? void 0 : trigger.getter(props);
|
|
487
491
|
},
|
|
488
492
|
|
|
489
|
-
|
|
493
|
+
appendTypeValue({
|
|
490
494
|
options
|
|
491
495
|
}) {
|
|
492
|
-
|
|
496
|
+
return options.type ? [options.type] : [];
|
|
497
|
+
},
|
|
493
498
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
499
|
+
onTypeChange([type, optionType], onChange) {
|
|
500
|
+
onChange(`{{${type}.${optionType}}}`);
|
|
501
|
+
},
|
|
497
502
|
|
|
498
|
-
|
|
503
|
+
parse([type, ...path]) {
|
|
504
|
+
return _objectSpread({
|
|
505
|
+
type
|
|
506
|
+
}, (path === null || path === void 0 ? void 0 : path.length) ? {
|
|
507
|
+
path: path.join('.')
|
|
508
|
+
} : {});
|
|
509
|
+
},
|
|
510
|
+
|
|
511
|
+
stringify(next) {
|
|
512
|
+
return `{{${next.join('.')}}}`;
|
|
499
513
|
}
|
|
500
514
|
|
|
501
515
|
} // calculation: Calculation
|
|
@@ -503,7 +517,7 @@ const VariableTypes = {
|
|
|
503
517
|
};
|
|
504
518
|
exports.VariableTypes = VariableTypes;
|
|
505
519
|
|
|
506
|
-
const VariableTypesContext = _react().default.createContext(
|
|
520
|
+
const VariableTypesContext = _react().default.createContext({});
|
|
507
521
|
|
|
508
522
|
exports.VariableTypesContext = VariableTypesContext;
|
|
509
523
|
|
|
@@ -511,26 +525,27 @@ function useVariableTypes() {
|
|
|
511
525
|
return _react().default.useContext(VariableTypesContext);
|
|
512
526
|
}
|
|
513
527
|
|
|
528
|
+
const OperandContext = _react().default.createContext(null);
|
|
529
|
+
|
|
530
|
+
function useOperandContext() {
|
|
531
|
+
return _react().default.useContext(OperandContext);
|
|
532
|
+
}
|
|
533
|
+
|
|
514
534
|
function Operand({
|
|
515
|
-
value
|
|
516
|
-
|
|
517
|
-
value: '',
|
|
518
|
-
options: {
|
|
519
|
-
type: 'string'
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
onChange: _onChange4,
|
|
535
|
+
value = null,
|
|
536
|
+
onChange: _onChange2,
|
|
523
537
|
children
|
|
524
538
|
}) {
|
|
525
539
|
const compile = (0, _client().useCompile)();
|
|
526
540
|
const Types = useVariableTypes();
|
|
541
|
+
const operand = parseValue(value, Types);
|
|
527
542
|
const type = operand.type;
|
|
528
543
|
|
|
529
544
|
const _ref = Types[type] || {},
|
|
530
|
-
component = _ref.component,
|
|
545
|
+
_ref$component = _ref.component,
|
|
546
|
+
Variable = _ref$component === void 0 ? NullRender : _ref$component,
|
|
531
547
|
appendTypeValue = _ref.appendTypeValue;
|
|
532
548
|
|
|
533
|
-
const VariableComponent = typeof component === 'function' ? component(operand) : NullRender;
|
|
534
549
|
return _react().default.createElement("div", {
|
|
535
550
|
className: (0, _css().css)`
|
|
536
551
|
display: flex;
|
|
@@ -539,7 +554,7 @@ function Operand({
|
|
|
539
554
|
`
|
|
540
555
|
}, _react().default.createElement(_antd().Cascader, {
|
|
541
556
|
allowClear: false,
|
|
542
|
-
value: [type, ...(appendTypeValue ? appendTypeValue(operand) : [])],
|
|
557
|
+
value: [Types[type] ? type : '', ...(appendTypeValue ? appendTypeValue(operand) : [])],
|
|
543
558
|
options: Object.values(Types).map(item => {
|
|
544
559
|
const options = typeof item.options === 'function' ? item.options() : item.options;
|
|
545
560
|
return {
|
|
@@ -551,31 +566,44 @@ function Operand({
|
|
|
551
566
|
};
|
|
552
567
|
}),
|
|
553
568
|
onChange: next => {
|
|
554
|
-
|
|
569
|
+
// 类型变化,包括主类型和子类型
|
|
570
|
+
const _Types$next$ = Types[next[0]],
|
|
571
|
+
onTypeChange = _Types$next$.onTypeChange,
|
|
572
|
+
stringify = _Types$next$.stringify; // 自定义处理
|
|
555
573
|
|
|
556
574
|
if (typeof onTypeChange === 'function') {
|
|
557
|
-
onTypeChange(
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
575
|
+
return onTypeChange(next, _onChange2);
|
|
576
|
+
} // 主类型变化
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
if (next[0] !== type) {
|
|
580
|
+
if (next[0] === 'constant') {
|
|
581
|
+
return _onChange2(null);
|
|
582
|
+
} else if (stringify) {
|
|
583
|
+
return _onChange2(stringify(next));
|
|
564
584
|
}
|
|
585
|
+
|
|
586
|
+
return _onChange2({
|
|
587
|
+
type: next[0],
|
|
588
|
+
value: null
|
|
589
|
+
});
|
|
565
590
|
}
|
|
566
591
|
}
|
|
567
|
-
}),
|
|
568
|
-
|
|
592
|
+
}), _react().default.createElement(OperandContext.Provider, {
|
|
593
|
+
value: operand
|
|
594
|
+
}, children !== null && children !== void 0 ? children : _react().default.createElement(Variable, {
|
|
595
|
+
value: operand.value,
|
|
596
|
+
onChange: _onChange2
|
|
569
597
|
})));
|
|
570
598
|
}
|
|
571
599
|
|
|
572
600
|
function Calculation({
|
|
573
601
|
calculator,
|
|
574
|
-
operands = [],
|
|
575
|
-
onChange:
|
|
602
|
+
operands = [null],
|
|
603
|
+
onChange: _onChange3
|
|
576
604
|
}) {
|
|
577
|
-
const
|
|
578
|
-
t =
|
|
605
|
+
const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
|
|
606
|
+
t = _useWorkflowTranslati.t;
|
|
579
607
|
|
|
580
608
|
const compile = (0, _client().useCompile)();
|
|
581
609
|
return _react().default.createElement(VariableTypesContext.Provider, {
|
|
@@ -588,18 +616,18 @@ function Calculation({
|
|
|
588
616
|
`
|
|
589
617
|
}, _react().default.createElement(Operand, {
|
|
590
618
|
value: operands[0],
|
|
591
|
-
onChange: v =>
|
|
619
|
+
onChange: v => _onChange3({
|
|
592
620
|
calculator,
|
|
593
621
|
operands: [v, operands[1]]
|
|
594
622
|
})
|
|
595
|
-
}), operands[0] ? _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_antd().Select, {
|
|
623
|
+
}), typeof operands[0] !== 'undefined' ? _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_antd().Select, {
|
|
596
624
|
value: calculator,
|
|
597
|
-
onChange: v =>
|
|
625
|
+
onChange: v => _onChange3({
|
|
598
626
|
operands,
|
|
599
627
|
calculator: v
|
|
600
628
|
}),
|
|
601
629
|
placeholder: t('Calculator')
|
|
602
|
-
}, calculatorGroups.map(group => _react().default.createElement(_antd().Select.OptGroup, {
|
|
630
|
+
}, calculatorGroups.filter(group => Boolean(getGroupCalculators(group.value).length)).map(group => _react().default.createElement(_antd().Select.OptGroup, {
|
|
603
631
|
key: group.value,
|
|
604
632
|
label: compile(group.title)
|
|
605
633
|
}, getGroupCalculators(group.value).map(([value, {
|
|
@@ -609,7 +637,7 @@ function Calculation({
|
|
|
609
637
|
value: value
|
|
610
638
|
}, compile(name)))))), _react().default.createElement(Operand, {
|
|
611
639
|
value: operands[1],
|
|
612
|
-
onChange: v =>
|
|
640
|
+
onChange: v => _onChange3({
|
|
613
641
|
calculator,
|
|
614
642
|
operands: [operands[0], v]
|
|
615
643
|
})
|
|
@@ -618,33 +646,23 @@ function Calculation({
|
|
|
618
646
|
|
|
619
647
|
function VariableComponent({
|
|
620
648
|
value,
|
|
621
|
-
onChange
|
|
649
|
+
onChange,
|
|
622
650
|
renderSchemaComponent
|
|
623
651
|
}) {
|
|
624
652
|
const VTypes = _objectSpread(_objectSpread({}, VariableTypes), {}, {
|
|
625
653
|
constant: {
|
|
626
|
-
title:
|
|
627
|
-
value: 'constant'
|
|
628
|
-
options: undefined
|
|
654
|
+
title: `{{t("Constant", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
655
|
+
value: 'constant'
|
|
629
656
|
}
|
|
630
657
|
});
|
|
631
658
|
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
};
|
|
659
|
+
const _parseValue = parseValue(value, VTypes),
|
|
660
|
+
type = _parseValue.type;
|
|
661
|
+
|
|
636
662
|
return _react().default.createElement(VariableTypesContext.Provider, {
|
|
637
663
|
value: VTypes
|
|
638
664
|
}, _react().default.createElement(Operand, {
|
|
639
|
-
value:
|
|
640
|
-
onChange:
|
|
641
|
-
|
|
642
|
-
_onChange6(null);
|
|
643
|
-
} else {
|
|
644
|
-
const stringify = VTypes[next.type].stringify;
|
|
645
|
-
|
|
646
|
-
_onChange6(stringify(next));
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
}, operand.type === 'constant' ? renderSchemaComponent() : null));
|
|
665
|
+
value: value,
|
|
666
|
+
onChange: onChange
|
|
667
|
+
}, type === 'constant' ? renderSchemaComponent() : null));
|
|
650
668
|
}
|
|
@@ -77,6 +77,8 @@ function _client() {
|
|
|
77
77
|
|
|
78
78
|
var _calculators = require("../calculators");
|
|
79
79
|
|
|
80
|
+
var _locale = require("../locale");
|
|
81
|
+
|
|
80
82
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
81
83
|
|
|
82
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; }
|
|
@@ -167,16 +169,12 @@ var _default = (0, _react2().observer)(({
|
|
|
167
169
|
|
|
168
170
|
const VTypes = _objectSpread(_objectSpread({}, ['linkTo', 'hasMany', 'belongsToMany'].includes(field.type) ? {} : _calculators.VariableTypes), {}, {
|
|
169
171
|
constant: {
|
|
170
|
-
title:
|
|
171
|
-
value: 'constant'
|
|
172
|
-
options: undefined
|
|
172
|
+
title: `{{t("Constant", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
173
|
+
value: 'constant'
|
|
173
174
|
}
|
|
174
175
|
});
|
|
175
176
|
|
|
176
|
-
const operand =
|
|
177
|
-
type: 'constant',
|
|
178
|
-
value: value[field.name]
|
|
179
|
-
}; // constant for associations to use Input, others to use CollectionField
|
|
177
|
+
const operand = (0, _calculators.parseValue)(value[field.name], VTypes); // constant for associations to use Input, others to use CollectionField
|
|
180
178
|
// dynamic values only support belongsTo/hasOne association, other association type should disable
|
|
181
179
|
// TODO: try to use <ObjectField> to replace this map
|
|
182
180
|
|
|
@@ -192,19 +190,11 @@ var _default = (0, _react2().observer)(({
|
|
|
192
190
|
}, _react().default.createElement(_calculators.VariableTypesContext.Provider, {
|
|
193
191
|
value: VTypes
|
|
194
192
|
}, _react().default.createElement(_calculators.Operand, {
|
|
195
|
-
value:
|
|
193
|
+
value: value[field.name],
|
|
196
194
|
onChange: next => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}));
|
|
201
|
-
} else {
|
|
202
|
-
const stringify = VTypes[next.type].stringify;
|
|
203
|
-
|
|
204
|
-
_onChange(_objectSpread(_objectSpread({}, value), {}, {
|
|
205
|
-
[field.name]: stringify(next)
|
|
206
|
-
}));
|
|
207
|
-
}
|
|
195
|
+
_onChange(_objectSpread(_objectSpread({}, value), {}, {
|
|
196
|
+
[field.name]: next
|
|
197
|
+
}));
|
|
208
198
|
}
|
|
209
199
|
}, operand.type === 'constant' ? _react().default.createElement(_client().SchemaComponent, {
|
|
210
200
|
schema: {
|
|
@@ -251,7 +241,7 @@ var _default = (0, _react2().observer)(({
|
|
|
251
241
|
}))
|
|
252
242
|
}, _react().default.createElement(_antd().Button, {
|
|
253
243
|
icon: _react().default.createElement(_icons().PlusOutlined, null)
|
|
254
|
-
}, t('Add field'))) : null) : _react().default.createElement("p", null,
|
|
244
|
+
}, t('Add field'))) : null) : _react().default.createElement("p", null, (0, _locale.lang)('Please select collection first')));
|
|
255
245
|
});
|
|
256
246
|
|
|
257
247
|
exports.default = _default;
|
|
@@ -25,16 +25,6 @@ function _antd() {
|
|
|
25
25
|
return data;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function _reactI18next() {
|
|
29
|
-
const data = require("react-i18next");
|
|
30
|
-
|
|
31
|
-
_reactI18next = function _reactI18next() {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
28
|
function _css() {
|
|
39
29
|
const data = require("@emotion/css");
|
|
40
30
|
|
|
@@ -45,6 +35,8 @@ function _css() {
|
|
|
45
35
|
return data;
|
|
46
36
|
}
|
|
47
37
|
|
|
38
|
+
var _locale = require("../locale");
|
|
39
|
+
|
|
48
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
49
41
|
|
|
50
42
|
const UnitOptions = [{
|
|
@@ -72,9 +64,6 @@ function _default({
|
|
|
72
64
|
value = 60000,
|
|
73
65
|
onChange: _onChange
|
|
74
66
|
}) {
|
|
75
|
-
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
76
|
-
t = _useTranslation.t;
|
|
77
|
-
|
|
78
67
|
const option = getNumberOption(value);
|
|
79
68
|
const quantity = Math.round(value / option.value);
|
|
80
69
|
return _react().default.createElement("fieldset", {
|
|
@@ -92,5 +81,5 @@ function _default({
|
|
|
92
81
|
}, UnitOptions.map(item => _react().default.createElement(_antd().Select.Option, {
|
|
93
82
|
key: item.value,
|
|
94
83
|
value: item.value
|
|
95
|
-
},
|
|
84
|
+
}, (0, _locale.lang)(item.label)))));
|
|
96
85
|
}
|