Bubble up dialog close
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<div class="flex flex-grow w-full justify-between gap-4">
|
||||
<div class="w-1/3 flex justify-center items-center pt-4 pr-4 pb-4">
|
||||
<p-image src="https://m.media-amazon.com/images/I/61GzazUmKyL._SL1462_.jpg" alt="Image" width="250"/>
|
||||
<p-image [src]="coverImageSrc(bookId)" alt="Image" width="250"/>
|
||||
</div>
|
||||
<div class="w-2/3 space-y-2">
|
||||
<div class="flex flex-col gap-1 w-full">
|
||||
@@ -81,7 +81,7 @@
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary"/>
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary" (onClick)="closeDialog.emit()"/>
|
||||
<p-button label="Save" icon="pi pi-check" (onClick)="onSave()"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||
import { InputText } from 'primeng/inputtext';
|
||||
import { Textarea } from 'primeng/textarea';
|
||||
import { Image } from 'primeng/image';
|
||||
import { Button } from 'primeng/button';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { BookMetadataForm } from '../../book/model/book-metadata-form';
|
||||
import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {Image} from 'primeng/image';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {BookMetadataForm} from '../../book/model/book-metadata-form';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-details',
|
||||
standalone: true,
|
||||
templateUrl: './book-details.component.html',
|
||||
styleUrl: './book-details.component.scss',
|
||||
imports: [
|
||||
InputText,
|
||||
Textarea,
|
||||
@@ -18,17 +20,22 @@ import { BookMetadataForm } from '../../book/model/book-metadata-form';
|
||||
Button,
|
||||
Divider,
|
||||
FormsModule
|
||||
],
|
||||
styleUrl: './book-details.component.scss'
|
||||
]
|
||||
})
|
||||
export class BookDetailsComponent implements OnChanges {
|
||||
|
||||
@Input() bookForm!: BookMetadataForm;
|
||||
@Input() bookId!: number;
|
||||
@Output() save = new EventEmitter<BookMetadataForm>();
|
||||
@Output() closeDialog = new EventEmitter<unknown>();
|
||||
|
||||
authorsInput: string = '';
|
||||
categoriesInput: string = '';
|
||||
|
||||
|
||||
constructor(private bookService: BookService) {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (this.bookForm.authors) {
|
||||
this.authorsInput = this.bookForm.authors.join(', ');
|
||||
@@ -59,4 +66,8 @@ export class BookDetailsComponent implements OnChanges {
|
||||
this.bookForm.categories = this.categoriesInput.split(',').map(category => category.trim());
|
||||
}
|
||||
}
|
||||
|
||||
coverImageSrc(bookId: number) {
|
||||
return this.bookService.getBookCoverUrl(bookId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user