Maintain book selections when switching between table and grid views (#1651)
This commit is contained in:
@@ -242,6 +242,7 @@
|
||||
@if (currentViewMode === 'table' && books.length > 0) {
|
||||
<app-book-table
|
||||
[books]="books"
|
||||
[preselectedBookIds]="selectedBooks"
|
||||
(selectedBooksChange)="onSelectedBooksChange($event)"
|
||||
[sortOption]="this.bookSorter.selectedSort!"
|
||||
[visibleColumns]="visibleColumns"
|
||||
|
||||
+3
@@ -42,6 +42,7 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
@Input() books: Book[] = [];
|
||||
@Input() sortOption: SortOption | null = null;
|
||||
@Input() visibleColumns: any[] = [];
|
||||
@Input() preselectedBookIds = new Set<number>();
|
||||
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private bookService = inject(BookService);
|
||||
@@ -89,6 +90,8 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
this.metadataCenterViewMode = userState?.user?.userSettings.metadataCenterViewMode ?? 'route';
|
||||
});
|
||||
|
||||
this.selectedBookIds = this.preselectedBookIds;
|
||||
this.selectedBooks = this.bookService.getBooksByIdsFromState([...this.selectedBookIds]);
|
||||
this.setScrollHeight();
|
||||
window.addEventListener('resize', this.setScrollHeight.bind(this));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user