balibabu
commited on
Commit
·
7a57a76
1
Parent(s):
18e87af
Feat: Make the category operator form displayed in collapsed mode by default #4505 (#4510)
Browse files### What problem does this PR solve?
Feat: Make the category operator form displayed in collapsed mode by
default #4505
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/pages/flow/form/categorize-form/dynamic-categorize.tsx
CHANGED
@@ -3,7 +3,7 @@ import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
|
|
3 |
import { useUpdateNodeInternals } from '@xyflow/react';
|
4 |
import {
|
5 |
Button,
|
6 |
-
|
7 |
Flex,
|
8 |
Form,
|
9 |
FormListFieldData,
|
@@ -97,13 +97,65 @@ const NameInput = ({
|
|
97 |
);
|
98 |
};
|
99 |
|
100 |
-
const
|
101 |
-
const updateNodeInternals = useUpdateNodeInternals();
|
102 |
const form = Form.useFormInstance();
|
|
|
103 |
const buildCategorizeToOptions = useBuildFormSelectOptions(
|
104 |
Operator.Categorize,
|
105 |
nodeId,
|
106 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
const { t } = useTranslate('flow');
|
108 |
|
109 |
return (
|
@@ -122,74 +174,35 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
|
|
122 |
});
|
123 |
if (nodeId) updateNodeInternals(nodeId);
|
124 |
};
|
|
|
125 |
return (
|
126 |
<Flex gap={18} vertical>
|
127 |
{fields.map((field) => (
|
128 |
-
<
|
129 |
size="small"
|
130 |
key={field.key}
|
131 |
className={styles.caseCard}
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
otherNames={getOtherFieldValues(
|
154 |
-
form,
|
155 |
-
'items',
|
156 |
-
field,
|
157 |
-
'name',
|
158 |
-
)}
|
159 |
-
validate={(errors: string[]) =>
|
160 |
-
form.setFields([
|
161 |
-
{
|
162 |
-
name: ['items', field.name, 'name'],
|
163 |
-
errors,
|
164 |
-
},
|
165 |
-
])
|
166 |
-
}
|
167 |
-
></NameInput>
|
168 |
-
</Form.Item>
|
169 |
-
<Form.Item
|
170 |
-
label={t('description')}
|
171 |
-
name={[field.name, 'description']}
|
172 |
-
>
|
173 |
-
<Input.TextArea rows={3} />
|
174 |
-
</Form.Item>
|
175 |
-
<Form.Item
|
176 |
-
label={t('examples')}
|
177 |
-
name={[field.name, 'examples']}
|
178 |
-
>
|
179 |
-
<Input.TextArea rows={3} />
|
180 |
-
</Form.Item>
|
181 |
-
<Form.Item label={t('nextStep')} name={[field.name, 'to']}>
|
182 |
-
<Select
|
183 |
-
allowClear
|
184 |
-
options={buildCategorizeToOptions(
|
185 |
-
getOtherFieldValues(form, 'items', field, 'to'),
|
186 |
-
)}
|
187 |
-
/>
|
188 |
-
</Form.Item>
|
189 |
-
<Form.Item hidden name={[field.name, 'index']}>
|
190 |
-
<Input />
|
191 |
-
</Form.Item>
|
192 |
-
</Card>
|
193 |
))}
|
194 |
|
195 |
<Button
|
|
|
3 |
import { useUpdateNodeInternals } from '@xyflow/react';
|
4 |
import {
|
5 |
Button,
|
6 |
+
Collapse,
|
7 |
Flex,
|
8 |
Form,
|
9 |
FormListFieldData,
|
|
|
97 |
);
|
98 |
};
|
99 |
|
100 |
+
const FormSet = ({ nodeId, field }: IProps & { field: FormListFieldData }) => {
|
|
|
101 |
const form = Form.useFormInstance();
|
102 |
+
const { t } = useTranslate('flow');
|
103 |
const buildCategorizeToOptions = useBuildFormSelectOptions(
|
104 |
Operator.Categorize,
|
105 |
nodeId,
|
106 |
);
|
107 |
+
|
108 |
+
return (
|
109 |
+
<section>
|
110 |
+
<Form.Item
|
111 |
+
label={t('categoryName')}
|
112 |
+
name={[field.name, 'name']}
|
113 |
+
validateTrigger={['onChange', 'onBlur']}
|
114 |
+
rules={[
|
115 |
+
{
|
116 |
+
required: true,
|
117 |
+
whitespace: true,
|
118 |
+
message: t('nameMessage'),
|
119 |
+
},
|
120 |
+
]}
|
121 |
+
>
|
122 |
+
<NameInput
|
123 |
+
otherNames={getOtherFieldValues(form, 'items', field, 'name')}
|
124 |
+
validate={(errors: string[]) =>
|
125 |
+
form.setFields([
|
126 |
+
{
|
127 |
+
name: ['items', field.name, 'name'],
|
128 |
+
errors,
|
129 |
+
},
|
130 |
+
])
|
131 |
+
}
|
132 |
+
></NameInput>
|
133 |
+
</Form.Item>
|
134 |
+
<Form.Item label={t('description')} name={[field.name, 'description']}>
|
135 |
+
<Input.TextArea rows={3} />
|
136 |
+
</Form.Item>
|
137 |
+
<Form.Item label={t('examples')} name={[field.name, 'examples']}>
|
138 |
+
<Input.TextArea rows={3} />
|
139 |
+
</Form.Item>
|
140 |
+
<Form.Item label={t('nextStep')} name={[field.name, 'to']}>
|
141 |
+
<Select
|
142 |
+
allowClear
|
143 |
+
options={buildCategorizeToOptions(
|
144 |
+
getOtherFieldValues(form, 'items', field, 'to'),
|
145 |
+
)}
|
146 |
+
/>
|
147 |
+
</Form.Item>
|
148 |
+
<Form.Item hidden name={[field.name, 'index']}>
|
149 |
+
<Input />
|
150 |
+
</Form.Item>
|
151 |
+
</section>
|
152 |
+
);
|
153 |
+
};
|
154 |
+
|
155 |
+
const DynamicCategorize = ({ nodeId }: IProps) => {
|
156 |
+
const updateNodeInternals = useUpdateNodeInternals();
|
157 |
+
const form = Form.useFormInstance();
|
158 |
+
|
159 |
const { t } = useTranslate('flow');
|
160 |
|
161 |
return (
|
|
|
174 |
});
|
175 |
if (nodeId) updateNodeInternals(nodeId);
|
176 |
};
|
177 |
+
|
178 |
return (
|
179 |
<Flex gap={18} vertical>
|
180 |
{fields.map((field) => (
|
181 |
+
<Collapse
|
182 |
size="small"
|
183 |
key={field.key}
|
184 |
className={styles.caseCard}
|
185 |
+
items={[
|
186 |
+
{
|
187 |
+
key: field.key,
|
188 |
+
label: (
|
189 |
+
<div className="flex justify-between">
|
190 |
+
<span>
|
191 |
+
{form.getFieldValue(['items', field.name, 'name'])}
|
192 |
+
</span>
|
193 |
+
<CloseOutlined
|
194 |
+
onClick={() => {
|
195 |
+
remove(field.name);
|
196 |
+
}}
|
197 |
+
/>
|
198 |
+
</div>
|
199 |
+
),
|
200 |
+
children: (
|
201 |
+
<FormSet nodeId={nodeId} field={field}></FormSet>
|
202 |
+
),
|
203 |
+
},
|
204 |
+
]}
|
205 |
+
></Collapse>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
))}
|
207 |
|
208 |
<Button
|
web/src/pages/flow/form/categorize-form/index.less
CHANGED
@@ -2,7 +2,9 @@
|
|
2 |
@darkBackgroundColor: rgba(150, 150, 150, 0.12);
|
3 |
|
4 |
.caseCard {
|
5 |
-
|
|
|
|
|
6 |
}
|
7 |
|
8 |
.addButton {
|
|
|
2 |
@darkBackgroundColor: rgba(150, 150, 150, 0.12);
|
3 |
|
4 |
.caseCard {
|
5 |
+
:global(.ant-collapse-content) {
|
6 |
+
background-color: @darkBackgroundColor;
|
7 |
+
}
|
8 |
}
|
9 |
|
10 |
.addButton {
|