From 8022f2580176d4fd230a04283561b765a942c064 Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 18 Jan 2022 20:51:01 +0100 Subject: [PATCH] Add track by functions to tag and file lists Signed-off-by: trivernis --- .../file-gallery/file-gallery.component.html | 2 +- .../file-multiview/file-gallery/file-gallery.component.ts | 4 ++++ .../file-multiview/file-grid/file-grid.component.html | 4 ++-- .../file/file-multiview/file-grid/file-grid.component.ts | 8 ++++++++ .../shared/sidebar/file-search/file-search.component.html | 2 +- .../shared/sidebar/file-search/file-search.component.ts | 4 ++++ .../shared/sidebar/tag-edit/tag-edit.component.html | 2 +- .../shared/sidebar/tag-edit/tag-edit.component.ts | 4 ++++ 8 files changed, 25 insertions(+), 5 deletions(-) diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html index d81a443..f718760 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.html @@ -13,7 +13,7 @@
-
+
diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts index b91a293..d55f5ef 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-gallery/file-gallery.component.ts @@ -173,6 +173,10 @@ export class FileGalleryComponent implements OnChanges, OnInit, AfterViewInit { } } + public trackByFileId(index: number, item: Selectable) { + return item.data.id; + } + private scrollToSelection(): void { if (this.selectedFile) { const selectedIndex = this.entries.indexOf(this.selectedFile); diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html index 7034cbc..d5678c6 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.html @@ -5,13 +5,13 @@ class="file-gallery-inner"> -
+
diff --git a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts index 1ee2d26..f203b2c 100644 --- a/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts +++ b/mediarepo-ui/src/app/components/shared/file/file-multiview/file-grid/file-grid.component.ts @@ -169,6 +169,14 @@ export class FileGridComponent implements OnChanges, OnInit, AfterViewInit { this.ctrlClicked = event.ctrlKey ? false : this.ctrlClicked; } + public trackByFileRowId(index: number, item: Selectable[]) { + return item.map(e => e.data.id).join("-"); + } + + public trackByFileId(index: number, item: Selectable) { + return item.data.id; + } + private setPartitionedGridEntries() { this.partitionedGridEntries = []; let scrollToIndex = -1; diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html b/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html index d52827b..e4de89f 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html +++ b/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html @@ -50,7 +50,7 @@
+ *cdkVirtualFor="let tag of contextTags; trackBy: trackByTagId" class="selectable-tag">
diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.ts b/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.ts index 159f641..4188f5e 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.ts +++ b/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.ts @@ -198,6 +198,10 @@ export class FileSearchComponent implements AfterViewChecked, OnInit { return deepEqual(tagFilter, filter); } + public trackByTagId(index: number, item: Tag) { + return item.id; + } + private assignDisplayedFilters() { this.displayedFilters = this.filters.getFilters().filter(f => !this.isTagFilter(f)); } diff --git a/mediarepo-ui/src/app/components/shared/sidebar/tag-edit/tag-edit.component.html b/mediarepo-ui/src/app/components/shared/sidebar/tag-edit/tag-edit.component.html index 3578731..388fc69 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/tag-edit/tag-edit.component.html +++ b/mediarepo-ui/src/app/components/shared/sidebar/tag-edit/tag-edit.component.html @@ -5,7 +5,7 @@
-
+