A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: de-deduplicate children in tag list when filtering (#11229)
shamoon6b55740f563c
diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts b/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.tsindex 91cf09264..0db84182b 100644--- a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts+++ b/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts@@ -73,9 +73,14 @@ describe('TagListComponent', () => {)})- it('should filter out child tags if name filter is empty, otherwise show all', () => {+ it('should omit matching children from top level when their parent is present', () => {const tags = [- { id: 1, name: 'Tag1', parent: null },+ {+ id: 1,+ name: 'Tag1',+ parent: null,+ children: [{ id: 2, name: 'Tag2', parent: 1 }],+ },{ id: 2, name: 'Tag2', parent: 1 },{ id: 3, name: 'Tag3', parent: null },]@@ -86,7 +91,13 @@ describe('TagListComponent', () => {component['_nameFilter'] = 'Tag2' // Simulate non-empty name filterconst filteredWithName = component.filterData(tags as any)- expect(filteredWithName.length).toBe(3)+ expect(filteredWithName.length).toBe(2)+ expect(filteredWithName.find((t) => t.id === 2)).toBeUndefined()+ expect(+ filteredWithName+ .find((t) => t.id === 1)+ ?.children?.some((c) => c.id === 2)+ ).toBe(true)})it('should request only parent tags when no name filter is applied', () => {diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.ts b/src-ui/src/app/components/manage/tag-list/tag-list.component.tsindex bf5ad1b50..64ca121df 100644--- a/src-ui/src/app/components/manage/tag-list/tag-list.component.ts+++ b/src-ui/src/app/components/manage/tag-list/tag-list.component.ts@@ -69,9 +69,13 @@ export class TagListComponent extends ManagementListComponent<Tag> {}filterData(data: Tag[]) {- return this.nameFilter?.length- ? [...data]- : data.filter((tag) => !tag.parent)+ if (!this.nameFilter?.length) {+ return data.filter((tag) => !tag.parent)+ }++ // When filtering by name, exclude children if their parent is also present+ const availableIds = new Set(data.map((tag) => tag.id))+ return data.filter((tag) => !tag.parent || !availableIds.has(tag.parent))}protected override getSelectableIDs(tags: Tag[]): number[] {