- Implement close dialog via service
- More metadata styling
This commit is contained in:
@@ -69,7 +69,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>
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary" (onClick)="closeDialog()"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -105,4 +105,8 @@ export class BookDetailsComponent implements OnInit {
|
||||
coverImageSrc(bookId: number): string {
|
||||
return this.bookService.getBookCoverUrl(bookId);
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.bookInfoService.closeDialog(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,12 @@ export class BookInfoTabsComponent implements OnInit {
|
||||
if (initialBook?.metadata) {
|
||||
this.bookInfoService.emit(this.convertToBookMetadataBI(initialBook));
|
||||
}
|
||||
this.bookInfoService.dialogClose$.subscribe((close) => {
|
||||
if(close) {
|
||||
this.bookInfoService.closeDialog(false);
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private convertToBookMetadataBI(book: Book): BookMetadataBI {
|
||||
|
||||
@@ -7,10 +7,18 @@ import {BookMetadataBI} from '../book/model/book-metadata-for-book-info.model';
|
||||
})
|
||||
export class BookInfoService {
|
||||
|
||||
private subject = new BehaviorSubject<BookMetadataBI | null>(null);
|
||||
bookMetadata$ = this.subject.asObservable();
|
||||
private bookMetadataSubject = new BehaviorSubject<BookMetadataBI | null>(null);
|
||||
bookMetadata$ = this.bookMetadataSubject.asObservable();
|
||||
|
||||
private dialogCloseSubject = new BehaviorSubject<boolean | null>(null);
|
||||
dialogClose$ = this.dialogCloseSubject.asObservable();
|
||||
|
||||
|
||||
emit(bookMetadata: BookMetadataBI) {
|
||||
this.subject.next(bookMetadata);
|
||||
this.bookMetadataSubject.next(bookMetadata);
|
||||
}
|
||||
|
||||
closeDialog(close: boolean) {
|
||||
return this.dialogCloseSubject.next(close);
|
||||
}
|
||||
}
|
||||
|
||||
+30
-30
@@ -5,12 +5,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="title" formControlName="title" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('title') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('title') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('title')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('title'), 'yellow-outlined-button': isValueCopied('title')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('title')"/>
|
||||
<input pInputText [value]="fetchedMetadata.title" class="input"/>
|
||||
<input pInputText [value]="fetchedMetadata.title" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="authors" formControlName="authors" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('authors') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('authors') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('authors')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('authors'), 'yellow-outlined-button': isValueCopied('authors')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('authors')"/>
|
||||
<input pInputText [value]="fetchedAuthorsString()" class="input"/>
|
||||
<input pInputText [value]="fetchedAuthorsString()" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="categories" formControlName="categories" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('categories') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('categories') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('categories')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('categories'), 'yellow-outlined-button': isValueCopied('categories')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('categories')"/>
|
||||
<input pInputText [value]="fetchedCategoriesString()" class="input"/>
|
||||
<input pInputText [value]="fetchedCategoriesString()" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -47,12 +47,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="publisher" formControlName="publisher" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('publisher') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('publisher') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('publisher')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('publisher'), 'yellow-outlined-button': isValueCopied('publisher')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('publisher')"/>
|
||||
<input pInputText [value]="fetchedMetadata.publisher" class="input"/>
|
||||
<input pInputText [value]="fetchedMetadata.publisher" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -61,12 +61,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="publishedDate" formControlName="publishedDate" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('publishedDate') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('publishedDate') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('publishedDate')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('publishedDate'), 'yellow-outlined-button': isValueCopied('publishedDate')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('publishedDate')"/>
|
||||
<input pInputText [value]="fetchedMetadata.publishedDate" class="input"/>
|
||||
<input pInputText [value]="fetchedMetadata.publishedDate" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -75,12 +75,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="isbn10" formControlName="isbn10" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('isbn10') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('isbn10') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('isbn10')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('isbn10'), 'yellow-outlined-button': isValueCopied('isbn10')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('isbn10')"/>
|
||||
<input pInputText [value]="fetchedMetadata.isbn10" class="input"/>
|
||||
<input pInputText [value]="fetchedMetadata.isbn10" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -89,12 +89,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="language" formControlName="language" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('language') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('language') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('language')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('language'), 'yellow-outlined-button': isValueCopied('language')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('language')"/>
|
||||
<input pInputText [value]="fetchedMetadata.language" class="input"/>
|
||||
<input pInputText [value]="fetchedMetadata.language" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -103,12 +103,12 @@
|
||||
<div class="input-container">
|
||||
<input pInputText id="pageCount" formControlName="pageCount" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueCopied('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('pageCount')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('pageCount'), 'yellow-outlined-button': isValueCopied('pageCount')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('pageCount')"/>
|
||||
<input pInputText [value]="fetchedMetadata.pageCount" class="input"/>
|
||||
<input pInputText [value]="fetchedMetadata.pageCount" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -117,12 +117,12 @@
|
||||
<div class="input-container">
|
||||
<textarea id="description" formControlName="description" class="input"></textarea>
|
||||
<p-button
|
||||
[icon]="isValueCopied('description') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="isValueSaved('description') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueCopied('description')}"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('description'), 'yellow-outlined-button': isValueCopied('description')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('description')"/>
|
||||
<textarea [value]="fetchedMetadata.description" class="input"></textarea>
|
||||
<textarea [value]="fetchedMetadata.description" class="input" readonly></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -132,9 +132,9 @@
|
||||
<img *ngIf="!updateThumbnailUrl" [src]="coverImageSrc(currentBookId)" alt="Book Thumbnail" class="thumbnail"/>
|
||||
<img *ngIf="updateThumbnailUrl" [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
<p-button
|
||||
[icon]="updateThumbnailUrl ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[icon]="thumbnailSaved ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': updateThumbnailUrl}"
|
||||
[ngClass]="{'green-outlined-button': thumbnailSaved, 'yellow-outlined-button': updateThumbnailUrl}"
|
||||
class="arrow-button"
|
||||
(click)="shouldUpdateThumbnail()"/>
|
||||
<img [src]="fetchedMetadata.thumbnailUrl" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||
@@ -147,7 +147,7 @@
|
||||
<div class="flex justify-between">
|
||||
<p-button label="Back" icon="pi pi-arrow-left" severity="info" (onClick)="goBackClick()"></p-button>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary"></p-button>
|
||||
<p-button label="Cancel" icon="pi pi-times" severity="secondary" (onClick)="closeDialog()"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" severity="primary" type="submit"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+6
-3
@@ -1,9 +1,7 @@
|
||||
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
margin-bottom: 0.75rem;
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
@@ -41,6 +39,11 @@
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
.yellow-outlined-button {
|
||||
--p-button-outlined-primary-border-color: yellow;
|
||||
--p-button-outlined-primary-color: yellow;
|
||||
}
|
||||
|
||||
.green-outlined-button {
|
||||
--p-button-outlined-primary-border-color: limegreen;
|
||||
--p-button-outlined-primary-color: limegreen;
|
||||
|
||||
+31
-13
@@ -1,15 +1,15 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FetchedMetadata } from '../../book/model/book.model';
|
||||
import { BookService } from '../../book/service/book.service';
|
||||
import { MessageService } from 'primeng/api';
|
||||
import { Button } from 'primeng/button';
|
||||
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { InputText } from 'primeng/inputtext';
|
||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||
import {FetchedMetadata} from '../../book/model/book.model';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {NgClass, NgIf} from '@angular/common';
|
||||
import { Divider } from 'primeng/divider';
|
||||
import { BookInfoService } from '../book-info.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { BookMetadataBI } from '../../book/model/book-metadata-for-book-info.model';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {BookInfoService} from '../book-info.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {BookMetadataBI} from '../../book/model/book-metadata-for-book-info.model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-searcher',
|
||||
@@ -35,7 +35,9 @@ export class MetadataSearcherComponent implements OnInit {
|
||||
bookMetadata$: Observable<BookMetadataBI | null>;
|
||||
currentBookId!: number;
|
||||
updateThumbnailUrl: boolean = false;
|
||||
thumbnailSaved: boolean = false;
|
||||
copiedFields: { [key: string]: boolean } = {};
|
||||
savedFields: { [key: string]: boolean } = {};
|
||||
|
||||
constructor(private bookService: BookService, private bookInfoService: BookInfoService, private messageService: MessageService) {
|
||||
this.bookMetadata$ = this.bookInfoService.bookMetadata$;
|
||||
@@ -68,7 +70,7 @@ export class MetadataSearcherComponent implements OnInit {
|
||||
publishedDate: bookMetadata.publishedDate,
|
||||
isbn10: bookMetadata.isbn10,
|
||||
isbn13: bookMetadata.isbn13,
|
||||
asin: bookMetadata.asin ? bookMetadata.asin : null,
|
||||
asin: bookMetadata.asin ? bookMetadata.asin : null,
|
||||
description: bookMetadata.description,
|
||||
pageCount: bookMetadata.pageCount == 0 ? null : bookMetadata.pageCount,
|
||||
language: bookMetadata.language
|
||||
@@ -109,6 +111,14 @@ export class MetadataSearcherComponent implements OnInit {
|
||||
|
||||
this.bookService.updateMetadata(updatedBookMetadata.bookId, updatedBookMetadata).subscribe({
|
||||
next: () => {
|
||||
Object.keys(this.copiedFields).forEach((field) => {
|
||||
if (this.copiedFields[field]) {
|
||||
this.savedFields[field] = true;
|
||||
}
|
||||
});
|
||||
if (this.updateThumbnailUrl) {
|
||||
this.thumbnailSaved = true;
|
||||
}
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
this.bookInfoService.emit(updatedBookMetadata);
|
||||
},
|
||||
@@ -160,14 +170,22 @@ export class MetadataSearcherComponent implements OnInit {
|
||||
}
|
||||
|
||||
highlightCopiedInput(field: string): void {
|
||||
this.copiedFields = { ...this.copiedFields, [field]: true };
|
||||
this.copiedFields = {...this.copiedFields, [field]: true};
|
||||
}
|
||||
|
||||
isValueCopied(field: string): boolean {
|
||||
return this.copiedFields[field];
|
||||
}
|
||||
|
||||
isValueSaved(field: string): boolean {
|
||||
return this.savedFields[field];
|
||||
}
|
||||
|
||||
goBackClick() {
|
||||
this.goBack.emit(true);
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.bookInfoService.closeDialog(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import {Button} from 'primeng/button';
|
||||
import {AppConfiguratorComponent} from '../configurator/configurator.component';
|
||||
import {StyleClass} from 'primeng/styleclass';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {BookInfoTabsComponent} from '../../../book-info-tabs/book-info-tabs.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topbar',
|
||||
|
||||
Reference in New Issue
Block a user