From 2f816bd5dc636b8b11c5c97fde67d878fbb2e03b Mon Sep 17 00:00:00 2001 From: "aditya.chandel" <> Date: Tue, 24 Dec 2024 13:13:19 -0700 Subject: [PATCH] Add entity type to title. Todo: Fix menu. --- .../books-browser/books-browser.component.html | 2 +- .../books-browser/books-browser.component.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/booklore-ui/src/app/book/component/books-browser/books-browser.component.html b/booklore-ui/src/app/book/component/books-browser/books-browser.component.html index ac7635b7d..d18dbea3d 100644 --- a/booklore-ui/src/app/book/component/books-browser/books-browser.component.html +++ b/booklore-ui/src/app/book/component/books-browser/books-browser.component.html @@ -1,6 +1,6 @@
-

{{ (entity$ | async)?.name }}

+

{{ (entityType$ | async) }}: {{ (entity$ | async)?.name }}

| undefined; entity$: Observable | undefined; + entityType$: Observable | undefined; items: MenuItem[] | undefined; constructor( @@ -38,8 +39,6 @@ export class BooksBrowserComponent implements OnInit { map(params => { const libraryId = Number(params.get('libraryId')); const shelfId = Number(params.get('shelfId')); - - console.log(shelfId + '---' + libraryId) return {libraryId, shelfId}; }) ); @@ -75,6 +74,18 @@ export class BooksBrowserComponent implements OnInit { }) ); + this.entityType$ = routeParam$.pipe( + switchMap(({libraryId, shelfId}) => { + if (!isNaN(libraryId) && libraryId !== 0) { + return of('Library'); + } else if (!isNaN(shelfId) && shelfId !== 0) { + return of('Shelf'); + } + return of(null); + }) + ); + + //this.initializeMenuItems(); }