diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts b/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts index 7a25085b2..cc618bf89 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts +++ b/booklore-ui/src/app/features/book/components/book-browser/book-browser.component.ts @@ -465,14 +465,30 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { ); } - onCheckboxClicked(event: { index: number; bookId: number; selected: boolean; shiftKey: boolean }) { - const {index, bookId, selected, shiftKey} = event; - if (!shiftKey || this.lastSelectedIndex === null) { - if (selected) { - this.selectedBooks.add(bookId); + handleBookSelection(book: Book, selected: boolean) { + if (selected) { + if (book.seriesBooks) { + //it is a series + this.selectedBooks = new Set([...this.selectedBooks, ...book.seriesBooks.map(book=>book.id)]); } else { - this.selectedBooks.delete(bookId); + this.selectedBooks.add(book.id); } + } else { + if (book.seriesBooks) { + //it is a series + book.seriesBooks.forEach(book =>{ + this.selectedBooks.delete(book.id); + }); + } else { + this.selectedBooks.delete(book.id); + } + } + } + + onCheckboxClicked(event: { index: number; book: Book; selected: boolean; shiftKey: boolean }) { + const {index, book, selected, shiftKey} = event; + if (!shiftKey || this.lastSelectedIndex === null) { + this.handleBookSelection(book, selected); this.lastSelectedIndex = index; } else { const start = Math.min(this.lastSelectedIndex, index); @@ -481,23 +497,14 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { for (let i = start; i <= end; i++) { const book = this.currentBooks[i]; if (!book) continue; - - if (isUnselectingRange) { - this.selectedBooks.delete(book.id); - } else { - this.selectedBooks.add(book.id); - } + this.handleBookSelection(book, !isUnselectingRange); } } this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks); } - handleBookSelect(bookId: number, selected: boolean): void { - if (selected) { - this.selectedBooks.add(bookId); - } else { - this.selectedBooks.delete(bookId); - } + handleBookSelect(book: Book, selected: boolean): void { + this.handleBookSelection(book, selected); this.isDrawerVisible = this.selectedBooks.size > 0; this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks); } @@ -543,8 +550,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { this.selectedBooks.clear(); }); }, - reject: () => { - } + reject: () => {} }); } diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.ts b/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.ts index bcc39ee6a..099226e88 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.ts +++ b/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.ts @@ -33,13 +33,13 @@ import {BookNavigationService} from '../../../service/book-navigation.service'; }) export class BookCardComponent implements OnInit, OnChanges, OnDestroy { - @Output() checkboxClick = new EventEmitter<{ index: number; bookId: number; selected: boolean; shiftKey: boolean }>(); + @Output() checkboxClick = new EventEmitter<{ index: number; book: Book; selected: boolean; shiftKey: boolean }>(); @Output() menuToggled = new EventEmitter(); @Input() index!: number; @Input() book!: Book; @Input() isCheckboxEnabled: boolean = false; - @Input() onBookSelect?: (bookId: number, selected: boolean) => void; + @Input() onBookSelect?: (book: Book, selected: boolean) => void; @Input() isSelected: boolean = false; @Input() bottomBarHidden: boolean = false; @Input() seriesViewEnabled: boolean = false; @@ -694,13 +694,13 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy { this.checkboxClick.emit({ index: this.index, - bookId: this.book.id, + book: this.book, selected: selected, shiftKey: shiftKey, }); if (this.onBookSelect) { - this.onBookSelect(this.book.id, selected); + this.onBookSelect(this.book, selected); } this.lastMouseEvent = null; diff --git a/booklore-ui/src/app/features/book/components/book-browser/filters/SeriesCollapseFilter.ts b/booklore-ui/src/app/features/book/components/book-browser/filters/SeriesCollapseFilter.ts index 3a21f641d..207a6d9f6 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/filters/SeriesCollapseFilter.ts +++ b/booklore-ui/src/app/features/book/components/book-browser/filters/SeriesCollapseFilter.ts @@ -81,6 +81,7 @@ export class SeriesCollapseFilter implements BookFilter, OnDestroy { const firstBook = sortedGroup[0]; collapsedBooks.push({ ...firstBook, + seriesBooks: group, seriesCount: group.length }); } diff --git a/booklore-ui/src/app/features/book/model/book.model.ts b/booklore-ui/src/app/features/book/model/book.model.ts index 31f9f3812..e536596fb 100644 --- a/booklore-ui/src/app/features/book/model/book.model.ts +++ b/booklore-ui/src/app/features/book/model/book.model.ts @@ -40,6 +40,7 @@ export interface Book extends FileInfo { koreaderProgress?: KoReaderProgress; koboProgress?: KoboProgress; seriesCount?: number | null; + seriesBooks?: Book[] | null; metadataMatchScore?: number | null; personalRating?: number | null; readStatus?: ReadStatus;