- Remove ISBN from search

- Make description text area
This commit is contained in:
aditya.chandel
2025-03-11 13:41:27 -06:00
parent c10f046c5b
commit 8c33befc51
5 changed files with 52 additions and 21 deletions
@@ -30,7 +30,39 @@
</div>
</div>
<div *ngFor="let field of metadataFields" class="form-row">
<div *ngFor="let field of metadataFieldsTop" class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<p-button *ngIf="!metadata[field.lockedKey]" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : 'pi pi-arrow-left'"
[outlined]="true"
[ngClass]="{'green-outlined-button': isValueSaved(field.controlName), 'yellow-outlined-button': isValueCopied(field.controlName)}"
class="arrow-button"
(click)="copyFetchedToCurrent(field.controlName)"/>
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
</div>
</div>
<div *ngFor="let field of metadataDescription" class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<p-button *ngIf="!metadata[field.lockedKey]" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
<textarea rows="6" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : 'pi pi-arrow-left'"
[outlined]="true"
[ngClass]="{'green-outlined-button': isValueSaved(field.controlName), 'yellow-outlined-button': isValueCopied(field.controlName)}"
class="arrow-button"
(click)="copyFetchedToCurrent(field.controlName)"/>
<textarea rows="6" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
</div>
</div>
<div *ngFor="let field of metadataFieldsBottom" class="form-row">
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
<div class="input-container">
<p-button *ngIf="!metadata[field.lockedKey]" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
@@ -11,6 +11,7 @@ import {Observable} from 'rxjs';
import {Tooltip} from 'primeng/tooltip';
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
import {BookService} from '../../../book/service/book.service';
import {Textarea} from 'primeng/textarea';
@Component({
selector: 'app-metadata-picker',
@@ -28,20 +29,28 @@ import {BookService} from '../../../book/service/book.service';
NgStyle,
Tooltip,
AsyncPipe,
NgForOf
NgForOf,
Textarea
]
})
export class MetadataPickerComponent implements OnInit {
metadataFields = [
metadataFieldsTop = [
{label: 'Title', controlName: 'title', lockedKey: 'titleLocked', fetchedKey: 'title'},
{label: 'Authors', controlName: 'authors', lockedKey: 'authorsLocked', fetchedKey: 'authors'},
{label: 'Categories', controlName: 'categories', lockedKey: 'categoriesLocked', fetchedKey: 'categories'},
{label: 'Publisher', controlName: 'publisher', lockedKey: 'publisherLocked', fetchedKey: 'publisher'},
{label: 'Published', controlName: 'publishedDate', lockedKey: 'publishedDateLocked', fetchedKey: 'publishedDate'},
{label: 'ISBN-10', controlName: 'isbn10', lockedKey: 'isbn10Locked', fetchedKey: 'isbn10'},
{label: 'Language', controlName: 'language', lockedKey: 'languageLocked', fetchedKey: 'language'},
{label: 'Language', controlName: 'language', lockedKey: 'languageLocked', fetchedKey: 'language'}
];
metadataDescription = [
{label: 'Description', controlName: 'description', lockedKey: 'descriptionLocked', fetchedKey: 'description'},
];
metadataFieldsBottom = [
{label: 'Series', controlName: 'seriesName', lockedKey: 'seriesNameLocked', fetchedKey: 'seriesName'},
{label: 'Book #', controlName: 'seriesNumber', lockedKey: 'seriesNumberLocked', fetchedKey: 'seriesNumber'},
{label: 'Total Books', controlName: 'seriesTotal', lockedKey: 'seriesTotalLocked', fetchedKey: 'seriesTotal'},
@@ -1,21 +1,16 @@
<form *ngIf="!selectedFetchedMetadata" class="flex flex-col w-full h-full pt-2" [formGroup]="form" (ngSubmit)="onSubmit()">
<div class="flex w-full gap-x-4 items-end">
<div class="flex flex-col gap-1 w-1/6">
<label for="provider">Providers</label>
<div class="flex flex-col gap-1 w-3/12">
<label>Providers</label>
<p-multiselect id="provider" class="w-full" [filter]="false" showToggleAll="false" [options]="providers" formControlName="provider" placeholder="Select Providers"></p-multiselect>
</div>
<div class="flex flex-col gap-1 w-1/6">
<label for="isbn">ISBN</label>
<input pInputText formControlName="isbn" id="isbn" class="w-full"/>
</div>
<div class="flex flex-col gap-1 w-2/6">
<div class="flex flex-col gap-1 w-5/12">
<label for="title">Title</label>
<input pInputText formControlName="title" id="title" class="w-full"/>
</div>
<div class="flex flex-col gap-1 w-2/6">
<div class="flex flex-col gap-1 w-4/12">
<label for="author">Author</label>
<input pInputText formControlName="author" id="author" class="w-full"/>
</div>
@@ -36,7 +36,6 @@ export class MetadataSearcherComponent implements OnInit {
constructor() {
this.form = this.formBuilder.group({
provider: null,
isbn: [''],
title: [''],
author: [''],
});
@@ -48,19 +47,18 @@ export class MetadataSearcherComponent implements OnInit {
this.bookId = metadata.bookId;
this.form.patchValue(({
provider: Object.values(MetadataProvider),
isbn: metadata.isbn10 || null,
title: metadata.title || null,
author: metadata.authors?.length! > 0 ? metadata.authors[0] : ''
}));
}
}));
//this.onSubmit();
this.onSubmit();
}
get isSearchEnabled(): boolean {
const providerSelected = !!this.form.get('provider')?.value;
const isbnOrTitle = this.form.get('isbn')?.value || this.form.get('title')?.value;
return providerSelected && isbnOrTitle;
const title = this.form.get('title')?.value;
return providerSelected && title;
}
onSubmit(): void {
@@ -69,14 +67,12 @@ export class MetadataSearcherComponent implements OnInit {
(this.form.get('provider')?.value as string[]).includes(MetadataProvider[key as keyof typeof MetadataProvider])
);
if (!providerKeys) {
console.error('Invalid provider selected.');
return;
}
const fetchRequest: FetchMetadataRequest = {
bookId: this.bookId,
providers: providerKeys,
title: this.form.get('title')?.value,
isbn: this.form.get('isbn')?.value,
author: this.form.get('author')?.value
};
this.loading = true;
@@ -2,6 +2,5 @@ export interface FetchMetadataRequest {
bookId: number,
providers: string[],
title: string,
isbn: string,
author: string
}