mirror of
https://github.com/adityachandelgit/BookLore.git
synced 2025-07-29 12:50:05 +00:00
fix: clear selected books after assigning to a shelf
This commit is contained in:

committed by
Aditya Chandel

parent
9b589748ac
commit
b76c0023ba
@ -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<number>();
|
||||
});
|
||||
}
|
||||
|
||||
lockUnlockMetadata(): void {
|
||||
|
@ -28,11 +28,13 @@
|
||||
<p-button [hidden]="readButtonHidden" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
|
||||
|
||||
@if (isCheckboxEnabled) {
|
||||
<input
|
||||
type="checkbox"
|
||||
<p-checkbox
|
||||
[binary]="true"
|
||||
class="select-checkbox"
|
||||
[checked]="isSelected"
|
||||
(click)="toggleSelection(!isSelected, $event)">
|
||||
(click)="captureMouseEvent($event)"
|
||||
[ngModel]="isSelected"
|
||||
(onChange)="toggleSelection($event)">
|
||||
</p-checkbox>
|
||||
}
|
||||
|
||||
@if (progressPercentage !== null) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,42 +45,33 @@
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row gap-11 p-4">
|
||||
<div>
|
||||
<p class="text-lg pb-4 ">Auto Book Search
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Automatically attempts metadata matching when the book information panel is opened."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class=" py-1">Enable:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="toggles.autoBookSearch"
|
||||
(onChange)="onToggleChange('autoBookSearch', $event.checked)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class="text-lg pb-4">Auto Book Search
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Automatically attempts metadata matching when the book information panel is opened."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="toggles.autoBookSearch"
|
||||
(onChange)="onToggleChange('autoBookSearch', $event.checked)"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-lg pb-4 ">Similar Book Recommendation
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Enables or disables similar book recommendations based on your library."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class=" py-1">Enable:</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="toggles.similarBookRecommendation"
|
||||
(onChange)="onToggleChange('similarBookRecommendation', $event.checked)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-lg pb-4">Similar Book Recommendation
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Enables or disables similar book recommendations based on your library."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-2 justify-start">
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="toggles.similarBookRecommendation"
|
||||
(onChange)="onToggleChange('similarBookRecommendation', $event.checked)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user