From a55535eb54a2991dd5b8bc3f950c6d46a5a1b83d Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 22 Nov 2026 08:39:57 -0800 Subject: [PATCH] Use the new display tags pipe and hidden badge on lists --- .../saved-view-widget.component.html | 6 ++- .../saved-view-widget.component.ts | 6 ++- .../document-card-large.component.html | 6 ++- .../document-card-large.component.ts | 6 ++- .../document-card-small.component.html | 9 +++- .../document-card-small.component.spec.ts | 42 +++++++++++++++++++ .../document-card-small.component.ts | 14 ++++++- .../document-list.component.html | 6 ++- .../document-list/document-list.component.ts | 6 ++- 9 files changed, 88 insertions(+), 13 deletions(-) diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html index 4f94cfee4..06ea8cb26 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html @@ -76,9 +76,13 @@ } } @case (DisplayField.TAGS) { - @for (tagID of doc.tags | collapseTags | async; track tagID) { + @let tags = doc.tags | displayTags | async; + @for (tagID of tags?.visible; track tagID) { } + @if (tags?.hidden.length) { + + } } @case (DisplayField.DOCUMENT_TYPE) { @if (doc.document_type) { diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts index 4e5e2d3bd..4a9825f6f 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts @@ -1,3 +1,4 @@ +import { HiddenTagsBadgeComponent } from 'src/app/components/common/hidden-tags-badge/hidden-tags-badge.component' import { AsyncPipe, NgClass, NgStyle } from '@angular/common' import { Component, @@ -38,7 +39,7 @@ import { } from 'src/app/data/filter-rule-type' import { SavedView } from 'src/app/data/saved-view' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { CollapseTagsPipe } from 'src/app/pipes/collapse-tags.pipe' +import { DisplayTagsPipe } from 'src/app/pipes/display-tags.pipe' import { CorrespondentNamePipe } from 'src/app/pipes/correspondent-name.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe' @@ -76,7 +77,8 @@ import { WidgetFrameComponent } from '../widget-frame/widget-frame.component' DocumentTypeNamePipe, StoragePathNamePipe, AsyncPipe, - CollapseTagsPipe, + DisplayTagsPipe, + HiddenTagsBadgeComponent, DocumentTitlePipe, CustomDatePipe, NgClass, diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html index 6f6067a93..80575d915 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html @@ -36,9 +36,13 @@ {{document().title | documentTitle}} } @if (displayFields().includes(DisplayField.TAGS)) { - @for (tagID of document().tags | collapseTags | async; track tagID) { + @let tags = document().tags | displayTags | async; + @for (tagID of tags?.visible; track tagID) { } + @if (tags?.hidden.length) { + + } } } @else {
 
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts index 98a5d286e..0b7822460 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts @@ -1,3 +1,4 @@ +import { HiddenTagsBadgeComponent } from 'src/app/components/common/hidden-tags-badge/hidden-tags-badge.component' import { AsyncPipe, NgOptimizedImage } from '@angular/common' import { AfterViewInit, @@ -20,7 +21,7 @@ import { Document, } from 'src/app/data/document' import { SETTINGS_KEYS } from 'src/app/data/ui-settings' -import { CollapseTagsPipe } from 'src/app/pipes/collapse-tags.pipe' +import { DisplayTagsPipe } from 'src/app/pipes/display-tags.pipe' import { CorrespondentNamePipe } from 'src/app/pipes/correspondent-name.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe' @@ -46,7 +47,8 @@ import { LoadingComponentWithPermissions } from '../../loading-component/loading TagComponent, CustomFieldDisplayComponent, AsyncPipe, - CollapseTagsPipe, + DisplayTagsPipe, + HiddenTagsBadgeComponent, NgOptimizedImage, UsernamePipe, CorrespondentNamePipe, diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html index 1b77c34ec..a3e723f22 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html @@ -19,8 +19,10 @@ } @if (document() && displayFields().includes(DisplayField.TAGS)) { - @let visibleTagIDs = document().tags | collapseTags | async; -
+ @let tags = document().tags | displayTags | async; + @let visibleTagIDs = tags?.visible; + @let showHidden = showHiddenTags(tags); +
@for (tagID of getTagIDs(visibleTagIDs); track tagID) { } @@ -29,6 +31,9 @@ + {{moreTags}}
} + @if (showHidden) { + + }
} diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts index c28037ab7..f0b320c92 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts @@ -42,6 +42,19 @@ describe('DocumentCardSmallComponent', () => { ], }).compileComponents() + jest + .spyOn(TestBed.inject(PermissionsService), 'currentUserCan') + .mockReturnValue(true) + jest.spyOn(TestBed.inject(TagService), 'listAll').mockReturnValue( + of({ + count: 8, + all: [1, 2, 3, 4, 5, 6, 7, 8], + results: [1, 2, 3, 4, 5, 6, 7, 8].map((id) => ({ + id, + name: `Tag ${id}`, + })), + }) + ) fixture = TestBed.createComponent(DocumentCardSmallComponent) component = fixture.componentInstance fixture.componentRef.setInput('document', Object.assign({}, doc)) @@ -148,4 +161,33 @@ describe('DocumentCardSmallComponent', () => { component.mouseLeaveCard() expect(component.popupPreview.close).toHaveBeenCalled() }) + + it('should show hidden tags last, only when visible tags leave a slot free', () => { + fixture.componentRef.setInput('document', { + ...component.document(), + tags: [1, 2, 3, 98, 99], + }) + fixture.detectChanges() + const tagsEl = () => fixture.nativeElement.querySelector('.tags') + expect(tagsEl().lastElementChild.textContent).toContain('2 hidden') + + // 6 visible tags fill the limit (document has notes) + fixture.componentRef.setInput('document', { + ...component.document(), + tags: [1, 2, 3, 4, 5, 6, 98, 99], + }) + fixture.detectChanges() + expect(tagsEl().textContent).not.toContain('hidden') + expect( + fixture.debugElement.queryAll(By.directive(TagComponent)) + ).toHaveLength(6) + + fixture.componentRef.setInput('document', { + ...component.document(), + tags: [1, 2, 3, 4, 5, 6, 7, 98], + }) + fixture.detectChanges() + expect(tagsEl().textContent).toContain('+ 2') + expect(tagsEl().textContent).not.toContain('hidden') + }) }) diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts index 6b9e5f097..4e5874491 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts @@ -1,3 +1,5 @@ +import { TagPartition } from 'src/app/utils/tag-display' +import { HiddenTagsBadgeComponent } from 'src/app/components/common/hidden-tags-badge/hidden-tags-badge.component' import { AsyncPipe, NgOptimizedImage } from '@angular/common' import { AfterViewInit, @@ -20,7 +22,7 @@ import { Document, } from 'src/app/data/document' import { SETTINGS_KEYS } from 'src/app/data/ui-settings' -import { CollapseTagsPipe } from 'src/app/pipes/collapse-tags.pipe' +import { DisplayTagsPipe } from 'src/app/pipes/display-tags.pipe' import { CorrespondentNamePipe } from 'src/app/pipes/correspondent-name.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe' @@ -46,7 +48,8 @@ import { LoadingComponentWithPermissions } from '../../loading-component/loading TagComponent, CustomFieldDisplayComponent, AsyncPipe, - CollapseTagsPipe, + DisplayTagsPipe, + HiddenTagsBadgeComponent, NgOptimizedImage, UsernamePipe, CorrespondentNamePipe, @@ -96,6 +99,13 @@ export class DocumentCardSmallComponent return this.document()?.notes.length > 0 ? 6 : 7 } + /** + * The hidden tags badge only fills a slot the visible tags leave free. + */ + showHiddenTags(tags: TagPartition): boolean { + return tags?.hidden.length > 0 && tags.visible.length < this.tagLimit + } + getMoreTags(tagIDs: number[]): number { const limit = this.tagLimit return tagIDs?.length > limit ? tagIDs.length - (limit - 1) : null diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html index 3f6e2e56b..7eb8252d5 100644 --- a/src-ui/src/app/components/document-list/document-list.component.html +++ b/src-ui/src/app/components/document-list/document-list.component.html @@ -335,9 +335,13 @@ {{d.title | documentTitle}} } @if (activeDisplayFields.includes(DisplayField.TAGS)) { - @for (tagID of d.tags | collapseTags | async; track tagID) { + @let tags = d.tags | displayTags | async; + @for (tagID of tags?.visible; track tagID) { } + @if (tags?.hidden.length) { + + } } } diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts index 146e3dda8..d1b1df7db 100644 --- a/src-ui/src/app/components/document-list/document-list.component.ts +++ b/src-ui/src/app/components/document-list/document-list.component.ts @@ -1,3 +1,4 @@ +import { HiddenTagsBadgeComponent } from 'src/app/components/common/hidden-tags-badge/hidden-tags-badge.component' import { AsyncPipe, NgClass, NgTemplateOutlet } from '@angular/common' import { Component, @@ -39,7 +40,7 @@ import { SortableDirective, SortEvent, } from 'src/app/directives/sortable.directive' -import { CollapseTagsPipe } from 'src/app/pipes/collapse-tags.pipe' +import { DisplayTagsPipe } from 'src/app/pipes/display-tags.pipe' import { CorrespondentNamePipe } from 'src/app/pipes/correspondent-name.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe' @@ -97,7 +98,8 @@ import { SaveViewConfigDialogComponent } from './save-view-config-dialog/save-vi StoragePathNamePipe, BootstrapIconComponent, AsyncPipe, - CollapseTagsPipe, + DisplayTagsPipe, + HiddenTagsBadgeComponent, FormsModule, ReactiveFormsModule, NgTemplateOutlet,