fix(table-view): table-view to also actually select all when users select press all (#645)
This commit is contained in:
@@ -21,14 +21,22 @@ export class BookSelectionService {
|
||||
this.currentBooks = books;
|
||||
}
|
||||
|
||||
getSelectableBookIds(book: Book): number[] {
|
||||
return book.seriesBooks?.length
|
||||
? book.seriesBooks.map(seriesBook => seriesBook.id)
|
||||
: [book.id];
|
||||
}
|
||||
|
||||
isBookSelected(book: Book): boolean {
|
||||
const selectedIds = this._selectedBooks();
|
||||
const ids = this.getSelectableBookIds(book);
|
||||
return ids.every(id => selectedIds.has(id));
|
||||
}
|
||||
|
||||
selectBook(book: Book): void {
|
||||
this._selectedBooks.update(current => {
|
||||
const next = new Set(current);
|
||||
if (book.seriesBooks) {
|
||||
book.seriesBooks.forEach(seriesBook => next.add(seriesBook.id));
|
||||
} else {
|
||||
next.add(book.id);
|
||||
}
|
||||
this.getSelectableBookIds(book).forEach(bookId => next.add(bookId));
|
||||
return next;
|
||||
});
|
||||
}
|
||||
@@ -36,11 +44,7 @@ export class BookSelectionService {
|
||||
deselectBook(book: Book): void {
|
||||
this._selectedBooks.update(current => {
|
||||
const next = new Set(current);
|
||||
if (book.seriesBooks) {
|
||||
book.seriesBooks.forEach(seriesBook => next.delete(seriesBook.id));
|
||||
} else {
|
||||
next.delete(book.id);
|
||||
}
|
||||
this.getSelectableBookIds(book).forEach(bookId => next.delete(bookId));
|
||||
return next;
|
||||
});
|
||||
}
|
||||
@@ -83,7 +87,7 @@ export class BookSelectionService {
|
||||
this._selectedBooks.update(current => {
|
||||
const next = new Set(current);
|
||||
for (const book of this.currentBooks) {
|
||||
next.add(book.id);
|
||||
this.getSelectableBookIds(book).forEach(bookId => next.add(bookId));
|
||||
}
|
||||
return next;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user