This commit is contained in:
+71
-53
@@ -38,63 +38,81 @@
|
||||
|
||||
<div class="gradient-divider"></div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group highlight-group flex-2">
|
||||
<label for="title" class="form-label">
|
||||
<i class="pi pi-tag label-icon"></i>
|
||||
{{ t('titleLabel') }}
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
<input
|
||||
id="title"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="title"
|
||||
class="input-full"
|
||||
[placeholder]="t('titlePlaceholder')"
|
||||
[class.filled]="title.trim()"/>
|
||||
<div class="top-section">
|
||||
@if (coverUrl) {
|
||||
<div class="cover-preview">
|
||||
<img [src]="coverUrl" alt="Book cover"/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="isbn" class="form-label">
|
||||
<i class="pi pi-barcode label-icon"></i>
|
||||
{{ t('isbnLabel') }}
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
<input
|
||||
id="isbn"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="isbn"
|
||||
class="input-full"
|
||||
[placeholder]="t('isbnPlaceholder')"/>
|
||||
<div class="top-fields">
|
||||
<div class="form-row">
|
||||
<div class="form-group highlight-group flex-2">
|
||||
<label for="title" class="form-label">
|
||||
<i class="pi pi-tag label-icon"></i>
|
||||
{{ t('titleLabel') }}
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
<input
|
||||
id="title"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="title"
|
||||
class="input-full"
|
||||
[placeholder]="t('titlePlaceholder')"
|
||||
[class.filled]="title.trim()"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="isbn" class="form-label">
|
||||
<i class="pi pi-barcode label-icon"></i>
|
||||
{{ t('isbnLabel') }}
|
||||
</label>
|
||||
<div class="isbn-input-row">
|
||||
<input
|
||||
id="isbn"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="isbn"
|
||||
class="input-full"
|
||||
[placeholder]="t('isbnPlaceholder')"/>
|
||||
<p-button
|
||||
icon="pi pi-search"
|
||||
[rounded]="true"
|
||||
[text]="true"
|
||||
severity="info"
|
||||
(onClick)="fetchMetadataByIsbn()"
|
||||
[disabled]="!isbn.trim() || isFetchingMetadata"
|
||||
[loading]="isFetchingMetadata"
|
||||
[pTooltip]="t('fetchMetadataTooltip')"
|
||||
tooltipPosition="top"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gradient-divider"></div>
|
||||
|
||||
<div class="form-group highlight-group">
|
||||
<label for="authors" class="form-label">
|
||||
<i class="pi pi-user label-icon"></i>
|
||||
{{ t('authorsLabel') }}
|
||||
</label>
|
||||
<div class="autocomplete-wrapper">
|
||||
<p-autoComplete
|
||||
appendTo="body"
|
||||
[(ngModel)]="authors"
|
||||
[multiple]="true"
|
||||
[fluid]="true"
|
||||
[dropdown]="false"
|
||||
[suggestions]="filteredAuthors"
|
||||
[forceSelection]="false"
|
||||
[showClear]="false"
|
||||
[placeholder]="t('authorsPlaceholder')"
|
||||
(completeMethod)="filterAuthors($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('authors', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('authors', $event)">
|
||||
</p-autoComplete>
|
||||
<div class="form-group highlight-group">
|
||||
<label for="authors" class="form-label">
|
||||
<i class="pi pi-user label-icon"></i>
|
||||
{{ t('authorsLabel') }}
|
||||
</label>
|
||||
<div class="autocomplete-wrapper">
|
||||
<p-autoComplete
|
||||
appendTo="body"
|
||||
[(ngModel)]="authors"
|
||||
[multiple]="true"
|
||||
[fluid]="true"
|
||||
[dropdown]="false"
|
||||
[suggestions]="filteredAuthors"
|
||||
[forceSelection]="false"
|
||||
[showClear]="false"
|
||||
[placeholder]="t('authorsPlaceholder')"
|
||||
(completeMethod)="filterAuthors($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('authors', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('authors', $event)">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+48
@@ -106,6 +106,54 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.isbn-input-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
|
||||
.input-full {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.top-section {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: flex-start;
|
||||
|
||||
@media (max-width: 640px) {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.top-fields {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.cover-preview {
|
||||
flex-shrink: 0;
|
||||
padding: 0.5rem;
|
||||
|
||||
img {
|
||||
height: 180px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
img {
|
||||
height: 150px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.autocomplete-wrapper {
|
||||
width: 100%;
|
||||
|
||||
|
||||
+30
-1
@@ -9,6 +9,7 @@ import {Textarea} from 'primeng/textarea';
|
||||
import {InputNumber} from 'primeng/inputnumber';
|
||||
import {AutoComplete, AutoCompleteCompleteEvent} from 'primeng/autocomplete';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {BookMetadataService} from '../../service/book-metadata.service';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
import {Library} from '../../model/library.model';
|
||||
import {CreatePhysicalBookRequest} from '../../model/book.model';
|
||||
@@ -37,6 +38,7 @@ export class AddPhysicalBookDialogComponent implements OnInit {
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dialogConfig = inject(DynamicDialogConfig);
|
||||
private bookService = inject(BookService);
|
||||
private bookMetadataService = inject(BookMetadataService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
|
||||
@@ -57,7 +59,9 @@ export class AddPhysicalBookDialogComponent implements OnInit {
|
||||
filteredAuthors: string[] = [];
|
||||
filteredCategories: string[] = [];
|
||||
|
||||
coverUrl: string | null = null;
|
||||
isLoading: boolean = false;
|
||||
isFetchingMetadata: boolean = false;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.libraryService.libraryState$
|
||||
@@ -131,6 +135,30 @@ export class AddPhysicalBookDialogComponent implements OnInit {
|
||||
(event.originalEvent.target as HTMLInputElement).value = '';
|
||||
}
|
||||
|
||||
fetchMetadataByIsbn(): void {
|
||||
const isbnValue = this.isbn.trim();
|
||||
if (!isbnValue || this.isFetchingMetadata) return;
|
||||
|
||||
this.isFetchingMetadata = true;
|
||||
this.bookMetadataService.lookupByIsbn(isbnValue).subscribe({
|
||||
next: (metadata) => {
|
||||
if (metadata.title) this.title = metadata.title;
|
||||
if (metadata.authors?.length) this.authors = [...metadata.authors];
|
||||
if (metadata.description) this.description = metadata.description;
|
||||
if (metadata.publisher) this.publisher = metadata.publisher;
|
||||
if (metadata.publishedDate) this.publishedDate = metadata.publishedDate;
|
||||
if (metadata.language) this.language = metadata.language;
|
||||
if (metadata.pageCount) this.pageCount = metadata.pageCount;
|
||||
if (metadata.categories?.length) this.categories = [...metadata.categories];
|
||||
this.coverUrl = metadata.thumbnailUrl || null;
|
||||
this.isFetchingMetadata = false;
|
||||
},
|
||||
error: () => {
|
||||
this.isFetchingMetadata = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
this.dynamicDialogRef.close();
|
||||
}
|
||||
@@ -154,7 +182,8 @@ export class AddPhysicalBookDialogComponent implements OnInit {
|
||||
publishedDate: this.publishedDate.trim() || undefined,
|
||||
language: this.language.trim() || undefined,
|
||||
pageCount: this.pageCount ?? undefined,
|
||||
categories: this.categories.length > 0 ? this.categories : undefined
|
||||
categories: this.categories.length > 0 ? this.categories : undefined,
|
||||
thumbnailUrl: this.coverUrl || undefined
|
||||
};
|
||||
|
||||
this.bookService.createPhysicalBook(request).subscribe({
|
||||
|
||||
@@ -413,6 +413,7 @@ export interface CreatePhysicalBookRequest {
|
||||
language?: string;
|
||||
pageCount?: number;
|
||||
categories?: string[];
|
||||
thumbnailUrl?: string;
|
||||
}
|
||||
|
||||
export interface BookStatusUpdateResponse {
|
||||
|
||||
@@ -57,4 +57,8 @@ export class BookMetadataService {
|
||||
fetchMetadataDetail(provider: string, providerItemId: string): Observable<BookMetadata> {
|
||||
return this.http.get<BookMetadata>(`${this.url}/metadata/detail/${provider}/${providerItemId}`);
|
||||
}
|
||||
|
||||
lookupByIsbn(isbn: string): Observable<BookMetadata> {
|
||||
return this.http.post<BookMetadata>(`${this.url}/metadata/isbn-lookup`, {isbn});
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -593,9 +593,8 @@
|
||||
<p-button
|
||||
icon="pi pi-chevron-left"
|
||||
[disabled]="!canNavigatePrevious()"
|
||||
(onClick)="navigatePrevious()"
|
||||
rounded
|
||||
text
|
||||
(onClick)="navigatePrevious()"`
|
||||
outlined
|
||||
severity="secondary"
|
||||
[pTooltip]="t('goToPreviousBook')"
|
||||
tooltipPosition="bottom">
|
||||
@@ -609,8 +608,7 @@
|
||||
[disabled]="!canNavigateNext()"
|
||||
(onClick)="navigateNext()"
|
||||
severity="secondary"
|
||||
rounded
|
||||
text
|
||||
outlined
|
||||
[pTooltip]="t('goToNextBook')"
|
||||
tooltipPosition="bottom">
|
||||
</p-button>
|
||||
|
||||
@@ -429,7 +429,8 @@
|
||||
"validationTitleOrIsbn": "Title or ISBN is required",
|
||||
"validationReady": "Ready to create",
|
||||
"cancelButton": "Cancel",
|
||||
"addButton": "Add Physical Book"
|
||||
"addButton": "Add Physical Book",
|
||||
"fetchMetadataTooltip": "Fetch metadata by ISBN"
|
||||
},
|
||||
"fileUploader": {
|
||||
"title": "Upload Additional File",
|
||||
|
||||
@@ -429,7 +429,8 @@
|
||||
"validationTitleOrIsbn": "Se requiere un título o ISBN",
|
||||
"validationReady": "Listo para crear",
|
||||
"cancelButton": "Cancelar",
|
||||
"addButton": "Agregar libro físico"
|
||||
"addButton": "Agregar libro físico",
|
||||
"fetchMetadataTooltip": "Obtener metadatos por ISBN"
|
||||
},
|
||||
"fileUploader": {
|
||||
"title": "Subir archivo adicional",
|
||||
|
||||
Reference in New Issue
Block a user