refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
+258
@@ -0,0 +1,258 @@
|
||||
<ng-container *transloco="let t; prefix: 'book.addPhysicalBook'">
|
||||
<div class="add-physical-book">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-book header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
(click)="cancel()"
|
||||
severity="secondary"
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
class="close-button"
|
||||
[pTooltip]="t('closeTooltip')"
|
||||
tooltipPosition="left"/>
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<div class="form-group highlight-group">
|
||||
<label for="library" class="form-label">
|
||||
<i class="pi pi-folder label-icon"></i>
|
||||
{{ t('libraryLabel') }}
|
||||
<span class="required-indicator">*</span>
|
||||
</label>
|
||||
<p-select
|
||||
id="library"
|
||||
[options]="libraries"
|
||||
[(ngModel)]="selectedLibraryId"
|
||||
optionLabel="name"
|
||||
optionValue="id"
|
||||
[placeholder]="t('libraryPlaceholder')"
|
||||
[style]="{'width': '100%'}"/>
|
||||
</div>
|
||||
|
||||
<div class="gradient-divider"></div>
|
||||
|
||||
<div class="top-section">
|
||||
@if (coverUrl) {
|
||||
<div class="cover-preview">
|
||||
<img [src]="coverUrl" alt="Book cover"/>
|
||||
</div>
|
||||
}
|
||||
|
||||
<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 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>
|
||||
|
||||
<div class="gradient-divider"></div>
|
||||
|
||||
<div class="form-group highlight-group">
|
||||
<label for="description" class="form-label">
|
||||
<i class="pi pi-align-left label-icon"></i>
|
||||
{{ t('descriptionLabel') }}
|
||||
</label>
|
||||
<textarea
|
||||
id="description"
|
||||
pTextarea
|
||||
[(ngModel)]="description"
|
||||
rows="3"
|
||||
[placeholder]="t('descriptionPlaceholder')"
|
||||
class="input-full"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="gradient-divider"></div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="publisher" class="form-label">
|
||||
<i class="pi pi-building label-icon"></i>
|
||||
{{ t('publisherLabel') }}
|
||||
</label>
|
||||
<input
|
||||
id="publisher"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="publisher"
|
||||
class="input-full"
|
||||
[placeholder]="t('publisherPlaceholder')"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="publishedDate" class="form-label">
|
||||
<i class="pi pi-calendar label-icon"></i>
|
||||
{{ t('publishedDateLabel') }}
|
||||
</label>
|
||||
<input
|
||||
id="publishedDate"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="publishedDate"
|
||||
class="input-full"
|
||||
[placeholder]="t('publishedDatePlaceholder')"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="language" class="form-label">
|
||||
<i class="pi pi-globe label-icon"></i>
|
||||
{{ t('languageLabel') }}
|
||||
</label>
|
||||
<input
|
||||
id="language"
|
||||
type="text"
|
||||
pInputText
|
||||
[(ngModel)]="language"
|
||||
class="input-full"
|
||||
[placeholder]="t('languagePlaceholder')"/>
|
||||
</div>
|
||||
|
||||
<div class="form-group highlight-group flex-1">
|
||||
<label for="pageCount" class="form-label">
|
||||
<i class="pi pi-file label-icon"></i>
|
||||
{{ t('pageCountLabel') }}
|
||||
</label>
|
||||
<p-inputnumber
|
||||
id="pageCount"
|
||||
[(ngModel)]="pageCount"
|
||||
[useGrouping]="false"
|
||||
[placeholder]="t('pageCountPlaceholder')"
|
||||
class="input-full">
|
||||
</p-inputnumber>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gradient-divider"></div>
|
||||
|
||||
<div class="form-group highlight-group">
|
||||
<label for="categories" class="form-label">
|
||||
<i class="pi pi-tags label-icon"></i>
|
||||
{{ t('categoriesLabel') }}
|
||||
</label>
|
||||
<div class="autocomplete-wrapper">
|
||||
<p-autoComplete
|
||||
appendTo="body"
|
||||
[(ngModel)]="categories"
|
||||
[multiple]="true"
|
||||
[fluid]="true"
|
||||
[dropdown]="false"
|
||||
[suggestions]="filteredCategories"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
[placeholder]="t('categoriesPlaceholder')"
|
||||
(completeMethod)="filterCategories($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('categories', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('categories', $event)">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<div class="validation-status">
|
||||
@if (!selectedLibraryId) {
|
||||
<div class="validation-message error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>{{ t('validationLibraryRequired') }}</span>
|
||||
</div>
|
||||
} @else if (!title.trim() && !isbn.trim()) {
|
||||
<div class="validation-message error">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
<span>{{ t('validationTitleOrIsbn') }}</span>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="validation-message success">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
<span>{{ t('validationReady') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
[label]="t('cancelButton')"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(onClick)="cancel()"/>
|
||||
<p-button
|
||||
[label]="t('addButton')"
|
||||
icon="pi pi-plus"
|
||||
severity="success"
|
||||
(onClick)="createBook()"
|
||||
[disabled]="!canCreate() || isLoading"
|
||||
[loading]="isLoading"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
@use '../../../../shared/styles/panel-shared' as panel;
|
||||
|
||||
.add-physical-book {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 700px;
|
||||
max-height: 90vh;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
min-width: auto;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
@include panel.panel-header;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 1.25rem;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-top: none;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||
overflow-y: auto;
|
||||
max-height: calc(90vh - 200px);
|
||||
|
||||
@media (max-width: 480px) {
|
||||
padding: 0.75rem;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
|
||||
@media (max-width: 640px) {
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.flex-2 {
|
||||
flex: 2;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
|
||||
&.highlight-group {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
gap: 0.25rem;
|
||||
|
||||
&.highlight-group {
|
||||
padding: 0.375rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
|
||||
.label-icon {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.required-indicator {
|
||||
color: var(--p-red-500);
|
||||
margin-left: 0.125rem;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
|
||||
.input-full {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.input-full {
|
||||
width: 100%;
|
||||
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%;
|
||||
|
||||
p-autocomplete {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
@include panel.dialog-footer;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.validation-message {
|
||||
@include panel.validation-message;
|
||||
}
|
||||
|
||||
::ng-deep {
|
||||
.p-inputnumber {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.p-inputnumber-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.p-autocomplete .p-chip .p-chip-label {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.p-autocomplete-input-chip {
|
||||
width: 2rem;
|
||||
}
|
||||
|
||||
.p-autocomplete-clearable ul {
|
||||
padding-inline-end: 2rem !important;
|
||||
}
|
||||
|
||||
.p-autocomplete-clearable .p-autocomplete-clear-icon {
|
||||
right: 0px;
|
||||
margin-top: -1rem;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
}
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
import {Component, computed, effect, inject} from '@angular/core';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {Select} from 'primeng/select';
|
||||
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';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-add-physical-book-dialog',
|
||||
standalone: true,
|
||||
templateUrl: './add-physical-book-dialog.component.html',
|
||||
imports: [
|
||||
FormsModule,
|
||||
Button,
|
||||
InputText,
|
||||
Tooltip,
|
||||
Select,
|
||||
Textarea,
|
||||
InputNumber,
|
||||
AutoComplete,
|
||||
TranslocoDirective
|
||||
],
|
||||
styleUrl: './add-physical-book-dialog.component.scss',
|
||||
})
|
||||
export class AddPhysicalBookDialogComponent {
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private dialogConfig = inject(DynamicDialogConfig);
|
||||
private bookService = inject(BookService);
|
||||
private bookMetadataService = inject(BookMetadataService);
|
||||
private libraryService = inject(LibraryService);
|
||||
|
||||
selectedLibraryId: number | null = null;
|
||||
title: string = '';
|
||||
isbn: string = '';
|
||||
authors: string[] = [];
|
||||
description: string = '';
|
||||
publisher: string = '';
|
||||
publishedDate: string = '';
|
||||
language: string = '';
|
||||
pageCount: number | null = null;
|
||||
categories: string[] = [];
|
||||
|
||||
private readonly metadata = computed(() => this.bookService.uniqueMetadata());
|
||||
get allAuthors(): string[] { return this.metadata().authors; }
|
||||
get allCategories(): string[] { return this.metadata().categories; }
|
||||
filteredAuthors: string[] = [];
|
||||
filteredCategories: string[] = [];
|
||||
|
||||
coverUrl: string | null = null;
|
||||
isLoading: boolean = false;
|
||||
isFetchingMetadata: boolean = false;
|
||||
private readonly initializeSelectedLibraryEffect = effect(() => {
|
||||
const libraries = this.libraries;
|
||||
if (libraries.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dialogConfig.data?.libraryId) {
|
||||
this.selectedLibraryId = this.dialogConfig.data.libraryId;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.selectedLibraryId == null && this.libraries[0].id !== undefined) {
|
||||
this.selectedLibraryId = this.libraries[0].id;
|
||||
}
|
||||
});
|
||||
|
||||
get libraries(): Library[] {
|
||||
return this.libraryService.libraries();
|
||||
}
|
||||
|
||||
filterAuthors(event: AutoCompleteCompleteEvent): void {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredAuthors = this.allAuthors.filter((author) =>
|
||||
author.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterCategories(event: AutoCompleteCompleteEvent): void {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredCategories = this.allCategories.filter((category) =>
|
||||
category.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
onAutoCompleteKeyUp(fieldName: 'authors' | 'categories', event: KeyboardEvent): void {
|
||||
if (event.key === 'Enter') {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const value = input.value?.trim();
|
||||
if (value) {
|
||||
const values = this[fieldName];
|
||||
if (!values.includes(value)) {
|
||||
this[fieldName] = [...values, value];
|
||||
}
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAutoCompleteSelect(fieldName: 'authors' | 'categories', event: { value: string, originalEvent: Event }): void {
|
||||
const values = this[fieldName];
|
||||
if (!values.includes(event.value)) {
|
||||
this[fieldName] = [...values, event.value];
|
||||
}
|
||||
(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();
|
||||
}
|
||||
|
||||
canCreate(): boolean {
|
||||
return !!this.selectedLibraryId && (!!this.title.trim() || !!this.isbn.trim());
|
||||
}
|
||||
|
||||
createBook(): void {
|
||||
if (!this.canCreate() || this.isLoading) return;
|
||||
|
||||
this.isLoading = true;
|
||||
|
||||
const request: CreatePhysicalBookRequest = {
|
||||
libraryId: this.selectedLibraryId!,
|
||||
title: this.title.trim() || undefined,
|
||||
isbn: this.isbn.trim() || undefined,
|
||||
authors: this.authors.length > 0 ? this.authors : undefined,
|
||||
description: this.description.trim() || undefined,
|
||||
publisher: this.publisher.trim() || undefined,
|
||||
publishedDate: this.publishedDate.trim() || undefined,
|
||||
language: this.language.trim() || undefined,
|
||||
pageCount: this.pageCount ?? undefined,
|
||||
categories: this.categories.length > 0 ? this.categories : undefined,
|
||||
thumbnailUrl: this.coverUrl || undefined
|
||||
};
|
||||
|
||||
this.bookService.createPhysicalBook(request).subscribe({
|
||||
next: (book) => {
|
||||
this.isLoading = false;
|
||||
this.dynamicDialogRef.close(book);
|
||||
},
|
||||
error: () => {
|
||||
this.isLoading = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user