fix(plugin-workflow): fix loop variable (#2211)
This commit is contained in:
parent
687f3c214d
commit
6b220c342c
@ -36,13 +36,13 @@ const DynamicConfig = ({ value, onChange }) => {
|
||||
<FormLayout layout="vertical">
|
||||
<FormItem colon label={t('Expression type', { ns: NAMESPACE })}>
|
||||
<Radio.Group
|
||||
value={value === false ? false : value || null}
|
||||
value={value === false ? false : value || ''}
|
||||
onChange={(ev) => {
|
||||
onChange(ev.target.value);
|
||||
}}
|
||||
>
|
||||
<Radio value={false}>{t('Static', { ns: NAMESPACE })}</Radio>
|
||||
<Radio value={value || null}>{t('Dynamic', { ns: NAMESPACE })}</Radio>
|
||||
<Radio value={value || ''}>{t('Dynamic', { ns: NAMESPACE })}</Radio>
|
||||
</Radio.Group>
|
||||
</FormItem>
|
||||
{value !== false ? (
|
||||
@ -53,7 +53,7 @@ const DynamicConfig = ({ value, onChange }) => {
|
||||
{ ns: NAMESPACE },
|
||||
)}
|
||||
>
|
||||
<Variable.Input value={value || null} onChange={(v) => onChange(v)} scope={scope} />
|
||||
<Variable.Input value={value || ''} onChange={(v) => onChange(v)} scope={scope} />
|
||||
</FormItem>
|
||||
) : null}
|
||||
</FormLayout>
|
||||
|
@ -9,18 +9,20 @@ import { addButtonClass, branchBlockClass, branchClass, nodeSubtreeClass } from
|
||||
import { nodesOptions, triggerOptions, useWorkflowVariableOptions, VariableOption } from '../variable';
|
||||
|
||||
function findOption(options: VariableOption[], paths: string[]) {
|
||||
let current = options;
|
||||
let opts = options;
|
||||
let option = null;
|
||||
for (let i = 0; i < paths.length; i++) {
|
||||
const path = paths[i];
|
||||
const option = current.find((item) => item.value === path);
|
||||
if (!option) {
|
||||
return null;
|
||||
const current = opts.find((item) => item.value === path);
|
||||
if (!current) {
|
||||
break;
|
||||
}
|
||||
if (option.children) {
|
||||
current = option.children;
|
||||
option = current;
|
||||
if (current.children) {
|
||||
opts = current.children;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
return option;
|
||||
}
|
||||
|
||||
export default {
|
||||
@ -124,7 +126,7 @@ export default {
|
||||
// find target data model by path described in `config.target`
|
||||
// 1. get options from $context/$jobsMapByNodeId
|
||||
// 2. route to sub-options and use as loop target options
|
||||
const targetOption: VariableOption = { key: 'item', value: 'item', label: lang('Loop target') };
|
||||
let targetOption: VariableOption = { key: 'item', value: 'item', label: lang('Loop target') };
|
||||
|
||||
if (typeof target === 'string' && target.startsWith('{{') && target.endsWith('}}')) {
|
||||
const paths = target
|
||||
@ -133,17 +135,19 @@ export default {
|
||||
.map((path) => path.trim());
|
||||
|
||||
const targetOptions = [nodesOptions, triggerOptions].map((item: any) => {
|
||||
const opts = typeof item.useOptions === 'function' ? item.useOptions(options).filter(Boolean) : null;
|
||||
const opts = item.useOptions(options).filter(Boolean);
|
||||
return {
|
||||
label: compile(item.title),
|
||||
value: item.value,
|
||||
key: item.value,
|
||||
children: compile(opts),
|
||||
children: opts,
|
||||
disabled: opts && !opts.length,
|
||||
};
|
||||
});
|
||||
|
||||
targetOption.children = findOption(targetOptions, paths);
|
||||
const found = findOption(targetOptions, paths);
|
||||
|
||||
targetOption = Object.assign({ ...targetOption }, found, targetOption);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import { onFieldInputValueChange } from '@formily/core';
|
||||
import { useForm, useField } from '@formily/react';
|
||||
|
||||
import { useCollectionDataSource } from '@nocobase/client';
|
||||
@ -8,7 +7,7 @@ import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
|
||||
import CollectionFieldset, { useCollectionUIFields } from '../components/CollectionFieldset';
|
||||
|
||||
import { isValidFilter } from '../utils';
|
||||
import { NAMESPACE } from '../locale';
|
||||
import { NAMESPACE, lang } from '../locale';
|
||||
import { collection, filter, values } from '../schemas/collection';
|
||||
import { RadioWithTooltip } from '../components/RadioWithTooltip';
|
||||
|
||||
@ -74,7 +73,7 @@ export default {
|
||||
...filter,
|
||||
title: `{{t("Only update records matching conditions", { ns: "${NAMESPACE}" })}}`,
|
||||
['x-validator'](value) {
|
||||
return isValidFilter(value) ? '' : `{{t("Please add at least one condition", { ns: "${NAMESPACE}" })}}`;
|
||||
return isValidFilter(value) ? '' : lang('Please add at least one condition');
|
||||
},
|
||||
},
|
||||
values: {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useCollectionManager, useCompile } from '@nocobase/client';
|
||||
import { useCompile } from '@nocobase/client';
|
||||
import { useFlowContext } from './FlowContext';
|
||||
import { NAMESPACE, lang } from './locale';
|
||||
import { instructions, useAvailableUpstreams, useNodeContext, useUpstreamScopes } from './nodes';
|
||||
@ -84,7 +84,7 @@ export const systemOptions = {
|
||||
|
||||
export const BaseTypeSets = {
|
||||
boolean: new Set(['checkbox']),
|
||||
number: new Set(['number', 'percent']),
|
||||
number: new Set(['integer', 'number', 'percent']),
|
||||
string: new Set([
|
||||
'input',
|
||||
'password',
|
||||
|
Loading…
Reference in New Issue
Block a user