balibabu
commited on
Commit
·
6b7630c
1
Parent(s):
2cbcd9d
feat: Add SwitchOperatorOptions to Select of Switch #1739 (#2033)
Browse files### 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)
- web/.umirc.ts +1 -1
- web/src/locales/en.ts +18 -0
- web/src/locales/zh-traditional.ts +18 -0
- web/src/locales/zh.ts +18 -0
- web/src/pages/flow/constant.tsx +17 -0
- web/src/pages/flow/exesql-form/index.tsx +1 -1
- web/src/pages/flow/switch-form/index.tsx +37 -8
web/.umirc.ts
CHANGED
@@ -30,7 +30,7 @@ export default defineConfig({
|
|
30 |
copy: ['src/conf.json'],
|
31 |
proxy: {
|
32 |
'/v1': {
|
33 |
-
target: 'http://
|
34 |
changeOrigin: true,
|
35 |
ws: true,
|
36 |
logger: console,
|
|
|
30 |
copy: ['src/conf.json'],
|
31 |
proxy: {
|
32 |
'/v1': {
|
33 |
+
target: 'http://123.60.95.134:9380/',
|
34 |
changeOrigin: true,
|
35 |
ws: true,
|
36 |
logger: console,
|
web/src/locales/en.ts
CHANGED
@@ -815,6 +815,24 @@ The above is the content you need to summarize.`,
|
|
815 |
password: 'Password',
|
816 |
switch: 'Switch',
|
817 |
logicalOperator: 'Logical operator',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
818 |
},
|
819 |
footer: {
|
820 |
profile: 'All rights reserved @ React',
|
|
|
815 |
password: 'Password',
|
816 |
switch: 'Switch',
|
817 |
logicalOperator: 'Logical operator',
|
818 |
+
switchOperatorOptions: {
|
819 |
+
equal: 'equal',
|
820 |
+
notEqual: 'notEqual',
|
821 |
+
gt: 'Greater than',
|
822 |
+
ge: 'Greater equal',
|
823 |
+
lt: 'Less than',
|
824 |
+
le: 'Less equal',
|
825 |
+
contains: 'Contains',
|
826 |
+
notContains: 'Not contains',
|
827 |
+
startWith: 'Start with',
|
828 |
+
endWith: 'End with',
|
829 |
+
empty: 'Empty',
|
830 |
+
notEmpty: 'Not empty',
|
831 |
+
},
|
832 |
+
switchLogicOperatorOptions: {
|
833 |
+
and: 'And',
|
834 |
+
or: 'Or',
|
835 |
+
},
|
836 |
},
|
837 |
footer: {
|
838 |
profile: 'All rights reserved @ React',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -773,6 +773,24 @@ export default {
|
|
773 |
password: '密碼',
|
774 |
switch: '條件',
|
775 |
logicalOperator: '操作符',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
776 |
},
|
777 |
footer: {
|
778 |
profile: '“保留所有權利 @ react”',
|
|
|
773 |
password: '密碼',
|
774 |
switch: '條件',
|
775 |
logicalOperator: '操作符',
|
776 |
+
switchOperatorOptions: {
|
777 |
+
equal: '等於',
|
778 |
+
notEqual: '不等於',
|
779 |
+
gt: '大於',
|
780 |
+
ge: '大於等於',
|
781 |
+
lt: '小於',
|
782 |
+
le: '小於等於',
|
783 |
+
contains: '包含',
|
784 |
+
notContains: '不包含',
|
785 |
+
startWith: '開始是',
|
786 |
+
endWith: '結束是',
|
787 |
+
empty: '為空',
|
788 |
+
notEmpty: '不為空',
|
789 |
+
},
|
790 |
+
switchLogicOperatorOptions: {
|
791 |
+
and: '與',
|
792 |
+
or: '或',
|
793 |
+
},
|
794 |
},
|
795 |
footer: {
|
796 |
profile: '“保留所有權利 @ react”',
|
web/src/locales/zh.ts
CHANGED
@@ -791,6 +791,24 @@ export default {
|
|
791 |
password: '密码',
|
792 |
switch: '条件',
|
793 |
logicalOperator: '操作符',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
794 |
},
|
795 |
footer: {
|
796 |
profile: 'All rights reserved @ React',
|
|
|
791 |
password: '密码',
|
792 |
switch: '条件',
|
793 |
logicalOperator: '操作符',
|
794 |
+
switchOperatorOptions: {
|
795 |
+
equal: '等于',
|
796 |
+
notEqual: '不等于',
|
797 |
+
gt: '大于',
|
798 |
+
ge: '大于等于',
|
799 |
+
lt: '小于',
|
800 |
+
le: '小于等于',
|
801 |
+
contains: '包含',
|
802 |
+
notContains: '不包含',
|
803 |
+
startWith: '开始是',
|
804 |
+
endWith: '结束是',
|
805 |
+
empty: '为空',
|
806 |
+
notEmpty: '不为空',
|
807 |
+
},
|
808 |
+
switchLogicOperatorOptions: {
|
809 |
+
and: '与',
|
810 |
+
or: '或',
|
811 |
+
},
|
812 |
},
|
813 |
footer: {
|
814 |
profile: 'All rights reserved @ React',
|
web/src/pages/flow/constant.tsx
CHANGED
@@ -2635,3 +2635,20 @@ export const ExeSQLOptions = ['mysql', 'postgresql', 'mariadb'].map((x) => ({
|
|
2635 |
}));
|
2636 |
|
2637 |
export const SwitchElseTo = 'end_cpn_id';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2635 |
}));
|
2636 |
|
2637 |
export const SwitchElseTo = 'end_cpn_id';
|
2638 |
+
|
2639 |
+
export const SwitchOperatorOptions = [
|
2640 |
+
{ value: '=', label: 'equal' },
|
2641 |
+
{ value: '≠', label: 'notEqual' },
|
2642 |
+
{ value: '>', label: 'gt' },
|
2643 |
+
{ value: '≥', label: 'ge' },
|
2644 |
+
{ value: '<', label: 'lt' },
|
2645 |
+
{ value: '≤', label: 'le' },
|
2646 |
+
{ value: 'contains', label: 'contains' },
|
2647 |
+
{ value: 'not contains', label: 'notContains' },
|
2648 |
+
{ value: 'start with', label: 'startWith' },
|
2649 |
+
{ value: 'end with', label: 'endWith' },
|
2650 |
+
{ value: 'empty', label: 'empty' },
|
2651 |
+
{ value: 'not empty', label: 'notEmpty' },
|
2652 |
+
];
|
2653 |
+
|
2654 |
+
export const SwitchLogicOperatorOptions = ['and', 'or'];
|
web/src/pages/flow/exesql-form/index.tsx
CHANGED
@@ -58,7 +58,7 @@ const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => {
|
|
58 |
>
|
59 |
<InputNumber></InputNumber>
|
60 |
</Form.Item>
|
61 |
-
<TopNItem initialValue={30} max={
|
62 |
</Form>
|
63 |
);
|
64 |
};
|
|
|
58 |
>
|
59 |
<InputNumber></InputNumber>
|
60 |
</Form.Item>
|
61 |
+
<TopNItem initialValue={30} max={1000}></TopNItem>
|
62 |
</Form>
|
63 |
);
|
64 |
};
|
web/src/pages/flow/switch-form/index.tsx
CHANGED
@@ -1,7 +1,13 @@
|
|
1 |
import { CloseOutlined } from '@ant-design/icons';
|
2 |
import { Button, Card, Form, Input, Select, Typography } from 'antd';
|
|
|
3 |
import { useTranslation } from 'react-i18next';
|
4 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
5 |
import { useBuildFormSelectOptions } from '../form-hooks';
|
6 |
import { IOperatorForm, ISwitchForm } from '../interface';
|
7 |
import { getOtherFieldValues } from '../utils';
|
@@ -28,6 +34,20 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
|
|
28 |
return conditions?.filter((x) => !!x).map((x) => x?.to) ?? [];
|
29 |
};
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return (
|
32 |
<Form
|
33 |
labelCol={{ span: 8 }}
|
@@ -60,13 +80,19 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
|
|
60 |
/>
|
61 |
}
|
62 |
>
|
63 |
-
<Form.Item
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
</Form.Item>
|
69 |
-
|
70 |
<Form.Item label={t('flow.to')} name={[field.name, 'to']}>
|
71 |
<Select
|
72 |
allowClear
|
@@ -113,7 +139,10 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
|
|
113 |
labelCol={subLabelCol}
|
114 |
wrapperCol={subWrapperCol}
|
115 |
>
|
116 |
-
<
|
|
|
|
|
|
|
117 |
</Form.Item>
|
118 |
<Form.Item
|
119 |
label={'value'}
|
|
|
1 |
import { CloseOutlined } from '@ant-design/icons';
|
2 |
import { Button, Card, Form, Input, Select, Typography } from 'antd';
|
3 |
+
import { useMemo } from 'react';
|
4 |
import { useTranslation } from 'react-i18next';
|
5 |
+
import {
|
6 |
+
Operator,
|
7 |
+
SwitchElseTo,
|
8 |
+
SwitchLogicOperatorOptions,
|
9 |
+
SwitchOperatorOptions,
|
10 |
+
} from '../constant';
|
11 |
import { useBuildFormSelectOptions } from '../form-hooks';
|
12 |
import { IOperatorForm, ISwitchForm } from '../interface';
|
13 |
import { getOtherFieldValues } from '../utils';
|
|
|
34 |
return conditions?.filter((x) => !!x).map((x) => x?.to) ?? [];
|
35 |
};
|
36 |
|
37 |
+
const switchOperatorOptions = useMemo(() => {
|
38 |
+
return SwitchOperatorOptions.map((x) => ({
|
39 |
+
value: x.value,
|
40 |
+
label: t(`flow.switchOperatorOptions.${x.label}`),
|
41 |
+
}));
|
42 |
+
}, [t]);
|
43 |
+
|
44 |
+
const switchLogicOperatorOptions = useMemo(() => {
|
45 |
+
return SwitchLogicOperatorOptions.map((x) => ({
|
46 |
+
value: x,
|
47 |
+
label: t(`flow.switchLogicOperatorOptions.${x}`),
|
48 |
+
}));
|
49 |
+
}, [t]);
|
50 |
+
|
51 |
return (
|
52 |
<Form
|
53 |
labelCol={{ span: 8 }}
|
|
|
80 |
/>
|
81 |
}
|
82 |
>
|
83 |
+
<Form.Item noStyle dependencies={[field.name, 'items']}>
|
84 |
+
{({ getFieldValue }) =>
|
85 |
+
getFieldValue(['conditions', field.name, 'items'])?.length >
|
86 |
+
1 && (
|
87 |
+
<Form.Item
|
88 |
+
label={t('flow.logicalOperator')}
|
89 |
+
name={[field.name, 'logical_operator']}
|
90 |
+
>
|
91 |
+
<Select options={switchLogicOperatorOptions} />
|
92 |
+
</Form.Item>
|
93 |
+
)
|
94 |
+
}
|
95 |
</Form.Item>
|
|
|
96 |
<Form.Item label={t('flow.to')} name={[field.name, 'to']}>
|
97 |
<Select
|
98 |
allowClear
|
|
|
139 |
labelCol={subLabelCol}
|
140 |
wrapperCol={subWrapperCol}
|
141 |
>
|
142 |
+
<Select
|
143 |
+
placeholder="operator"
|
144 |
+
options={switchOperatorOptions}
|
145 |
+
/>
|
146 |
</Form.Item>
|
147 |
<Form.Item
|
148 |
label={'value'}
|