mirror of
https://github.com/adityachandelgit/BookLore.git
synced 2026-01-06 03:50:45 -06:00
fix: when selecting a series, select all books from the series (#1979)
This commit is contained in:
@@ -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: () => {}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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<boolean>();
|
||||
|
||||
@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;
|
||||
|
||||
@@ -81,6 +81,7 @@ export class SeriesCollapseFilter implements BookFilter, OnDestroy {
|
||||
const firstBook = sortedGroup[0];
|
||||
collapsedBooks.push({
|
||||
...firstBook,
|
||||
seriesBooks: group,
|
||||
seriesCount: group.length
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user