- Remove ISBN from search
- Make description text area
This commit is contained in:
+33
-1
@@ -30,7 +30,39 @@
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
|
||||||
<div class="input-container">
|
<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-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
|
||||||
|
|||||||
+12
-3
@@ -11,6 +11,7 @@ import {Observable} from 'rxjs';
|
|||||||
import {Tooltip} from 'primeng/tooltip';
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
|
import {Textarea} from 'primeng/textarea';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-picker',
|
selector: 'app-metadata-picker',
|
||||||
@@ -28,20 +29,28 @@ import {BookService} from '../../../book/service/book.service';
|
|||||||
NgStyle,
|
NgStyle,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
NgForOf
|
NgForOf,
|
||||||
|
Textarea
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class MetadataPickerComponent implements OnInit {
|
export class MetadataPickerComponent implements OnInit {
|
||||||
|
|
||||||
metadataFields = [
|
|
||||||
|
metadataFieldsTop = [
|
||||||
{label: 'Title', controlName: 'title', lockedKey: 'titleLocked', fetchedKey: 'title'},
|
{label: 'Title', controlName: 'title', lockedKey: 'titleLocked', fetchedKey: 'title'},
|
||||||
{label: 'Authors', controlName: 'authors', lockedKey: 'authorsLocked', fetchedKey: 'authors'},
|
{label: 'Authors', controlName: 'authors', lockedKey: 'authorsLocked', fetchedKey: 'authors'},
|
||||||
{label: 'Categories', controlName: 'categories', lockedKey: 'categoriesLocked', fetchedKey: 'categories'},
|
{label: 'Categories', controlName: 'categories', lockedKey: 'categoriesLocked', fetchedKey: 'categories'},
|
||||||
{label: 'Publisher', controlName: 'publisher', lockedKey: 'publisherLocked', fetchedKey: 'publisher'},
|
{label: 'Publisher', controlName: 'publisher', lockedKey: 'publisherLocked', fetchedKey: 'publisher'},
|
||||||
{label: 'Published', controlName: 'publishedDate', lockedKey: 'publishedDateLocked', fetchedKey: 'publishedDate'},
|
{label: 'Published', controlName: 'publishedDate', lockedKey: 'publishedDateLocked', fetchedKey: 'publishedDate'},
|
||||||
{label: 'ISBN-10', controlName: 'isbn10', lockedKey: 'isbn10Locked', fetchedKey: 'isbn10'},
|
{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'},
|
{label: 'Description', controlName: 'description', lockedKey: 'descriptionLocked', fetchedKey: 'description'},
|
||||||
|
];
|
||||||
|
|
||||||
|
metadataFieldsBottom = [
|
||||||
{label: 'Series', controlName: 'seriesName', lockedKey: 'seriesNameLocked', fetchedKey: 'seriesName'},
|
{label: 'Series', controlName: 'seriesName', lockedKey: 'seriesNameLocked', fetchedKey: 'seriesName'},
|
||||||
{label: 'Book #', controlName: 'seriesNumber', lockedKey: 'seriesNumberLocked', fetchedKey: 'seriesNumber'},
|
{label: 'Book #', controlName: 'seriesNumber', lockedKey: 'seriesNumberLocked', fetchedKey: 'seriesNumber'},
|
||||||
{label: 'Total Books', controlName: 'seriesTotal', lockedKey: 'seriesTotalLocked', fetchedKey: 'seriesTotal'},
|
{label: 'Total Books', controlName: 'seriesTotal', lockedKey: 'seriesTotalLocked', fetchedKey: 'seriesTotal'},
|
||||||
|
|||||||
+4
-9
@@ -1,21 +1,16 @@
|
|||||||
<form *ngIf="!selectedFetchedMetadata" class="flex flex-col w-full h-full pt-2" [formGroup]="form" (ngSubmit)="onSubmit()">
|
<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 w-full gap-x-4 items-end">
|
||||||
<div class="flex flex-col gap-1 w-1/6">
|
<div class="flex flex-col gap-1 w-3/12">
|
||||||
<label for="provider">Providers</label>
|
<label>Providers</label>
|
||||||
<p-multiselect id="provider" class="w-full" [filter]="false" showToggleAll="false" [options]="providers" formControlName="provider" placeholder="Select Providers"></p-multiselect>
|
<p-multiselect id="provider" class="w-full" [filter]="false" showToggleAll="false" [options]="providers" formControlName="provider" placeholder="Select Providers"></p-multiselect>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-1 w-1/6">
|
<div class="flex flex-col gap-1 w-5/12">
|
||||||
<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">
|
|
||||||
<label for="title">Title</label>
|
<label for="title">Title</label>
|
||||||
<input pInputText formControlName="title" id="title" class="w-full"/>
|
<input pInputText formControlName="title" id="title" class="w-full"/>
|
||||||
</div>
|
</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>
|
<label for="author">Author</label>
|
||||||
<input pInputText formControlName="author" id="author" class="w-full"/>
|
<input pInputText formControlName="author" id="author" class="w-full"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+3
-7
@@ -36,7 +36,6 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.form = this.formBuilder.group({
|
this.form = this.formBuilder.group({
|
||||||
provider: null,
|
provider: null,
|
||||||
isbn: [''],
|
|
||||||
title: [''],
|
title: [''],
|
||||||
author: [''],
|
author: [''],
|
||||||
});
|
});
|
||||||
@@ -48,19 +47,18 @@ export class MetadataSearcherComponent implements OnInit {
|
|||||||
this.bookId = metadata.bookId;
|
this.bookId = metadata.bookId;
|
||||||
this.form.patchValue(({
|
this.form.patchValue(({
|
||||||
provider: Object.values(MetadataProvider),
|
provider: Object.values(MetadataProvider),
|
||||||
isbn: metadata.isbn10 || null,
|
|
||||||
title: metadata.title || null,
|
title: metadata.title || null,
|
||||||
author: metadata.authors?.length! > 0 ? metadata.authors[0] : ''
|
author: metadata.authors?.length! > 0 ? metadata.authors[0] : ''
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
//this.onSubmit();
|
this.onSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
get isSearchEnabled(): boolean {
|
get isSearchEnabled(): boolean {
|
||||||
const providerSelected = !!this.form.get('provider')?.value;
|
const providerSelected = !!this.form.get('provider')?.value;
|
||||||
const isbnOrTitle = this.form.get('isbn')?.value || this.form.get('title')?.value;
|
const title = this.form.get('title')?.value;
|
||||||
return providerSelected && isbnOrTitle;
|
return providerSelected && title;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(): void {
|
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])
|
(this.form.get('provider')?.value as string[]).includes(MetadataProvider[key as keyof typeof MetadataProvider])
|
||||||
);
|
);
|
||||||
if (!providerKeys) {
|
if (!providerKeys) {
|
||||||
console.error('Invalid provider selected.');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fetchRequest: FetchMetadataRequest = {
|
const fetchRequest: FetchMetadataRequest = {
|
||||||
bookId: this.bookId,
|
bookId: this.bookId,
|
||||||
providers: providerKeys,
|
providers: providerKeys,
|
||||||
title: this.form.get('title')?.value,
|
title: this.form.get('title')?.value,
|
||||||
isbn: this.form.get('isbn')?.value,
|
|
||||||
author: this.form.get('author')?.value
|
author: this.form.get('author')?.value
|
||||||
};
|
};
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|||||||
@@ -2,6 +2,5 @@ export interface FetchMetadataRequest {
|
|||||||
bookId: number,
|
bookId: number,
|
||||||
providers: string[],
|
providers: string[],
|
||||||
title: string,
|
title: string,
|
||||||
isbn: string,
|
|
||||||
author: string
|
author: string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user