diff --git a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts index 0b4bea88e..e6bc4f7dd 100644 --- a/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts +++ b/booklore-ui/src/app/book/components/book-browser/book-browser.component.ts @@ -650,6 +650,9 @@ export class BookBrowserComponent implements OnInit, AfterViewInit { openShelfAssigner(): void { this.dynamicDialogRef = this.dialogHelperService.openShelfAssigner(this.selectedBooks); + this.dynamicDialogRef.onClose.subscribe(() => { + this.selectedBooks = new Set(); + }); } lockUnlockMetadata(): void { diff --git a/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.html b/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.html index d26f3dbde..0b5152b49 100644 --- a/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.html +++ b/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.html @@ -28,11 +28,13 @@ @if (isCheckboxEnabled) { - + (click)="captureMouseEvent($event)" + [ngModel]="isSelected" + (onChange)="toggleSelection($event)"> + } @if (progressPercentage !== null) { diff --git a/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.ts b/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.ts index 83e764e61..1b48624b0 100644 --- a/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.ts +++ b/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.ts @@ -6,7 +6,7 @@ import {ConfirmationService, MenuItem, MessageService} from 'primeng/api'; import {DialogService} from 'primeng/dynamicdialog'; import {ShelfAssignerComponent} from '../../shelf-assigner/shelf-assigner.component'; import {BookService} from '../../../service/book.service'; -import {CheckboxModule} from 'primeng/checkbox'; +import {CheckboxChangeEvent, CheckboxModule} from 'primeng/checkbox'; import {FormsModule} from '@angular/forms'; import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component'; import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum'; @@ -89,22 +89,6 @@ export class BookCardComponent implements OnInit { this.bookService.readBook(book.id); } - toggleSelection(selected: boolean, event?: MouseEvent): void { - if (this.isCheckboxEnabled) { - this.isSelected = selected; - this.checkboxClick.emit({ - index: this.index, - bookId: this.book.id, - selected, - shiftKey: !!event?.shiftKey, - }); - - if (this.onBookSelect) { - this.onBookSelect(this.book.id, selected); - } - } - } - private initMenu() { this.items = [ { @@ -328,4 +312,27 @@ export class BookCardComponent implements OnInit { if (lockedKeys.length === 0) return false; return lockedKeys.every(key => metadata[key] === true); } + + private lastMouseEvent: MouseEvent | null = null; + + captureMouseEvent(event: MouseEvent): void { + this.lastMouseEvent = event; + } + + toggleSelection(event: CheckboxChangeEvent): void { + if (this.isCheckboxEnabled) { + this.isSelected = event.checked; + const shiftKey = this.lastMouseEvent?.shiftKey ?? false; + this.checkboxClick.emit({ + index: this.index, + bookId: this.book.id, + selected: event.checked, + shiftKey: shiftKey, + }); + if (this.onBookSelect) { + this.onBookSelect(this.book.id, event.checked); + } + this.lastMouseEvent = null; + } + } } diff --git a/booklore-ui/src/app/settings/global-preferences/global-preferences.component.html b/booklore-ui/src/app/settings/global-preferences/global-preferences.component.html index aa5622c82..82a16af68 100644 --- a/booklore-ui/src/app/settings/global-preferences/global-preferences.component.html +++ b/booklore-ui/src/app/settings/global-preferences/global-preferences.component.html @@ -45,42 +45,33 @@ -
-
-

Auto Book Search - - -

-
-

Enable:

-
- -
-
+
+

Auto Book Search + + +

+
+
-
-

Similar Book Recommendation - - -

-
-

Enable:

-
- -
-
+ +

Similar Book Recommendation + + +

+
+