Instead of navigating to book details via the router, use dialog instead
This commit is contained in:
@@ -119,8 +119,6 @@ export class BookCardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openBookInfo(book: Book): void {
|
openBookInfo(book: Book): void {
|
||||||
setTimeout(() => {
|
this.openBookDetailsDialog(book.id)
|
||||||
this.router.navigate(['/library', book.libraryId, 'book', book.id, 'info']);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import {NgForOf, NgIf} from '@angular/common';
|
|||||||
import {Button} from 'primeng/button';
|
import {Button} from 'primeng/button';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {BookService} from '../../service/book.service';
|
import {BookService} from '../../service/book.service';
|
||||||
|
import {BookMetadataCenterComponent} from '../../../book-metadata-center/book-metadata-center.component';
|
||||||
|
import {DialogService} from 'primeng/dynamicdialog';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-search',
|
selector: 'app-search',
|
||||||
@@ -27,7 +29,7 @@ export class SearchComponent implements OnInit, OnDestroy {
|
|||||||
#searchSubject = new Subject<string>();
|
#searchSubject = new Subject<string>();
|
||||||
#subscription!: Subscription;
|
#subscription!: Subscription;
|
||||||
|
|
||||||
constructor(private bookService: BookService, private router: Router) {}
|
constructor(private bookService: BookService, private router: Router, private dialogService: DialogService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.initializeSearch();
|
this.initializeSearch();
|
||||||
@@ -55,11 +57,29 @@ export class SearchComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
onBookClick(book: Book): void {
|
onBookClick(book: Book): void {
|
||||||
this.clearSearch();
|
this.clearSearch();
|
||||||
this.openBook(book.id, book.libraryId);
|
this.openBook(book.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
openBook(bookId: number, libraryId: number): void {
|
openBook(bookId: number): void {
|
||||||
this.router.navigate(['/library', libraryId, 'book', bookId, 'info']);
|
this.bookService.getBookByIdFromAPI(bookId, true).subscribe(({
|
||||||
|
next: (book) => {
|
||||||
|
this.dialogService.open(BookMetadataCenterComponent, {
|
||||||
|
header: 'Open book details',
|
||||||
|
modal: true,
|
||||||
|
closable: true,
|
||||||
|
width: '1200px',
|
||||||
|
height: '835px',
|
||||||
|
showHeader: false,
|
||||||
|
closeOnEscape: true,
|
||||||
|
data: {
|
||||||
|
book: book
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.error('Error fetching book:', error);
|
||||||
|
}
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
getBookCoverUrl(bookId: number): string {
|
getBookCoverUrl(bookId: number): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user