### What problem does this PR solve? feat: Add SwitchOperatorOptions to Select of Switch #1739 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -2635,3 +2635,20 @@ export const ExeSQLOptions = ['mysql', 'postgresql', 'mariadb'].map((x) => ({
|
||||
}));
|
||||
|
||||
export const SwitchElseTo = 'end_cpn_id';
|
||||
|
||||
export const SwitchOperatorOptions = [
|
||||
{ value: '=', label: 'equal' },
|
||||
{ value: '≠', label: 'notEqual' },
|
||||
{ value: '>', label: 'gt' },
|
||||
{ value: '≥', label: 'ge' },
|
||||
{ value: '<', label: 'lt' },
|
||||
{ value: '≤', label: 'le' },
|
||||
{ value: 'contains', label: 'contains' },
|
||||
{ value: 'not contains', label: 'notContains' },
|
||||
{ value: 'start with', label: 'startWith' },
|
||||
{ value: 'end with', label: 'endWith' },
|
||||
{ value: 'empty', label: 'empty' },
|
||||
{ value: 'not empty', label: 'notEmpty' },
|
||||
];
|
||||
|
||||
export const SwitchLogicOperatorOptions = ['and', 'or'];
|
||||
|
||||
@@ -58,7 +58,7 @@ const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => {
|
||||
>
|
||||
<InputNumber></InputNumber>
|
||||
</Form.Item>
|
||||
<TopNItem initialValue={30} max={100000}></TopNItem>
|
||||
<TopNItem initialValue={30} max={1000}></TopNItem>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { CloseOutlined } from '@ant-design/icons';
|
||||
import { Button, Card, Form, Input, Select, Typography } from 'antd';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Operator, SwitchElseTo } from '../constant';
|
||||
import {
|
||||
Operator,
|
||||
SwitchElseTo,
|
||||
SwitchLogicOperatorOptions,
|
||||
SwitchOperatorOptions,
|
||||
} from '../constant';
|
||||
import { useBuildFormSelectOptions } from '../form-hooks';
|
||||
import { IOperatorForm, ISwitchForm } from '../interface';
|
||||
import { getOtherFieldValues } from '../utils';
|
||||
@@ -28,6 +34,20 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
|
||||
return conditions?.filter((x) => !!x).map((x) => x?.to) ?? [];
|
||||
};
|
||||
|
||||
const switchOperatorOptions = useMemo(() => {
|
||||
return SwitchOperatorOptions.map((x) => ({
|
||||
value: x.value,
|
||||
label: t(`flow.switchOperatorOptions.${x.label}`),
|
||||
}));
|
||||
}, [t]);
|
||||
|
||||
const switchLogicOperatorOptions = useMemo(() => {
|
||||
return SwitchLogicOperatorOptions.map((x) => ({
|
||||
value: x,
|
||||
label: t(`flow.switchLogicOperatorOptions.${x}`),
|
||||
}));
|
||||
}, [t]);
|
||||
|
||||
return (
|
||||
<Form
|
||||
labelCol={{ span: 8 }}
|
||||
@@ -60,13 +80,19 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Form.Item
|
||||
label={t('flow.logicalOperator')}
|
||||
name={[field.name, 'logical_operator']}
|
||||
>
|
||||
<Input />
|
||||
<Form.Item noStyle dependencies={[field.name, 'items']}>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue(['conditions', field.name, 'items'])?.length >
|
||||
1 && (
|
||||
<Form.Item
|
||||
label={t('flow.logicalOperator')}
|
||||
name={[field.name, 'logical_operator']}
|
||||
>
|
||||
<Select options={switchLogicOperatorOptions} />
|
||||
</Form.Item>
|
||||
)
|
||||
}
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label={t('flow.to')} name={[field.name, 'to']}>
|
||||
<Select
|
||||
allowClear
|
||||
@@ -113,7 +139,10 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
|
||||
labelCol={subLabelCol}
|
||||
wrapperCol={subWrapperCol}
|
||||
>
|
||||
<Input placeholder="operator" />
|
||||
<Select
|
||||
placeholder="operator"
|
||||
options={switchOperatorOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={'value'}
|
||||
|
||||
Reference in New Issue
Block a user