From 8e6ddd7c1b5d76ae4721003941ac272cefc58192 Mon Sep 17 00:00:00 2001 From: chanx <1243304602@qq.com> Date: Tue, 23 Dec 2025 14:16:57 +0800 Subject: [PATCH] Fix: Metadata bugs. (#12111) ### What problem does this PR solve? Fix: Metadata bugs. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Kevin Hu --- .../list-filter-bar/filter-field.tsx | 2 +- .../list-filter-bar/filter-popover.tsx | 108 +++++++++++++----- web/src/components/list-filter-bar/index.tsx | 3 + web/src/hooks/use-document-request.ts | 6 +- web/src/interfaces/request/knowledge.ts | 1 + web/src/locales/en.ts | 2 + .../pages/dataset/components/metedata/hook.ts | 24 ++-- .../components/metedata/manage-modal.tsx | 41 ++++--- .../metedata/manage-values-modal.tsx | 8 +- .../dataset-setting/configuration/audio.tsx | 2 + .../dataset-setting/configuration/book.tsx | 2 + .../dataset-setting/configuration/email.tsx | 2 + .../dataset-setting/configuration/laws.tsx | 2 + .../dataset-setting/configuration/manual.tsx | 2 + .../dataset-setting/configuration/one.tsx | 2 + .../dataset-setting/configuration/paper.tsx | 2 + .../dataset-setting/configuration/picture.tsx | 2 + .../configuration/presentation.tsx | 2 + web/src/pages/dataset/dataset/index.tsx | 26 ++++- .../dataset/dataset/use-select-filters.ts | 8 +- 20 files changed, 184 insertions(+), 63 deletions(-) diff --git a/web/src/components/list-filter-bar/filter-field.tsx b/web/src/components/list-filter-bar/filter-field.tsx index 087d0c0642..134e6f3ef9 100644 --- a/web/src/components/list-filter-bar/filter-field.tsx +++ b/web/src/components/list-filter-bar/filter-field.tsx @@ -118,7 +118,7 @@ export const FilterField = memo( setShowAll(!showAll); }} > - + {item.label} {showAll ? ( diff --git a/web/src/components/list-filter-bar/filter-popover.tsx b/web/src/components/list-filter-bar/filter-popover.tsx index f4c05bfd2e..ba4628193e 100644 --- a/web/src/components/list-filter-bar/filter-popover.tsx +++ b/web/src/components/list-filter-bar/filter-popover.tsx @@ -33,6 +33,7 @@ export type CheckboxFormMultipleProps = { onChange?: FilterChange; onOpenChange?: (open: boolean) => void; setOpen(open: boolean): void; + filterGroup?: Record; }; function CheckboxFormMultiple({ @@ -40,6 +41,7 @@ function CheckboxFormMultiple({ value, onChange, setOpen, + filterGroup, }: CheckboxFormMultipleProps) { const [resolvedFilters, setResolvedFilters] = useState(filters); @@ -120,6 +122,20 @@ function CheckboxFormMultiple({ } }, [form, value, resolvedFilters, fieldsDict]); + const filterList = useMemo(() => { + const filterSet = filterGroup + ? Object.values(filterGroup).reduce>((pre, cur) => { + cur.forEach((item) => pre.add(item)); + return pre; + }, new Set()) + : new Set(); + return [...filterSet]; + }, [filterGroup]); + + const notInfilterGroup = useMemo(() => { + return filters.filter((x) => !filterList.includes(x.field)); + }, [filterList, filters]); + return (
form.reset()} > - {filters.map((x) => ( - ( - -
- {x.label} +
+ {filterGroup && + Object.keys(filterGroup).map((key) => { + const filterKeys = filterGroup[key]; + const thisFilters = filters.filter((x) => + filterKeys.includes(x.field), + ); + return ( +
+
{key}
+
+ {thisFilters.map((x) => ( + + ))} +
- {x.list.map((item) => { - return ( - - ); - })} - - - )} - /> - ))} + ); + })} + {notInfilterGroup && + notInfilterGroup.map((x) => { + return ( + ( + +
+ + {x.label} + +
+ {x.list.map((item) => { + return ( + + ); + })} + +
+ )} + /> + ); + })} +
+