From 0ddc50d2a052d1b39c68cba70657e7f14d6ceb4e Mon Sep 17 00:00:00 2001 From: trivernis Date: Wed, 8 Dec 2021 20:43:31 +0100 Subject: [PATCH] Add page up and down shortcut and improve scrolling Signed-off-by: trivernis --- .../file-gallery/file-gallery.component.ts | 48 +++++++++---------- .../file-grid/file-grid.component.html | 2 +- .../file-grid/file-grid.component.ts | 38 ++++++++++++++- 3 files changed, 61 insertions(+), 27 deletions(-) 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 718953f..f7b06ec 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 @@ -42,6 +42,30 @@ export class FileGalleryComponent implements OnChanges, OnInit { tabService.selectedTab.subscribe(() => this.adjustElementSizes()); } + async ngOnInit(): Promise { + if (!this.selectedFile || this.files.indexOf( + this.selectedFile.data) < 0) { + await this.onEntrySelect( + this.getPreselectedEntry() ?? this.entries[0]) + } + } + + public async ngOnChanges(changes: SimpleChanges): Promise { + if (changes["files"]) { + this.entries = this.files.map( + f => new Selectable(f, f.hash == this.selectedFile?.data.hash)); + const selectedIndex = this.files.findIndex( + f => f.hash === this.selectedFile?.data.hash); + + if (!this.selectedFile || selectedIndex < 0) { + await this.onEntrySelect( + this.getPreselectedEntry() ?? this.entries[0]) + } else { + await this.onEntrySelect(this.entries[selectedIndex]) + } + } + } + /** * Called when a new entry is selected * @param {Selectable} entry @@ -75,30 +99,6 @@ export class FileGalleryComponent implements OnChanges, OnInit { } } - async ngOnInit(): Promise { - if (!this.selectedFile || this.files.indexOf( - this.selectedFile.data) < 0) { - await this.onEntrySelect( - this.getPreselectedEntry() ?? this.entries[0]) - } - } - - public async ngOnChanges(changes: SimpleChanges): Promise { - if (changes["files"]) { - this.entries = this.files.map( - f => new Selectable(f, f.hash == this.selectedFile?.data.hash)); - const selectedIndex = this.files.findIndex( - f => f.hash === this.selectedFile?.data.hash); - - if (!this.selectedFile || selectedIndex < 0) { - await this.onEntrySelect( - this.getPreselectedEntry() ?? this.entries[0]) - } else { - await this.onEntrySelect(this.entries[selectedIndex]) - } - } - } - /** * Selects the previous item in the gallery * @returns {Promise} 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 10e598e..6a62c74 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 @@ -1,5 +1,5 @@