This commit is contained in:
aditya.chandel
2024-12-25 22:52:58 -07:00
parent f27470b901
commit 5b763c01ab
2 changed files with 11 additions and 28 deletions
@@ -2,7 +2,7 @@
<div class="library-header-dial"> <div class="library-header-dial">
<h3 class="library-name">{{ (entityType$ | async) }}: {{ (entity$ | async)?.name }}</h3> <h3 class="library-name">{{ (entityType$ | async) }}: {{ (entity$ | async)?.name }}</h3>
<p-speedDial <p-speedDial
[model]="items!" [model]="speedDialItems!"
direction="right" direction="right"
transitionDelay="80" transitionDelay="80"
showIcon="pi pi-ellipsis-v" showIcon="pi pi-ellipsis-v"
@@ -17,7 +17,7 @@
<p-button *ngIf="(entityType$ | async) === 'Shelf'" icon="pi pi-minus-circle" label="Unshelf" severity="primary" [rounded]="true" [outlined]="true" (click)="unshelfBooks()"></p-button> <p-button *ngIf="(entityType$ | async) === 'Shelf'" icon="pi pi-minus-circle" label="Unshelf" severity="primary" [rounded]="true" [outlined]="true" (click)="unshelfBooks()"></p-button>
<p-button icon="pi pi-times" label="Deselect" severity="warning" [rounded]="true" [outlined]="true" (click)="deselectAllBooks()"></p-button> <p-button icon="pi pi-times" label="Deselect" severity="warning" [rounded]="true" [outlined]="true" (click)="deselectAllBooks()"></p-button>
</div> </div>
<p-menu #menu [model]="items" [popup]="true" appendTo="body"></p-menu> <p-menu #menu [model]="multiSelectItems" [popup]="true" appendTo="body"></p-menu>
</div> </div>
<div class="library-header-right"> <div class="library-header-right">
@@ -28,7 +28,8 @@ export class BooksBrowserComponent implements OnInit {
entity: Library | Shelf | null = null; entity: Library | Shelf | null = null;
entityType: string = ''; entityType: string = '';
items: MenuItem[] | undefined; speedDialItems: MenuItem[] | undefined;
multiSelectItems: MenuItem[] | undefined;
selectedBooks: Set<number> = new Set(); selectedBooks: Set<number> = new Set();
selectedSort: SortOption | null = null; selectedSort: SortOption | null = null;
sortOptions: SortOption[] = []; sortOptions: SortOption[] = [];
@@ -182,7 +183,7 @@ export class BooksBrowserComponent implements OnInit {
} }
setupMenu(): void { setupMenu(): void {
this.items = [ this.multiSelectItems = [
{ {
label: 'Options', label: 'Options',
items: [ items: [
@@ -210,7 +211,7 @@ export class BooksBrowserComponent implements OnInit {
} }
private initializeLibraryMenuItems(): void { private initializeLibraryMenuItems(): void {
this.items = [ this.speedDialItems = [
{ {
icon: 'pi pi-trash', icon: 'pi pi-trash',
tooltipOptions: { tooltipOptions: {
@@ -229,19 +230,10 @@ export class BooksBrowserComponent implements OnInit {
this.libraryService.deleteLibrary(this.entity?.id!).subscribe({ this.libraryService.deleteLibrary(this.entity?.id!).subscribe({
complete: () => { complete: () => {
this.router.navigate(['/']); this.router.navigate(['/']);
this.messageService.add({ this.messageService.add({severity: 'info', summary: 'Success', detail: 'Library was deleted'});
severity: 'info',
summary: 'Success',
detail: 'Library was deleted'
});
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({severity: 'error', summary: 'Failed', detail: 'Failed to delete library', life: 3000});
severity: 'error',
summary: 'Failed',
detail: 'Failed to delete library',
life: 3000
});
} }
}); });
} }
@@ -252,7 +244,7 @@ export class BooksBrowserComponent implements OnInit {
} }
private initializeShelfMenuItems(): void { private initializeShelfMenuItems(): void {
this.items = [ this.speedDialItems = [
{ {
icon: 'pi pi-trash', icon: 'pi pi-trash',
tooltipOptions: { tooltipOptions: {
@@ -271,19 +263,10 @@ export class BooksBrowserComponent implements OnInit {
this.shelfService.deleteShelf(this.entity?.id!).subscribe({ this.shelfService.deleteShelf(this.entity?.id!).subscribe({
complete: () => { complete: () => {
this.router.navigate(['/']); this.router.navigate(['/']);
this.messageService.add({ this.messageService.add({severity: 'info', summary: 'Success', detail: 'Shelf was deleted'});
severity: 'info',
summary: 'Success',
detail: 'Shelf was deleted'
});
}, },
error: () => { error: () => {
this.messageService.add({ this.messageService.add({severity: 'error', summary: 'Failed', detail: 'Failed to delete shelf', life: 3000});
severity: 'error',
summary: 'Failed',
detail: 'Failed to delete shelf',
life: 3000
});
} }
}); });
} }