WIP: Buggy big table to small to big switching

This commit is contained in:
aditya.chandel
2025-01-08 17:08:05 -07:00
parent ccc2fa23b6
commit 6b541c77af
13 changed files with 203 additions and 178 deletions
+4 -4
View File
@@ -24,7 +24,7 @@
"ngx-extended-pdf-viewer": "^22.0.0", "ngx-extended-pdf-viewer": "^22.0.0",
"ngx-infinite-scroll": "^19.0.0", "ngx-infinite-scroll": "^19.0.0",
"primeicons": "^7.0.0", "primeicons": "^7.0.0",
"primeng": "19.0.2", "primeng": "19.0.3",
"quill": "^2.0.3", "quill": "^2.0.3",
"rxjs": "~7.8.0", "rxjs": "~7.8.0",
"tailwindcss-primeui": "^0.3.4", "tailwindcss-primeui": "^0.3.4",
@@ -12037,9 +12037,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/primeng": { "node_modules/primeng": {
"version": "19.0.2", "version": "19.0.3",
"resolved": "https://registry.npmjs.org/primeng/-/primeng-19.0.2.tgz", "resolved": "https://registry.npmjs.org/primeng/-/primeng-19.0.3.tgz",
"integrity": "sha512-7vizB1ynvvADjZBE9/Ks/YFwbY/d2tKYo+8Uq3OsBq9+rf9pIwKQIhd9GKkpe1gXx5Ig2SOFVeTp1Ru4H/vlVA==", "integrity": "sha512-cv15SG37WcMFlGZY9cyMULM8l91PTYRONdvMoDECNnH7LV0EkG1jvrsAezn8c4IsoJheofnoZez9D6Z9TpS4PQ==",
"license": "SEE LICENSE IN LICENSE.md", "license": "SEE LICENSE IN LICENSE.md",
"dependencies": { "dependencies": {
"@primeuix/styled": "^0.3.2", "@primeuix/styled": "^0.3.2",
+1 -1
View File
@@ -26,7 +26,7 @@
"ngx-extended-pdf-viewer": "^22.0.0", "ngx-extended-pdf-viewer": "^22.0.0",
"ngx-infinite-scroll": "^19.0.0", "ngx-infinite-scroll": "^19.0.0",
"primeicons": "^7.0.0", "primeicons": "^7.0.0",
"primeng": "19.0.2", "primeng": "19.0.3",
"quill": "^2.0.3", "quill": "^2.0.3",
"rxjs": "~7.8.0", "rxjs": "~7.8.0",
"tailwindcss-primeui": "^0.3.4", "tailwindcss-primeui": "^0.3.4",
+1 -1
View File
@@ -14,7 +14,7 @@ const routes: Routes = [
path: '', component: DashboardComponent, path: '', component: DashboardComponent,
}, },
{ {
path: 'all-books', component: BookTableComponent, path: 'all-books', component: BookBrowserComponent,
}, },
{ {
path: 'library/:libraryId/books', component: BookBrowserComponent, path: 'library/:libraryId/books', component: BookBrowserComponent,
+38 -32
View File
@@ -43,6 +43,9 @@ import Aura from '@primeng/themes/aura';
import {IftaLabel} from 'primeng/iftalabel'; import {IftaLabel} from 'primeng/iftalabel';
import {LoadingOverlayComponent} from './loading-overlay/loading-overlay.component'; import {LoadingOverlayComponent} from './loading-overlay/loading-overlay.component';
import {MultiSelectModule} from 'primeng/multiselect'; import {MultiSelectModule} from 'primeng/multiselect';
import {SelectButton} from "primeng/selectbutton";
import {BookTableComponent} from './book/component/book-table/book-table.component';
import {RadioButton} from 'primeng/radiobutton';
@NgModule({ @NgModule({
declarations: [ declarations: [
@@ -52,38 +55,41 @@ import {MultiSelectModule} from 'primeng/multiselect';
ShelfAssignerComponent, ShelfAssignerComponent,
BookBrowserComponent BookBrowserComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
AppRoutingModule, AppRoutingModule,
AppLayoutModule, AppLayoutModule,
FormsModule, FormsModule,
InputTextModule, InputTextModule,
TableModule, TableModule,
Button, Button,
StepperModule, StepperModule,
IconFieldModule, IconFieldModule,
InputIconModule, InputIconModule,
ToggleButtonModule, ToggleButtonModule,
PasswordModule, PasswordModule,
ToastModule, ToastModule,
InfiniteScrollDirective, InfiniteScrollDirective,
SearchComponent, SearchComponent,
DropdownModule, DropdownModule,
VirtualScrollerModule, VirtualScrollerModule,
LazyLoadImageModule, LazyLoadImageModule,
ConfirmDialogModule, ConfirmDialogModule,
CheckboxModule, CheckboxModule,
DividerModule, DividerModule,
DialogModule, DialogModule,
BookCardComponent, BookCardComponent,
SpeedDialModule, SpeedDialModule,
MenuModule, MenuModule,
IconPickerComponent, IconPickerComponent,
ProgressSpinnerModule, ProgressSpinnerModule,
IftaLabel, IftaLabel,
LoadingOverlayComponent, LoadingOverlayComponent,
MultiSelectModule MultiSelectModule,
], SelectButton,
BookTableComponent,
RadioButton
],
providers: [ providers: [
DialogService, DialogService,
MessageService, MessageService,
@@ -19,7 +19,6 @@ import {MultiSelect} from 'primeng/multiselect';
templateUrl: './metadata-searcher.component.html', templateUrl: './metadata-searcher.component.html',
styleUrls: ['./metadata-searcher.component.scss'], styleUrls: ['./metadata-searcher.component.scss'],
imports: [ imports: [
Select,
ReactiveFormsModule, ReactiveFormsModule,
Button, Button,
InputText, InputText,
@@ -4,10 +4,10 @@
<img [src]="coverImageSrc(bookMetadata.bookId)" class="book-cover placeholder" alt="Cover of {{ bookMetadata.title }}" loading="lazy" width="225"/> <img [src]="coverImageSrc(bookMetadata.bookId)" class="book-cover placeholder" alt="Cover of {{ bookMetadata.title }}" loading="lazy" width="225"/>
<div class="pl-4 flex flex-col w-full space-y-4"> <div class="pl-6 flex flex-col w-full space-y-4">
<div class="flex flex-row items-center justify-between"> <div class="flex flex-row items-center justify-between">
<div> <div>
<p class="text-xl font-bold">{{ bookMetadata.title }}</p> <p class="text-lg font-bold">{{ bookMetadata.title }}</p>
<div class="flex items-center gap-4 pt-1"> <div class="flex items-center gap-4 pt-1">
<p-rating [(ngModel)]="bookMetadata.rating" readonly stars="5"></p-rating> <p-rating [(ngModel)]="bookMetadata.rating" readonly stars="5"></p-rating>
<p class="font-semibold">({{ bookMetadata.reviewCount || 0 }} Reviews)</p> <p class="font-semibold">({{ bookMetadata.reviewCount || 0 }} Reviews)</p>
@@ -7,15 +7,8 @@
<p *ngIf="entityType === EntityType.ALL_BOOKS" class="entity-name text-2xl"> <p *ngIf="entityType === EntityType.ALL_BOOKS" class="entity-name text-2xl">
All Books All Books
</p> </p>
<div *ngIf="entityType !== EntityType.ALL_BOOKS"> <div *ngIf="entityType !== EntityType.ALL_BOOKS">
<p-button <p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
icon="pi pi-ellipsis-v"
[rounded]="true"
[text]="true"
severity="info"
(click)="entitymenu.toggle($event)">
</p-button>
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu> <p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
</div> </div>
</ng-container> </ng-container>
@@ -23,74 +16,69 @@
<div class="header-right-items"> <div class="header-right-items">
<input type="text" pInputText placeholder="Search by title..." [(ngModel)]="bookTitle" (ngModelChange)="onBookTitleChange($event)"/> <input type="text" pInputText placeholder="Search by title..." [(ngModel)]="bookTitle" (ngModelChange)="onBookTitleChange($event)"/>
<p-dropdown [options]="sortOptions" optionLabel="label" placeholder="Select Sorting" [(ngModel)]="selectedSort" (onChange)="updateSortOption($event.value)"></p-dropdown>
<p-dropdown <div class="state-options">
[options]="sortOptions" <p-radioButton *ngFor="let option of stateOptions" [value]="option.value" [(ngModel)]="value" (onClick)="viewChanged($event)"></p-radioButton>
optionLabel="label"
placeholder="Select Sorting"
[(ngModel)]="selectedSort"
(onChange)="updateSortOption($event.value)">
</p-dropdown>
<div class="zoom-controls">
<p-button icon="pi pi-minus" [rounded]="true" [outlined]="true" severity="info"></p-button>
<p-button icon="pi pi-plus" [rounded]="true" [outlined]="true" severity="info"></p-button>
</div> </div>
</div> </div>
</div> </div>
<div *ngIf="!(bookState$ | async)?.loaded && !(bookState$ | async)?.error"> <div *ngIf="bookState$ | async as bookState">
<p-progressSpinner></p-progressSpinner> <div *ngIf="!bookState?.loaded && !bookState?.error">
</div> <p-progressSpinner></p-progressSpinner>
<div class="virtual-scroller-container">
<div class="no-books-container" *ngIf="(bookState$ | async)?.error">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
</p>
</div>
<div class="no-books-container" *ngIf="!(bookState$ | async)?.error && (bookState$ | async)?.loaded && (bookState$ | async)?.books?.length === 0">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "This library has no books!" : "This shelf has no books!" }}
</p>
</div> </div>
<div class="book-card-container" *ngIf="(bookState$ | async)?.books as books"> <div class="virtual-scroller-container">
<virtual-scroller *ngIf="books.length > 0" class="virtual-scroller" #scroll [items]="books"> <div class="no-books-container" *ngIf="bookState?.error">
<div class="grid grid-cols-12 gap-4" #container> <p class="no-books-text">
<div class="virtual-scroller-item" *ngFor="let book of scroll.viewPortItems"> {{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
<app-book-card </p>
[book]="book" </div>
[isCheckboxEnabled]="true" <div class="no-books-container" *ngIf="!bookState?.error && bookState?.loaded && bookState?.books?.length === 0">
[onBookSelect]="handleBookSelect.bind(this)" <p class="no-books-text">
[isSelected]="selectedBooks.has(book.id)"> {{ entityType === EntityType.LIBRARY ? "This library has no books!" : "This shelf has no books!" }}
</app-book-card> </p>
</div>
<div class="book-card-container" *ngIf="bookState?.books as books">
<app-book-table *ngIf="value === 'table'" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"></app-book-table>
<virtual-scroller *ngIf="value === 'grid'" class="virtual-scroller" #scroll [items]="books">
<div class="grid grid-cols-12 gap-4" #container>
<div class="virtual-scroller-item" *ngFor="let book of scroll.viewPortItems">
<app-book-card
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
</div>
</div> </div>
</div> </virtual-scroller>
</virtual-scroller> </div>
</div>
<div class="book-browser-footer" *ngIf="selectedBooks.size > 0"> <div class="book-browser-footer" *ngIf="selectedBooks.size > 0">
<div class="footer-items-container"> <div class="footer-items-container">
<ng-container *ngIf="entityType$ | async as entityType"> <ng-container *ngIf="entityType$ | async as entityType">
<p-button *ngIf="entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS" <p-button *ngIf="entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS"
icon="pi pi-book" icon="pi pi-book"
label="Assign Shelf" label="Assign Shelf"
severity="info" severity="info"
(onClick)="openShelfAssigner()"> (onClick)="openShelfAssigner()">
</p-button> </p-button>
<p-button *ngIf="entityType === EntityType.SHELF" <p-button *ngIf="entityType === EntityType.SHELF"
icon="pi pi-minus-circle" icon="pi pi-minus-circle"
label="Unshelf" label="Unshelf"
severity="info" severity="info"
(click)="unshelfBooks()"> (click)="unshelfBooks()">
</p-button> </p-button>
<p-button icon="pi pi-times" <p-button icon="pi pi-times"
label="Deselect" label="Deselect"
severity="warn" severity="warn"
(click)="deselectAllBooks()"> (click)="deselectAllBooks()">
</p-button> </p-button>
</ng-container> </ng-container>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -23,12 +23,6 @@
align-items: center; align-items: center;
} }
.zoom-controls {
display: flex;
gap: 1rem;
align-items: center;
}
.virtual-scroller-container { .virtual-scroller-container {
position: relative; position: relative;
@@ -1,4 +1,4 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {MenuItem, MessageService} from 'primeng/api'; import {MenuItem, MessageService} from 'primeng/api';
import {LibraryService} from '../../service/library.service'; import {LibraryService} from '../../service/library.service';
@@ -16,6 +16,8 @@ import {SortOption} from '../../model/sort.model';
import {BookState} from '../../model/state/book-state.model'; import {BookState} from '../../model/state/book-state.model';
import {Book} from '../../model/book.model'; import {Book} from '../../model/book.model';
import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service'; import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service';
import {SelectButtonChangeEvent} from 'primeng/selectbutton';
import {BookTableComponent} from '../book-table/book-table.component';
export enum EntityType { export enum EntityType {
LIBRARY = 'Library', LIBRARY = 'Library',
@@ -44,6 +46,12 @@ export class BookBrowserComponent implements OnInit {
sortOptions: SortOption[] = []; sortOptions: SortOption[] = [];
isDrawerVisible: boolean = false; isDrawerVisible: boolean = false;
dynamicDialogRef: DynamicDialogRef | undefined; dynamicDialogRef: DynamicDialogRef | undefined;
EntityType = EntityType;
stateOptions: any[] = [{ label: 'Grid', value: 'grid' },{ label: 'Table', value: 'table' }];
value: string = 'table';
@ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent;
constructor( constructor(
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
@@ -91,7 +99,6 @@ export class BookBrowserComponent implements OnInit {
this.bookTitle$.next(''); this.bookTitle$.next('');
this.bookTitle = ''; this.bookTitle = '';
}); });
} }
private getEntityInfoFromRoute(): Observable<{ entityId: number; entityType: EntityType }> { private getEntityInfoFromRoute(): Observable<{ entityId: number; entityType: EntityType }> {
@@ -214,9 +221,20 @@ export class BookBrowserComponent implements OnInit {
this.isDrawerVisible = this.selectedBooks.size > 0; this.isDrawerVisible = this.selectedBooks.size > 0;
} }
onSelectedBooksChange(selectedBookIds: Set<number>): void {
this.selectedBooks = new Set(selectedBookIds);
this.isDrawerVisible = this.selectedBooks.size > 0;
}
deselectAllBooks(): void { deselectAllBooks(): void {
this.selectedBooks.clear(); this.selectedBooks.clear();
this.isDrawerVisible = false; this.isDrawerVisible = false;
this.bookTableComponent.clearSelectedBooks();
}
viewChanged(event : SelectButtonChangeEvent) {
this.selectedBooks.clear();
this.isDrawerVisible = false;
} }
unshelfBooks() { unshelfBooks() {
@@ -285,6 +303,4 @@ export class BookBrowserComponent implements OnInit {
this.selectedBooks.clear(); this.selectedBooks.clear();
}); });
} }
protected readonly EntityType = EntityType;
} }
@@ -34,11 +34,7 @@ export class BookCardComponent implements OnInit {
items: MenuItem[] | undefined; items: MenuItem[] | undefined;
isHovered: boolean = false; isHovered: boolean = false;
constructor( constructor(private bookService: BookService, private dialogService: DialogService) {
private bookService: BookService,
private router: Router,
private dialogService: DialogService
) {
} }
ngOnInit(): void { ngOnInit(): void {
@@ -1,41 +1,36 @@
<div *ngIf="!(bookState$ | async)?.loaded && !(bookState$ | async)?.error"> <p-table [value]="books" [resizableColumns]="true" showGridlines stripedRows [scrollable]="true" [scrollHeight]="'calc(100vh - 160px)'"
<p-progressSpinner></p-progressSpinner> [virtualScroll]="true" [virtualScrollItemSize]="46" [(selection)]="selectedBooks" (onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)"
</div> (onRowSelect)="onRowSelect($event)" (onRowUnselect)="onRowUnselect($event)">
<ng-template #header>
<div *ngIf="(bookState$ | async)?.books as book"> <tr>
<p-table [value]="book" [resizableColumns]="true" showGridlines stripedRows [scrollable]="true" <th class="max-w-16">Cover</th>
scrollHeight="900px" [virtualScroll]="true" [virtualScrollItemSize]="46"> <th class="w-1/2 max-w-52 overflow-hidden truncate" pResizableColumn>Title</th>
<ng-template #header> <th class="w-1/6 max-w-48 overflow-hidden truncate">Publisher</th>
<tr> <th class="w-1/8 max-w-44 overflow-hidden truncate" pResizableColumn>Subtitle</th>
<th class="max-w-16">Cover</th> <th class="w-1/8 max-w-36 overflow-hidden truncate">ISBN</th>
<th class="w-1/2 max-w-52 overflow-hidden truncate" pResizableColumn>Title</th> <th class="w-1/8 max-w-32 overflow-hidden truncate">Language</th>
<th class="w-1/6 max-w-48 overflow-hidden truncate">Publisher</th> <th class="w-1/8 max-w-36 overflow-hidden truncate">Rating</th>
<th class="w-1/8 max-w-44 overflow-hidden truncate" pResizableColumn>Subtitle</th> <th class="max-w-16">
<th class="w-1/8 max-w-36 overflow-hidden truncate">ISBN</th> <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
<th class="w-1/8 max-w-32 overflow-hidden truncate">Language</th> </th>
<th class="w-1/8 max-w-36 overflow-hidden truncate">Rating</th> </tr>
<th class="max-w-16"> </ng-template>
<p-tableHeaderCheckbox/> <ng-template #body let-book>
</th> <tr style="height:46px">
</tr> <td (click)="openMetadataCenter(book.id)" class="w-6 h-6"><img [src]="getBookCoverUrl(book.id)" alt="Book Cover" class="size-7"/></td>
</ng-template> <td (click)="openMetadataCenter(book.id)" class="w-1/2 max-w-52 overflow-hidden truncate" [title]="book.metadata?.title">{{ book.metadata?.title }}</td>
<ng-template #body let-book> <td class="w-1/6 max-w-48 overflow-hidden truncate">{{ book.metadata?.publisher }}</td>
<tr style="height:46px"> <td class="w-1/8 max-w-44 overflow-hidden truncate">{{ book.metadata?.subtitle }}</td>
<td (click)="openMetadataCenter(book.id)" class="w-6 h-6"><img [src]="getBookCoverUrl(book.id)" alt="Book Cover" class="size-7"/></td> <td class="w-1/8 max-w-36 overflow-hidden truncate">{{ book.metadata?.isbn10 }}</td>
<td (click)="openMetadataCenter(book.id)" class="w-1/2 max-w-52 overflow-hidden truncate" [title]="book.metadata?.title">{{ book.metadata?.title }} </td> <td class="w-1/8 max-w-32 overflow-hidden truncate">{{ book.metadata?.language }}</td>
<td class="w-1/6 max-w-48 overflow-hidden truncate">{{ book.metadata?.publisher }}</td> <td class="w-1/8 max-w-36 overflow-hidden truncate">
<td class="w-1/8 max-w-44 overflow-hidden truncate">{{ book.metadata?.subtitle }}</td> <ng-container *ngIf="book.metadata">
<td class="w-1/8 max-w-36 overflow-hidden truncate">{{ book.metadata?.isbn10 }}</td> <p-rating [(ngModel)]="book.metadata.rating" readonly stars="5"></p-rating>
<td class="w-1/8 max-w-32 overflow-hidden truncate">{{ book.metadata?.language }}</td> </ng-container>
<td class="w-1/8 max-w-36 overflow-hidden truncate"> </td>
<ng-container *ngIf="book.metadata"> <td class="max-w-16">
<p-rating [(ngModel)]="book.metadata.rating" readonly stars="5"></p-rating> <p-tableCheckbox [value]="book"></p-tableCheckbox>
</ng-container> </td>
</td> </tr>
<td class="max-w-16"> </ng-template>
<p-tableCheckbox [value]="book"/> </p-table>
</td>
</tr>
</ng-template>
</p-table>
</div>
@@ -0,0 +1,6 @@
/*
.p-datatable-flex-scrollable .p-datatable-wrapper {
flex-basis: auto !important;
height: 0 !important;
}
*/
@@ -1,14 +1,12 @@
import { Component } from '@angular/core'; import {ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnChanges, Output, SimpleChanges} from '@angular/core';
import {Observable} from 'rxjs';
import {BookState} from '../../model/state/book-state.model';
import {TableModule} from 'primeng/table'; import {TableModule} from 'primeng/table';
import {AsyncPipe, NgIf} from '@angular/common'; import {NgIf} from '@angular/common';
import {ProgressSpinner} from 'primeng/progressspinner';
import {BookService} from '../../service/book.service'; import {BookService} from '../../service/book.service';
import {Rating} from 'primeng/rating'; import {Rating} from 'primeng/rating';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {BookMetadataCenterComponent} from '../../../book-metadata-center/book-metadata-center.component'; import {BookMetadataCenterComponent} from '../../../book-metadata-center/book-metadata-center.component';
import {DialogService} from 'primeng/dynamicdialog'; import {DialogService} from 'primeng/dynamicdialog';
import {Book} from '../../model/book.model';
@Component({ @Component({
selector: 'app-book-table', selector: 'app-book-table',
@@ -16,31 +14,58 @@ import {DialogService} from 'primeng/dynamicdialog';
templateUrl: './book-table.component.html', templateUrl: './book-table.component.html',
imports: [ imports: [
TableModule, TableModule,
AsyncPipe,
NgIf, NgIf,
ProgressSpinner,
Rating, Rating,
FormsModule FormsModule
], ],
styleUrl: './book-table.component.scss' styleUrl: './book-table.component.scss'
}) })
export class BookTableComponent { export class BookTableComponent {
bookState$: Observable<BookState>; selectedBooks: Book[] = [];
selectedBookIds: Set<number> = new Set();
constructor(private bookService: BookService, private dialogService: DialogService) { @Output() selectedBooksChange = new EventEmitter<Set<number>>();
this.bookState$ = this.bookService.bookState$; @Input() books: Book[] = [];
constructor(private bookService: BookService, private dialogService: DialogService, private zone: NgZone) {
}
clearSelectedBooks(): void {
this.selectedBookIds.clear();
this.selectedBooks = [];
this.selectedBooksChange.emit(this.selectedBookIds);
}
onRowSelect(event: any): void {
this.selectedBookIds.add(event.data.id);
this.selectedBooksChange.emit(this.selectedBookIds);
}
onRowUnselect(event: any): void {
this.selectedBookIds.delete(event.data.id);
this.selectedBooksChange.emit(this.selectedBookIds);
}
onHeaderCheckboxToggle(event: any): void {
if (event.checked) {
this.selectedBooks = [...this.books];
this.selectedBookIds = new Set(this.books.map(book => book.id));
} else {
this.clearSelectedBooks();
}
this.selectedBooksChange.emit(this.selectedBookIds);
} }
getBookCoverUrl(bookId: number): string { getBookCoverUrl(bookId: number): string {
return this.bookService.getBookCoverUrl(bookId); return this.bookService.getBookCoverUrl(bookId);
} }
openMetadataCenter(id: number) { openMetadataCenter(id: number): void {
this.openBookDetailsDialog(id); this.openBookDetailsDialog(id);
} }
openBookDetailsDialog(bookId: number): void { openBookDetailsDialog(bookId: number): void {
this.bookService.getBookByIdFromAPI(bookId, true).subscribe(({ this.bookService.getBookByIdFromAPI(bookId, true).subscribe({
next: (book) => { next: (book) => {
this.dialogService.open(BookMetadataCenterComponent, { this.dialogService.open(BookMetadataCenterComponent, {
header: 'Open book details', header: 'Open book details',
@@ -59,6 +84,6 @@ export class BookTableComponent {
error: (error) => { error: (error) => {
console.error('Error fetching book:', error); console.error('Error fetching book:', error);
} }
})) });
} }
} }