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 {
|
openShelfAssigner(): void {
|
||||||
this.dynamicDialogRef = this.dialogHelperService.openShelfAssigner(this.selectedBooks);
|
this.dynamicDialogRef = this.dialogHelperService.openShelfAssigner(this.selectedBooks);
|
||||||
|
this.dynamicDialogRef.onClose.subscribe(() => {
|
||||||
|
this.selectedBooks = new Set<number>();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
lockUnlockMetadata(): void {
|
lockUnlockMetadata(): void {
|
||||||
|
|||||||
@@ -28,11 +28,13 @@
|
|||||||
<p-button [hidden]="readButtonHidden" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
|
<p-button [hidden]="readButtonHidden" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
|
||||||
|
|
||||||
@if (isCheckboxEnabled) {
|
@if (isCheckboxEnabled) {
|
||||||
<input
|
<p-checkbox
|
||||||
type="checkbox"
|
[binary]="true"
|
||||||
class="select-checkbox"
|
class="select-checkbox"
|
||||||
[checked]="isSelected"
|
(click)="captureMouseEvent($event)"
|
||||||
(click)="toggleSelection(!isSelected, $event)">
|
[ngModel]="isSelected"
|
||||||
|
(onChange)="toggleSelection($event)">
|
||||||
|
</p-checkbox>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (progressPercentage !== null) {
|
@if (progressPercentage !== null) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {ConfirmationService, MenuItem, MessageService} from 'primeng/api';
|
|||||||
import {DialogService} from 'primeng/dynamicdialog';
|
import {DialogService} from 'primeng/dynamicdialog';
|
||||||
import {ShelfAssignerComponent} from '../../shelf-assigner/shelf-assigner.component';
|
import {ShelfAssignerComponent} from '../../shelf-assigner/shelf-assigner.component';
|
||||||
import {BookService} from '../../../service/book.service';
|
import {BookService} from '../../../service/book.service';
|
||||||
import {CheckboxModule} from 'primeng/checkbox';
|
import {CheckboxChangeEvent, CheckboxModule} from 'primeng/checkbox';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
import {MetadataFetchOptionsComponent} from '../../../metadata/metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||||
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
|
||||||
@@ -89,22 +89,6 @@ export class BookCardComponent implements OnInit {
|
|||||||
this.bookService.readBook(book.id);
|
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() {
|
private initMenu() {
|
||||||
this.items = [
|
this.items = [
|
||||||
{
|
{
|
||||||
@@ -328,4 +312,27 @@ export class BookCardComponent implements OnInit {
|
|||||||
if (lockedKeys.length === 0) return false;
|
if (lockedKeys.length === 0) return false;
|
||||||
return lockedKeys.every(key => metadata[key] === true);
|
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>
|
<p-divider></p-divider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-row gap-11 p-4">
|
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||||
<div>
|
<p class="text-lg pb-4">Auto Book Search
|
||||||
<p class="text-lg pb-4 ">Auto Book Search
|
<i class="pi pi-info-circle text-sky-600"
|
||||||
<i class="pi pi-info-circle text-sky-600"
|
pTooltip="Automatically attempts metadata matching when the book information panel is opened."
|
||||||
pTooltip="Automatically attempts metadata matching when the book information panel is opened."
|
tooltipPosition="right"
|
||||||
tooltipPosition="right"
|
style="cursor: pointer;">
|
||||||
style="cursor: pointer;">
|
</i>
|
||||||
</i>
|
</p>
|
||||||
</p>
|
<div class="flex gap-4 justify-start">
|
||||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
<p-toggleswitch
|
||||||
<p class=" py-1">Enable:</p>
|
[(ngModel)]="toggles.autoBookSearch"
|
||||||
<div class="flex gap-4 justify-start">
|
(onChange)="onToggleChange('autoBookSearch', $event.checked)"
|
||||||
<p-toggleswitch
|
/>
|
||||||
[(ngModel)]="toggles.autoBookSearch"
|
|
||||||
(onChange)="onToggleChange('autoBookSearch', $event.checked)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<p class="text-lg pb-4 ">Similar Book Recommendation
|
<p class="text-lg pb-4">Similar Book Recommendation
|
||||||
<i class="pi pi-info-circle text-sky-600"
|
<i class="pi pi-info-circle text-sky-600"
|
||||||
pTooltip="Enables or disables similar book recommendations based on your library."
|
pTooltip="Enables or disables similar book recommendations based on your library."
|
||||||
tooltipPosition="right"
|
tooltipPosition="right"
|
||||||
style="cursor: pointer;">
|
style="cursor: pointer;">
|
||||||
</i>
|
</i>
|
||||||
</p>
|
</p>
|
||||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
<div class="flex gap-2 justify-start">
|
||||||
<p class=" py-1">Enable:</p>
|
<p-toggleswitch
|
||||||
<div class="flex gap-4 justify-start">
|
[(ngModel)]="toggles.similarBookRecommendation"
|
||||||
<p-toggleswitch
|
(onChange)="onToggleChange('similarBookRecommendation', $event.checked)"
|
||||||
[(ngModel)]="toggles.similarBookRecommendation"
|
/>
|
||||||
(onChange)="onToggleChange('similarBookRecommendation', $event.checked)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user