diff --git a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.html b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.html index 8388834b2..5baf974de 100644 --- a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.html +++ b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.html @@ -13,11 +13,21 @@ -
+
-
- Book Cover - {{ book.metadata?.title }} +
+
+ Book Cover +
+
+

{{ book.metadata?.title | slice:0:70 }}

+
+
+

by: {{ getAuthorNames(book.metadata?.authors) }}

+
+
+
+
diff --git a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.scss b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.scss index 34a17abff..3bb6c9c36 100644 --- a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.scss +++ b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.scss @@ -57,7 +57,6 @@ .search-dropdown-item { display: flex; align-items: center; - padding: 10px; cursor: pointer; transition: background-color 0.3s; @@ -67,18 +66,11 @@ } .search-book-cover { - width: 25px; - height: 37px; + width: 35px; + height: 47px; object-fit: cover; max-width: 100px; max-height: 150px; border-radius: 4px; margin-right: 10px; } - -.search-book-name { - font-size: 14px; - font-weight: 500; - color: var(--text-color); - flex-grow: 1; -} diff --git a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts index 5ce1f2d76..cbd954418 100644 --- a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts +++ b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts @@ -1,13 +1,14 @@ import {Component, inject, OnDestroy, OnInit} from '@angular/core'; import {Subject, Subscription} from 'rxjs'; import {catchError, debounceTime, distinctUntilChanged, switchMap} from 'rxjs/operators'; -import {Book} from '../../model/book.model'; +import {Author, Book} from '../../model/book.model'; import {FormsModule} from '@angular/forms'; import {InputTextModule} from 'primeng/inputtext'; import {BookService} from '../../service/book.service'; import {Button} from 'primeng/button'; -import {NgForOf, NgIf} from '@angular/common'; +import {NgForOf, NgIf, SlicePipe} from '@angular/common'; import {MetadataDialogService} from '../../../metadata/service/metadata-dialog.service'; +import {Divider} from 'primeng/divider'; @Component({ selector: 'app-book-searcher', @@ -17,7 +18,9 @@ import {MetadataDialogService} from '../../../metadata/service/metadata-dialog.s InputTextModule, Button, NgIf, - NgForOf + NgForOf, + SlicePipe, + Divider ], styleUrls: ['./book-searcher.component.scss'], standalone: true @@ -52,6 +55,14 @@ export class BookSearcherComponent implements OnInit, OnDestroy { }); } + getLibraryName(libraryId: number): string { + return `${libraryId}`; + } + + getAuthorNames(authors: Author[] | undefined): string { + return authors?.map(author => author.name).join(', ') || 'Unknown Author'; + } + onSearchInputChange(): void { this.#searchSubject.next(this.searchQuery.trim()); } diff --git a/booklore-ui/src/app/book/service/book.service.ts b/booklore-ui/src/app/book/service/book.service.ts index d53dff8b8..1a28a97bf 100644 --- a/booklore-ui/src/app/book/service/book.service.ts +++ b/booklore-ui/src/app/book/service/book.service.ts @@ -139,7 +139,8 @@ export class BookService { return this.bookState$.pipe( map(state => (state.books || []).filter(book => - book.metadata?.title?.toLowerCase().includes(query.toLowerCase()) + (book.metadata?.title?.toLowerCase().includes(query.toLowerCase()) || + book.metadata?.authors.some(author => author.name.toLowerCase().includes(query.toLowerCase()))) ) ) );