Add “Unassigned” shelf view for books not in any shelf

This commit is contained in:
adityachandelgit
2025-05-15 21:11:33 -06:00
committed by Aditya Chandel
parent 22f10d0475
commit 4cb82d2ba7
6 changed files with 74 additions and 30 deletions
@@ -57,20 +57,32 @@ export class AppMenuComponent implements OnInit {
);
this.shelfMenu$ = this.shelfService.shelfState$.pipe(
map((state) => [
{
label: 'Shelves',
separator: false,
items: state.shelves?.map((shelf) => ({
menu: this.libraryShelfMenuService.initializeShelfMenuItems(shelf),
label: shelf.name,
type: 'Shelf',
icon: 'pi pi-' + shelf.icon,
routerLink: [`/shelf/${shelf.id}/books`],
bookCount$: this.shelfService.getBookCount(shelf.id ?? 0),
})) || [],
},
])
map((state) => {
const shelves = state.shelves?.map((shelf) => ({
menu: this.libraryShelfMenuService.initializeShelfMenuItems(shelf),
label: shelf.name,
type: 'Shelf',
icon: 'pi pi-' + shelf.icon,
routerLink: [`/shelf/${shelf.id}/books`],
bookCount$: this.shelfService.getBookCount(shelf.id ?? 0),
})) || [];
const unshelvedItem = {
label: 'Unshelved',
type: 'Shelf',
icon: 'pi pi-inbox',
routerLink: ['/unshelved-books'],
bookCount$: this.shelfService.getUnshelvedBookCount?.() ?? of(0),
};
return [
{
label: 'Shelves',
separator: false,
items: [unshelvedItem, ...shelves],
},
];
})
);
this.homeMenu$ = this.bookService.bookState$.pipe(
@@ -30,7 +30,7 @@
<span *ngIf="(item.routerLink && !item.items) && item.visible !== false">
<ng-container *ngIf="item.type === 'Library' || item.type === 'Shelf'">
<p-button
*ngIf="item.type !== 'Library' || canManipulateLibrary"
*ngIf="(item.type !== 'Library' || canManipulateLibrary) && item.label !== 'Unshelved'"
(click)="entitymenu.toggle($event)"
(mouseover)="hovered = true"
(mouseleave)="hovered = false"
@@ -46,12 +46,12 @@
<p-menu #entitymenu [model]="item.menu" [popup]="true" appendTo="body"></p-menu>
</ng-container>
<ng-container *ngIf="item.type === 'Library' && !canManipulateLibrary || item.type === 'All Books'">
<ng-container *ngIf="item.type === 'Library' && !canManipulateLibrary || item.type === 'All Books' || item.label === 'Unshelved'">
<p class="text-[var(--primary-color)] pr-1">
{{ (item.bookCount$ | async)?.toString() || '0' }}
</p>
</ng-container>
</span>
</span>
</div>
<ul *ngIf="item.items && item.visible !== false" [@children]="submenuAnimation">