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