mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 07:29:05 +08:00
### 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)
This commit is contained in:
parent
37235315e1
commit
4946e43941
@ -3,7 +3,7 @@ import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { useUpdateNodeInternals } from '@xyflow/react';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Collapse,
|
||||
Flex,
|
||||
Form,
|
||||
FormListFieldData,
|
||||
@ -97,13 +97,65 @@ const NameInput = ({
|
||||
);
|
||||
};
|
||||
|
||||
const DynamicCategorize = ({ nodeId }: IProps) => {
|
||||
const updateNodeInternals = useUpdateNodeInternals();
|
||||
const FormSet = ({ nodeId, field }: IProps & { field: FormListFieldData }) => {
|
||||
const form = Form.useFormInstance();
|
||||
const { t } = useTranslate('flow');
|
||||
const buildCategorizeToOptions = useBuildFormSelectOptions(
|
||||
Operator.Categorize,
|
||||
nodeId,
|
||||
);
|
||||
|
||||
return (
|
||||
<section>
|
||||
<Form.Item
|
||||
label={t('categoryName')}
|
||||
name={[field.name, 'name']}
|
||||
validateTrigger={['onChange', 'onBlur']}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
whitespace: true,
|
||||
message: t('nameMessage'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<NameInput
|
||||
otherNames={getOtherFieldValues(form, 'items', field, 'name')}
|
||||
validate={(errors: string[]) =>
|
||||
form.setFields([
|
||||
{
|
||||
name: ['items', field.name, 'name'],
|
||||
errors,
|
||||
},
|
||||
])
|
||||
}
|
||||
></NameInput>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('description')} name={[field.name, 'description']}>
|
||||
<Input.TextArea rows={3} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('examples')} name={[field.name, 'examples']}>
|
||||
<Input.TextArea rows={3} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('nextStep')} name={[field.name, 'to']}>
|
||||
<Select
|
||||
allowClear
|
||||
options={buildCategorizeToOptions(
|
||||
getOtherFieldValues(form, 'items', field, 'to'),
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item hidden name={[field.name, 'index']}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
const DynamicCategorize = ({ nodeId }: IProps) => {
|
||||
const updateNodeInternals = useUpdateNodeInternals();
|
||||
const form = Form.useFormInstance();
|
||||
|
||||
const { t } = useTranslate('flow');
|
||||
|
||||
return (
|
||||
@ -122,74 +174,35 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
|
||||
});
|
||||
if (nodeId) updateNodeInternals(nodeId);
|
||||
};
|
||||
|
||||
return (
|
||||
<Flex gap={18} vertical>
|
||||
{fields.map((field) => (
|
||||
<Card
|
||||
<Collapse
|
||||
size="small"
|
||||
key={field.key}
|
||||
className={styles.caseCard}
|
||||
extra={
|
||||
<CloseOutlined
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Form.Item
|
||||
label={t('categoryName')}
|
||||
name={[field.name, 'name']}
|
||||
validateTrigger={['onChange', 'onBlur']}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
whitespace: true,
|
||||
message: t('nameMessage'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<NameInput
|
||||
otherNames={getOtherFieldValues(
|
||||
form,
|
||||
'items',
|
||||
field,
|
||||
'name',
|
||||
)}
|
||||
validate={(errors: string[]) =>
|
||||
form.setFields([
|
||||
{
|
||||
name: ['items', field.name, 'name'],
|
||||
errors,
|
||||
},
|
||||
])
|
||||
}
|
||||
></NameInput>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t('description')}
|
||||
name={[field.name, 'description']}
|
||||
>
|
||||
<Input.TextArea rows={3} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t('examples')}
|
||||
name={[field.name, 'examples']}
|
||||
>
|
||||
<Input.TextArea rows={3} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('nextStep')} name={[field.name, 'to']}>
|
||||
<Select
|
||||
allowClear
|
||||
options={buildCategorizeToOptions(
|
||||
getOtherFieldValues(form, 'items', field, 'to'),
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item hidden name={[field.name, 'index']}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Card>
|
||||
items={[
|
||||
{
|
||||
key: field.key,
|
||||
label: (
|
||||
<div className="flex justify-between">
|
||||
<span>
|
||||
{form.getFieldValue(['items', field.name, 'name'])}
|
||||
</span>
|
||||
<CloseOutlined
|
||||
onClick={() => {
|
||||
remove(field.name);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
children: (
|
||||
<FormSet nodeId={nodeId} field={field}></FormSet>
|
||||
),
|
||||
},
|
||||
]}
|
||||
></Collapse>
|
||||
))}
|
||||
|
||||
<Button
|
||||
|
@ -2,7 +2,9 @@
|
||||
@darkBackgroundColor: rgba(150, 150, 150, 0.12);
|
||||
|
||||
.caseCard {
|
||||
background-color: @darkBackgroundColor;
|
||||
:global(.ant-collapse-content) {
|
||||
background-color: @darkBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
.addButton {
|
||||
|
Loading…
x
Reference in New Issue
Block a user