WIP: Enhance book metadata picker
This commit is contained in:
-5
@@ -37,11 +37,6 @@ public class MetadataController {
|
||||
return ResponseEntity.ok(bookMetadata);
|
||||
}
|
||||
|
||||
/*@PutMapping("/update/{bookId}")
|
||||
public ResponseEntity<BookMetadata> updateMetadata(@PathVariable long bookId, @RequestBody BookMetadata bookMetadata) {
|
||||
return ResponseEntity.ok(bookMetadataUpdater.updateMetadata(bookId, bookMetadata));
|
||||
}*/
|
||||
|
||||
@PutMapping(path = "/refreshV2")
|
||||
public ResponseEntity<String> scheduleRefreshV2(@Validated @RequestBody MetadataRefreshRequest request) {
|
||||
jobSchedulerService.scheduleMetadataRefreshV2(request);
|
||||
|
||||
-125
@@ -1,10 +1,6 @@
|
||||
package com.adityachandel.booklore.service.metadata;
|
||||
|
||||
import com.adityachandel.booklore.exception.ApiError;
|
||||
import com.adityachandel.booklore.mapper.AuthorMapper;
|
||||
import com.adityachandel.booklore.mapper.BookMetadataMapper;
|
||||
import com.adityachandel.booklore.mapper.CategoryMapper;
|
||||
import com.adityachandel.booklore.model.dto.BookMetadata;
|
||||
import com.adityachandel.booklore.model.entity.*;
|
||||
import com.adityachandel.booklore.repository.*;
|
||||
import com.adityachandel.booklore.service.metadata.model.FetchedBookMetadata;
|
||||
@@ -20,7 +16,6 @@ import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -34,9 +29,6 @@ public class BookMetadataUpdater {
|
||||
private BookMetadataRepository bookMetadataRepository;
|
||||
private CategoryRepository categoryRepository;
|
||||
private FileService fileService;
|
||||
private BookMetadataMapper bookMetadataMapper;
|
||||
private AuthorMapper authorMapper;
|
||||
private CategoryMapper categoryMapper;
|
||||
private BookAwardRepository bookAwardRepository;
|
||||
|
||||
|
||||
@@ -249,121 +241,4 @@ public class BookMetadataUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public BookMetadata updateMetadata(long bookId, BookMetadata updatedMetadata) {
|
||||
BookEntity bookEntity = bookRepository.findById(bookId).orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
|
||||
BookMetadataEntity metadata = bookEntity.getMetadata();
|
||||
|
||||
List<String> lockedFields = new ArrayList<>();
|
||||
|
||||
if (metadata.getAllFieldsLocked() != null && metadata.getAllFieldsLocked()) {
|
||||
log.warn("Attempted to update metadata for book with ID {}, but all fields are locked. No update performed.", bookId);
|
||||
throw ApiError.METADATA_LOCKED.createException(bookId);
|
||||
}
|
||||
|
||||
if (metadata.getTitleLocked() && updatedMetadata.getTitle() != null) {
|
||||
lockedFields.add("Title");
|
||||
} else if (!metadata.getTitleLocked() && updatedMetadata.getTitle() != null) {
|
||||
metadata.setTitle(updatedMetadata.getTitle());
|
||||
}
|
||||
|
||||
if (metadata.getSubtitleLocked() && updatedMetadata.getSubtitle() != null) {
|
||||
lockedFields.add("Subtitle");
|
||||
} else if (!metadata.getSubtitleLocked() && updatedMetadata.getSubtitle() != null) {
|
||||
metadata.setSubtitle(updatedMetadata.getSubtitle());
|
||||
}
|
||||
|
||||
if (metadata.getPublisherLocked() && updatedMetadata.getPublisher() != null) {
|
||||
lockedFields.add("Publisher");
|
||||
} else if (!metadata.getPublisherLocked() && updatedMetadata.getPublisher() != null) {
|
||||
metadata.setPublisher(updatedMetadata.getPublisher());
|
||||
}
|
||||
|
||||
if (metadata.getSeriesNameLocked() && updatedMetadata.getSeriesName() != null) {
|
||||
lockedFields.add("Series Name");
|
||||
} else if (!metadata.getSeriesNameLocked() && updatedMetadata.getSeriesName() != null) {
|
||||
metadata.setSeriesName(updatedMetadata.getSeriesName());
|
||||
}
|
||||
|
||||
if (metadata.getSeriesNumberLocked() && updatedMetadata.getSeriesNumber() != null) {
|
||||
lockedFields.add("Series Number");
|
||||
} else if (!metadata.getSeriesNumberLocked() && updatedMetadata.getSeriesNumber() != null) {
|
||||
metadata.setSeriesNumber(updatedMetadata.getSeriesNumber());
|
||||
}
|
||||
|
||||
if (metadata.getSeriesTotalLocked() && updatedMetadata.getSeriesTotal() != null) {
|
||||
lockedFields.add("Series Total");
|
||||
} else if (!metadata.getSeriesTotalLocked() && updatedMetadata.getSeriesTotal() != null) {
|
||||
metadata.setSeriesTotal(updatedMetadata.getSeriesTotal());
|
||||
}
|
||||
|
||||
if (metadata.getPublishedDateLocked() && updatedMetadata.getPublishedDate() != null) {
|
||||
lockedFields.add("Published Date");
|
||||
} else if (!metadata.getPublishedDateLocked() && updatedMetadata.getPublishedDate() != null) {
|
||||
metadata.setPublishedDate(updatedMetadata.getPublishedDate());
|
||||
}
|
||||
|
||||
if (metadata.getDescriptionLocked() && updatedMetadata.getDescription() != null) {
|
||||
lockedFields.add("Description");
|
||||
} else if (!metadata.getDescriptionLocked() && updatedMetadata.getDescription() != null) {
|
||||
metadata.setDescription(updatedMetadata.getDescription());
|
||||
}
|
||||
|
||||
if (metadata.getIsbn13Locked() && updatedMetadata.getIsbn13() != null) {
|
||||
lockedFields.add("ISBN 13");
|
||||
} else if (!metadata.getIsbn13Locked() && updatedMetadata.getIsbn13() != null) {
|
||||
metadata.setIsbn13(updatedMetadata.getIsbn13());
|
||||
}
|
||||
|
||||
if (metadata.getIsbn10Locked() && updatedMetadata.getIsbn10() != null) {
|
||||
lockedFields.add("ISBN 10");
|
||||
} else if (!metadata.getIsbn10Locked() && updatedMetadata.getIsbn10() != null) {
|
||||
metadata.setIsbn10(updatedMetadata.getIsbn10());
|
||||
}
|
||||
|
||||
if (metadata.getPageCountLocked() && updatedMetadata.getPageCount() != null) {
|
||||
lockedFields.add("Page Count");
|
||||
} else if (!metadata.getPageCountLocked() && updatedMetadata.getPageCount() != null) {
|
||||
metadata.setPageCount(updatedMetadata.getPageCount());
|
||||
}
|
||||
|
||||
if (metadata.getLanguageLocked() && updatedMetadata.getLanguage() != null) {
|
||||
lockedFields.add("Language");
|
||||
} else if (!metadata.getLanguageLocked() && updatedMetadata.getLanguage() != null) {
|
||||
metadata.setLanguage(updatedMetadata.getLanguage());
|
||||
}
|
||||
|
||||
if (metadata.getRatingLocked() && updatedMetadata.getRating() != null) {
|
||||
lockedFields.add("Rating");
|
||||
} else if (!metadata.getRatingLocked() && updatedMetadata.getRating() != null) {
|
||||
metadata.setRating(updatedMetadata.getRating());
|
||||
}
|
||||
|
||||
if (metadata.getReviewCountLocked() && updatedMetadata.getReviewCount() != null) {
|
||||
lockedFields.add("Review Count");
|
||||
} else if (!metadata.getReviewCountLocked() && updatedMetadata.getReviewCount() != null) {
|
||||
metadata.setReviewCount(updatedMetadata.getReviewCount());
|
||||
}
|
||||
|
||||
if (metadata.getAuthorsLocked() && updatedMetadata.getAuthors() != null) {
|
||||
lockedFields.add("Authors");
|
||||
} else if (!metadata.getAuthorsLocked() && updatedMetadata.getAuthors() != null) {
|
||||
metadata.setAuthors(authorMapper.toAuthorEntityList(updatedMetadata.getAuthors()));
|
||||
}
|
||||
|
||||
if (metadata.getCategoriesLocked() && updatedMetadata.getCategories() != null) {
|
||||
lockedFields.add("Categories");
|
||||
} else if (!metadata.getCategoriesLocked() && updatedMetadata.getCategories() != null) {
|
||||
metadata.setCategories(categoryMapper.toCategoryEntities(updatedMetadata.getCategories()));
|
||||
}
|
||||
|
||||
if (!lockedFields.isEmpty()) {
|
||||
String lockedFieldsMessage = String.join(", ", lockedFields);
|
||||
log.error("Attempted to update the following locked fields for book with ID {}: {}", bookId, lockedFieldsMessage);
|
||||
throw ApiError.METADATA_LOCKED.createException(bookId);
|
||||
}
|
||||
|
||||
bookRepository.save(bookEntity);
|
||||
return bookMetadataMapper.toBookMetadata(metadata, false);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
<form [formGroup]="bookMetadataForm" (ngSubmit)="onSave()" *ngIf="bookMetadata$ | async as metadata" class="pt-2 flex flex-col h-full">
|
||||
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" *ngIf="bookMetadata$ | async as metadata" class="pt-2 flex flex-col h-full">
|
||||
|
||||
<div class="overflow-y-scroll flex-1">
|
||||
|
||||
@@ -172,9 +172,9 @@
|
||||
<p-divider></p-divider>
|
||||
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
|
||||
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
|
||||
<p-button class="pr-10" label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
|
||||
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Close" icon="pi pi-times" severity="secondary" (onClick)="closeDialog()"></p-button>
|
||||
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
|
||||
</div>
|
||||
|
||||
+61
-61
@@ -36,11 +36,11 @@ export class MetadataEditorComponent implements OnInit {
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
|
||||
bookMetadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
|
||||
bookMetadataForm: FormGroup;
|
||||
metadataForm: FormGroup;
|
||||
currentBookId!: number;
|
||||
|
||||
constructor() {
|
||||
this.bookMetadataForm = new FormGroup({
|
||||
this.metadataForm = new FormGroup({
|
||||
title: new FormControl(''),
|
||||
subtitle: new FormControl(''),
|
||||
authors: new FormControl(''),
|
||||
@@ -82,7 +82,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
if (metadata) {
|
||||
this.currentBookId = metadata.bookId;
|
||||
|
||||
this.bookMetadataForm.setValue({
|
||||
this.metadataForm.setValue({
|
||||
title: metadata.title,
|
||||
subtitle: metadata.subtitle,
|
||||
authors: metadata.authors.map((author) => author.name).sort().join(', '),
|
||||
@@ -118,22 +118,22 @@ export class MetadataEditorComponent implements OnInit {
|
||||
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
||||
});
|
||||
|
||||
if (metadata.titleLocked) this.bookMetadataForm.get('title')?.disable();
|
||||
if (metadata.subtitleLocked) this.bookMetadataForm.get('subtitle')?.disable();
|
||||
if (metadata.authorsLocked) this.bookMetadataForm.get('authors')?.disable();
|
||||
if (metadata.categoriesLocked) this.bookMetadataForm.get('categories')?.disable();
|
||||
if (metadata.publisherLocked) this.bookMetadataForm.get('publisher')?.disable();
|
||||
if (metadata.publishedDateLocked) this.bookMetadataForm.get('publishedDate')?.disable();
|
||||
if (metadata.languageLocked) this.bookMetadataForm.get('language')?.disable();
|
||||
if (metadata.isbn10Locked) this.bookMetadataForm.get('isbn10')?.disable();
|
||||
if (metadata.isbn13Locked) this.bookMetadataForm.get('isbn13')?.disable();
|
||||
if (metadata.reviewCountLocked) this.bookMetadataForm.get('reviewCount')?.disable();
|
||||
if (metadata.ratingLocked) this.bookMetadataForm.get('rating')?.disable();
|
||||
if (metadata.pageCountLocked) this.bookMetadataForm.get('pageCount')?.disable();
|
||||
if (metadata.descriptionLocked) this.bookMetadataForm.get('description')?.disable();
|
||||
if (metadata.seriesNameLocked) this.bookMetadataForm.get('seriesName')?.disable();
|
||||
if (metadata.seriesNumberLocked) this.bookMetadataForm.get('seriesNumber')?.disable();
|
||||
if (metadata.seriesTotalLocked) this.bookMetadataForm.get('seriesTotal')?.disable();
|
||||
if (metadata.titleLocked) this.metadataForm.get('title')?.disable();
|
||||
if (metadata.subtitleLocked) this.metadataForm.get('subtitle')?.disable();
|
||||
if (metadata.authorsLocked) this.metadataForm.get('authors')?.disable();
|
||||
if (metadata.categoriesLocked) this.metadataForm.get('categories')?.disable();
|
||||
if (metadata.publisherLocked) this.metadataForm.get('publisher')?.disable();
|
||||
if (metadata.publishedDateLocked) this.metadataForm.get('publishedDate')?.disable();
|
||||
if (metadata.languageLocked) this.metadataForm.get('language')?.disable();
|
||||
if (metadata.isbn10Locked) this.metadataForm.get('isbn10')?.disable();
|
||||
if (metadata.isbn13Locked) this.metadataForm.get('isbn13')?.disable();
|
||||
if (metadata.reviewCountLocked) this.metadataForm.get('reviewCount')?.disable();
|
||||
if (metadata.ratingLocked) this.metadataForm.get('rating')?.disable();
|
||||
if (metadata.pageCountLocked) this.metadataForm.get('pageCount')?.disable();
|
||||
if (metadata.descriptionLocked) this.metadataForm.get('description')?.disable();
|
||||
if (metadata.seriesNameLocked) this.metadataForm.get('seriesName')?.disable();
|
||||
if (metadata.seriesNumberLocked) this.metadataForm.get('seriesNumber')?.disable();
|
||||
if (metadata.seriesTotalLocked) this.metadataForm.get('seriesTotal')?.disable();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -151,34 +151,34 @@ export class MetadataEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
toggleLock(field: string): void {
|
||||
const isLocked = this.bookMetadataForm.get(field + 'Locked')?.value;
|
||||
const isLocked = this.metadataForm.get(field + 'Locked')?.value;
|
||||
const updatedLockedState = !isLocked;
|
||||
this.bookMetadataForm.get(field + 'Locked')?.setValue(updatedLockedState);
|
||||
this.metadataForm.get(field + 'Locked')?.setValue(updatedLockedState);
|
||||
if (updatedLockedState) {
|
||||
this.bookMetadataForm.get(field)?.disable();
|
||||
this.metadataForm.get(field)?.disable();
|
||||
} else {
|
||||
this.bookMetadataForm.get(field)?.enable();
|
||||
this.metadataForm.get(field)?.enable();
|
||||
}
|
||||
this.updateMetadata();
|
||||
}
|
||||
|
||||
lockAll(): void {
|
||||
Object.keys(this.bookMetadataForm.controls).forEach((key) => {
|
||||
Object.keys(this.metadataForm.controls).forEach((key) => {
|
||||
if (key.endsWith('Locked')) {
|
||||
this.bookMetadataForm.get(key)?.setValue(true);
|
||||
this.metadataForm.get(key)?.setValue(true);
|
||||
const fieldName = key.replace('Locked', '');
|
||||
this.bookMetadataForm.get(fieldName)?.disable();
|
||||
this.metadataForm.get(fieldName)?.disable();
|
||||
}
|
||||
});
|
||||
this.updateMetadata();
|
||||
}
|
||||
|
||||
unlockAll(): void {
|
||||
Object.keys(this.bookMetadataForm.controls).forEach((key) => {
|
||||
Object.keys(this.metadataForm.controls).forEach((key) => {
|
||||
if (key.endsWith('Locked')) {
|
||||
this.bookMetadataForm.get(key)?.setValue(false);
|
||||
this.metadataForm.get(key)?.setValue(false);
|
||||
const fieldName = key.replace('Locked', '');
|
||||
this.bookMetadataForm.get(fieldName)?.enable();
|
||||
this.metadataForm.get(fieldName)?.enable();
|
||||
}
|
||||
});
|
||||
this.updateMetadata();
|
||||
@@ -187,39 +187,39 @@ export class MetadataEditorComponent implements OnInit {
|
||||
private buildMetadata() {
|
||||
const updatedBookMetadata: BookMetadata = {
|
||||
bookId: this.currentBookId,
|
||||
title: this.bookMetadataForm.get('title')?.value,
|
||||
subtitle: this.bookMetadataForm.get('subtitle')?.value,
|
||||
authors: this.bookMetadataForm.get('authors')?.value.split(',').map((author: string) => author.trim()),
|
||||
categories: this.bookMetadataForm.get('categories')?.value.split(',').map((category: string) => category.trim()),
|
||||
publisher: this.bookMetadataForm.get('publisher')?.value,
|
||||
publishedDate: this.bookMetadataForm.get('publishedDate')?.value,
|
||||
isbn10: this.bookMetadataForm.get('isbn10')?.value,
|
||||
isbn13: this.bookMetadataForm.get('isbn13')?.value,
|
||||
description: this.bookMetadataForm.get('description')?.value,
|
||||
pageCount: this.bookMetadataForm.get('pageCount')?.value,
|
||||
rating: this.bookMetadataForm.get('rating')?.value,
|
||||
reviewCount: this.bookMetadataForm.get('reviewCount')?.value,
|
||||
language: this.bookMetadataForm.get('language')?.value,
|
||||
seriesName: this.bookMetadataForm.get('seriesName')?.value,
|
||||
seriesNumber: this.bookMetadataForm.get('seriesNumber')?.value,
|
||||
seriesTotal: this.bookMetadataForm.get('seriesTotal')?.value,
|
||||
title: this.metadataForm.get('title')?.value,
|
||||
subtitle: this.metadataForm.get('subtitle')?.value,
|
||||
authors: this.metadataForm.get('authors')?.value.split(',').map((author: string) => author.trim()),
|
||||
categories: this.metadataForm.get('categories')?.value.split(',').map((category: string) => category.trim()),
|
||||
publisher: this.metadataForm.get('publisher')?.value,
|
||||
publishedDate: this.metadataForm.get('publishedDate')?.value,
|
||||
isbn10: this.metadataForm.get('isbn10')?.value,
|
||||
isbn13: this.metadataForm.get('isbn13')?.value,
|
||||
description: this.metadataForm.get('description')?.value,
|
||||
pageCount: this.metadataForm.get('pageCount')?.value,
|
||||
rating: this.metadataForm.get('rating')?.value,
|
||||
reviewCount: this.metadataForm.get('reviewCount')?.value,
|
||||
language: this.metadataForm.get('language')?.value,
|
||||
seriesName: this.metadataForm.get('seriesName')?.value,
|
||||
seriesNumber: this.metadataForm.get('seriesNumber')?.value,
|
||||
seriesTotal: this.metadataForm.get('seriesTotal')?.value,
|
||||
|
||||
titleLocked: this.bookMetadataForm.get('titleLocked')?.value,
|
||||
subtitleLocked: this.bookMetadataForm.get('subtitleLocked')?.value,
|
||||
authorsLocked: this.bookMetadataForm.get('authorsLocked')?.value,
|
||||
categoriesLocked: this.bookMetadataForm.get('categoriesLocked')?.value,
|
||||
publisherLocked: this.bookMetadataForm.get('publisherLocked')?.value,
|
||||
publishedDateLocked: this.bookMetadataForm.get('publishedDateLocked')?.value,
|
||||
isbn10Locked: this.bookMetadataForm.get('isbn10Locked')?.value,
|
||||
isbn13Locked: this.bookMetadataForm.get('isbn13Locked')?.value,
|
||||
descriptionLocked: this.bookMetadataForm.get('descriptionLocked')?.value,
|
||||
pageCountLocked: this.bookMetadataForm.get('pageCountLocked')?.value,
|
||||
languageLocked: this.bookMetadataForm.get('languageLocked')?.value,
|
||||
ratingLocked: this.bookMetadataForm.get('ratingLocked')?.value,
|
||||
reviewCountLocked: this.bookMetadataForm.get('reviewCountLocked')?.value,
|
||||
seriesNameLocked: this.bookMetadataForm.get('seriesNameLocked')?.value,
|
||||
seriesNumberLocked: this.bookMetadataForm.get('seriesNumberLocked')?.value,
|
||||
seriesTotalLocked: this.bookMetadataForm.get('seriesTotalLocked')?.value,
|
||||
titleLocked: this.metadataForm.get('titleLocked')?.value,
|
||||
subtitleLocked: this.metadataForm.get('subtitleLocked')?.value,
|
||||
authorsLocked: this.metadataForm.get('authorsLocked')?.value,
|
||||
categoriesLocked: this.metadataForm.get('categoriesLocked')?.value,
|
||||
publisherLocked: this.metadataForm.get('publisherLocked')?.value,
|
||||
publishedDateLocked: this.metadataForm.get('publishedDateLocked')?.value,
|
||||
isbn10Locked: this.metadataForm.get('isbn10Locked')?.value,
|
||||
isbn13Locked: this.metadataForm.get('isbn13Locked')?.value,
|
||||
descriptionLocked: this.metadataForm.get('descriptionLocked')?.value,
|
||||
pageCountLocked: this.metadataForm.get('pageCountLocked')?.value,
|
||||
languageLocked: this.metadataForm.get('languageLocked')?.value,
|
||||
ratingLocked: this.metadataForm.get('ratingLocked')?.value,
|
||||
reviewCountLocked: this.metadataForm.get('reviewCountLocked')?.value,
|
||||
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
||||
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
||||
|
||||
};
|
||||
return updatedBookMetadata;
|
||||
|
||||
+75
-2
@@ -1,4 +1,4 @@
|
||||
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="h-full flex pt-1 flex-col">
|
||||
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" *ngIf="bookMetadata$ | async as metadata" class="h-full flex pt-1 flex-col">
|
||||
<div class="overflow-y-scroll flex-1">
|
||||
|
||||
<div class="flex justify-center items-center" [ngStyle]="{'padding-bottom': '0.75rem', 'padding-left': '4.95rem'}">
|
||||
@@ -16,6 +16,8 @@
|
||||
<div class="form-row">
|
||||
<label for="title" class="label">Title</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['titleLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('title')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['titleLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('title')" severity="warn"></p-button>
|
||||
<input pInputText id="title" formControlName="title" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('title') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -30,6 +32,8 @@
|
||||
<div class="form-row">
|
||||
<label for="authors" class="label">Authors</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['authorsLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('authors')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['authorsLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('authors')" severity="warn"></p-button>
|
||||
<input pInputText id="authors" formControlName="authors" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('authors') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -44,6 +48,8 @@
|
||||
<div class="form-row">
|
||||
<label for="categories" class="label">Categories</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['categoriesLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('categories')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['categoriesLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('categories')" severity="warn"></p-button>
|
||||
<input pInputText id="categories" formControlName="categories" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('categories') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -58,6 +64,8 @@
|
||||
<div class="form-row">
|
||||
<label for="publisher" class="label">Publisher</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['publisherLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publisher')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['publisherLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publisher')" severity="warn"></p-button>
|
||||
<input pInputText id="publisher" formControlName="publisher" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('publisher') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -72,6 +80,8 @@
|
||||
<div class="form-row">
|
||||
<label for="publishedDate" class="label">Published</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['publishedDateLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['publishedDateLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('publishedDate')" severity="warn"></p-button>
|
||||
<input pInputText id="publishedDate" formControlName="publishedDate" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('publishedDate') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -86,6 +96,8 @@
|
||||
<div class="form-row">
|
||||
<label for="isbn10" class="label">ISBN-10</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['isbn10Locked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['isbn10Locked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn10')" severity="warn"></p-button>
|
||||
<input pInputText id="isbn10" formControlName="isbn10" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('isbn10') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -100,6 +112,8 @@
|
||||
<div class="form-row">
|
||||
<label for="language" class="label">Language</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['languageLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('language')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['languageLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('language')" severity="warn"></p-button>
|
||||
<input pInputText id="language" formControlName="language" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('language') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -114,6 +128,8 @@
|
||||
<div class="form-row">
|
||||
<label for="description" class="label">Description</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['descriptionLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('description')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['descriptionLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('description')" severity="warn"></p-button>
|
||||
<textarea id="description" formControlName="description" class="input"></textarea>
|
||||
<p-button
|
||||
[icon]="isValueSaved('description') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -140,9 +156,60 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<label for="seriesName" class="label">Series</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['seriesNameLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['seriesNameLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="warn"></p-button>
|
||||
<input pInputText id="seriesName" formControlName="seriesName" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('seriesName') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('seriesName'), 'yellow-outlined-button': isValueCopied('seriesName')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('seriesName')"/>
|
||||
<input pInputText [value]="fetchedMetadata.seriesName" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="seriesNumber" class="label">Book #</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['seriesNumberLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['seriesNumberLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesNumber')" severity="warn"></p-button>
|
||||
<input pInputText id="seriesNumber" formControlName="seriesNumber" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('seriesNumber') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('seriesNumber'), 'yellow-outlined-button': isValueCopied('seriesNumber')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('seriesNumber')"/>
|
||||
<input pInputText [value]="fetchedMetadata.seriesNumber" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="seriesTotal" class="label">Total Books</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['seriesTotalLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['seriesTotalLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('seriesTotal')" severity="warn"></p-button>
|
||||
<input pInputText id="seriesTotal" formControlName="seriesTotal" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('seriesTotal') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
[outlined]="true"
|
||||
[ngClass]="{'green-outlined-button': isValueSaved('seriesTotal'), 'yellow-outlined-button': isValueCopied('seriesTotal')}"
|
||||
class="arrow-button"
|
||||
(click)="copyFetchedToCurrent('seriesTotal')"/>
|
||||
<input pInputText [value]="fetchedMetadata.seriesTotal" class="input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="isbn13" class="label">ISBN-13</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['isbn13Locked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['isbn13Locked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('isbn13')" severity="warn"></p-button>
|
||||
<input pInputText id="isbn13" formControlName="isbn13" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('isbn13') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -157,6 +224,8 @@
|
||||
<div class="form-row">
|
||||
<label for="rating" class="label">Rating</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['ratingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('rating')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['ratingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('rating')" severity="warn"></p-button>
|
||||
<input pInputText id="rating" formControlName="rating" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -169,8 +238,10 @@
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="reviewCount" class="label">Rating</label>
|
||||
<label for="reviewCount" class="label">Reviews</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['reviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('reviewCount')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['reviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('reviewCount')" severity="warn"></p-button>
|
||||
<input pInputText id="reviewCount" formControlName="reviewCount" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('reviewCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
@@ -185,6 +256,8 @@
|
||||
<div class="form-row">
|
||||
<label for="pageCount" class="label">Pages</label>
|
||||
<div class="input-container">
|
||||
<p-button *ngIf="!metadata['pageCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="success"></p-button>
|
||||
<p-button *ngIf="metadata['pageCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('pageCount')" severity="warn"></p-button>
|
||||
<input pInputText id="pageCount" formControlName="pageCount" class="input"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved('pageCount') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
||||
|
||||
+142
-32
@@ -1,11 +1,10 @@
|
||||
import {Component, EventEmitter, inject, Input, OnInit, Output} from '@angular/core';
|
||||
import {BookMetadata, 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, NgStyle} from '@angular/common';
|
||||
import {AsyncPipe, NgClass, NgIf, NgStyle} from '@angular/common';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {BookMetadataCenterService} from '../book-metadata-center.service';
|
||||
import {Observable} from 'rxjs';
|
||||
@@ -27,7 +26,8 @@ import {UrlHelperService} from '../../../utilities/service/url-helper.service';
|
||||
ReactiveFormsModule,
|
||||
NgClass,
|
||||
NgStyle,
|
||||
Tooltip
|
||||
Tooltip,
|
||||
AsyncPipe
|
||||
]
|
||||
})
|
||||
export class MetadataPickerComponent implements OnInit {
|
||||
@@ -42,14 +42,12 @@ export class MetadataPickerComponent implements OnInit {
|
||||
copiedFields: Record<string, boolean> = {};
|
||||
savedFields: Record<string, boolean> = {};
|
||||
|
||||
private bookService = inject(BookService);
|
||||
private metadataCenterService = inject(BookMetadataCenterService);
|
||||
private messageService = inject(MessageService);
|
||||
private metadataService = inject(MetadataService);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
|
||||
currentMetadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
|
||||
protected metadata!: BookMetadata;
|
||||
bookMetadata$: Observable<BookMetadata | null> = this.metadataCenterService.currentMetadata$;
|
||||
|
||||
constructor() {
|
||||
this.metadataForm = new FormGroup({
|
||||
@@ -66,19 +64,38 @@ export class MetadataPickerComponent implements OnInit {
|
||||
language: new FormControl(''),
|
||||
rating: new FormControl(''),
|
||||
reviewCount: new FormControl(''),
|
||||
seriesName: new FormControl(''),
|
||||
seriesNumber: new FormControl(''),
|
||||
seriesTotal: new FormControl(''),
|
||||
|
||||
titleLocked: new FormControl(false),
|
||||
subtitleLocked: new FormControl(false),
|
||||
authorsLocked: new FormControl(false),
|
||||
categoriesLocked: new FormControl(false),
|
||||
publisherLocked: new FormControl(false),
|
||||
publishedDateLocked: new FormControl(false),
|
||||
isbn10Locked: new FormControl(false),
|
||||
isbn13Locked: new FormControl(false),
|
||||
descriptionLocked: new FormControl(false),
|
||||
pageCountLocked: new FormControl(false),
|
||||
languageLocked: new FormControl(false),
|
||||
ratingLocked: new FormControl(false),
|
||||
reviewCountLocked: new FormControl(false),
|
||||
seriesNameLocked: new FormControl(false),
|
||||
seriesNumberLocked: new FormControl(false),
|
||||
seriesTotalLocked: new FormControl(false),
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.currentMetadata$.subscribe((metadata) => {
|
||||
this.bookMetadata$.subscribe((metadata) => {
|
||||
if (metadata) {
|
||||
this.currentBookId = metadata.bookId;
|
||||
this.metadata = metadata;
|
||||
this.metadataForm.setValue({
|
||||
title: metadata.title,
|
||||
subtitle: metadata.subtitle,
|
||||
authors: metadata.authors.map((author) => author.name).join(', '),
|
||||
categories: metadata.categories.map((category) => category.name).join(', '),
|
||||
authors: metadata.authors.map((author) => author.name).sort().join(', '),
|
||||
categories: metadata.categories.map((category) => category.name).sort().join(', '),
|
||||
publisher: metadata.publisher,
|
||||
publishedDate: metadata.publishedDate,
|
||||
isbn10: metadata.isbn10,
|
||||
@@ -87,8 +104,45 @@ export class MetadataPickerComponent implements OnInit {
|
||||
pageCount: metadata.pageCount == 0 ? null : metadata.pageCount,
|
||||
language: metadata.language,
|
||||
rating: metadata.rating,
|
||||
reviewCount: metadata.reviewCount
|
||||
reviewCount: metadata.reviewCount,
|
||||
seriesName: metadata.seriesName,
|
||||
seriesNumber: metadata.seriesNumber,
|
||||
seriesTotal: metadata.seriesTotal,
|
||||
|
||||
titleLocked: metadata.titleLocked || false,
|
||||
subtitleLocked: metadata.subtitleLocked || false,
|
||||
authorsLocked: metadata.authorsLocked || false,
|
||||
categoriesLocked: metadata.categoriesLocked || false,
|
||||
publisherLocked: metadata.publisherLocked || false,
|
||||
publishedDateLocked: metadata.publishedDateLocked || false,
|
||||
isbn10Locked: metadata.isbn10Locked || false,
|
||||
isbn13Locked: metadata.isbn13Locked || false,
|
||||
descriptionLocked: metadata.descriptionLocked || false,
|
||||
pageCountLocked: metadata.pageCountLocked || false,
|
||||
languageLocked: metadata.languageLocked || false,
|
||||
ratingLocked: metadata.ratingLocked || false,
|
||||
reviewCountLocked: metadata.reviewCountLocked || false,
|
||||
seriesNameLocked: metadata.seriesNameLocked || false,
|
||||
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
||||
seriesTotalLocked: metadata.seriesTotalLocked || false,
|
||||
});
|
||||
|
||||
if (metadata.titleLocked) this.metadataForm.get('title')?.disable();
|
||||
if (metadata.subtitleLocked) this.metadataForm.get('subtitle')?.disable();
|
||||
if (metadata.authorsLocked) this.metadataForm.get('authors')?.disable();
|
||||
if (metadata.categoriesLocked) this.metadataForm.get('categories')?.disable();
|
||||
if (metadata.publisherLocked) this.metadataForm.get('publisher')?.disable();
|
||||
if (metadata.publishedDateLocked) this.metadataForm.get('publishedDate')?.disable();
|
||||
if (metadata.languageLocked) this.metadataForm.get('language')?.disable();
|
||||
if (metadata.isbn10Locked) this.metadataForm.get('isbn10')?.disable();
|
||||
if (metadata.isbn13Locked) this.metadataForm.get('isbn13')?.disable();
|
||||
if (metadata.reviewCountLocked) this.metadataForm.get('reviewCount')?.disable();
|
||||
if (metadata.ratingLocked) this.metadataForm.get('rating')?.disable();
|
||||
if (metadata.pageCountLocked) this.metadataForm.get('pageCount')?.disable();
|
||||
if (metadata.descriptionLocked) this.metadataForm.get('description')?.disable();
|
||||
if (metadata.seriesNameLocked) this.metadataForm.get('seriesName')?.disable();
|
||||
if (metadata.seriesNumberLocked) this.metadataForm.get('seriesNumber')?.disable();
|
||||
if (metadata.seriesTotalLocked) this.metadataForm.get('seriesTotal')?.disable();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -102,24 +156,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
const updatedBookMetadata: BookMetadata = {
|
||||
bookId: this.currentBookId,
|
||||
title: this.metadataForm.get('title')?.value || this.copiedFields['title'] ? this.getValueOrCopied('title') : '',
|
||||
subtitle: this.metadataForm.get('subtitle')?.value || this.copiedFields['subtitle'] ? this.getValueOrCopied('subtitle') : '',
|
||||
authors: this.metadataForm.get('authors')?.value || this.copiedFields['authors'] ? this.getArrayFromFormField('authors', this.fetchedMetadata.authors) : [],
|
||||
categories: this.metadataForm.get('categories')?.value || this.copiedFields['categories'] ? this.getArrayFromFormField('categories', this.fetchedMetadata.categories) : [],
|
||||
publisher: this.metadataForm.get('publisher')?.value || this.copiedFields['publisher'] ? this.getValueOrCopied('publisher') : '',
|
||||
publishedDate: this.metadataForm.get('publishedDate')?.value || this.copiedFields['publishedDate'] ? this.getValueOrCopied('publishedDate') : '',
|
||||
isbn10: this.metadataForm.get('isbn10')?.value || this.copiedFields['isbn10'] ? this.getValueOrCopied('isbn10') : '',
|
||||
isbn13: this.metadataForm.get('isbn13')?.value || this.copiedFields['isbn13'] ? this.getValueOrCopied('isbn13') : '',
|
||||
description: this.metadataForm.get('description')?.value || this.copiedFields['description'] ? this.getValueOrCopied('description') : '',
|
||||
pageCount: this.metadataForm.get('pageCount')?.value || this.copiedFields['pageCount'] ? this.getPageCountOrCopied() : null,
|
||||
language: this.metadataForm.get('language')?.value || this.copiedFields['language'] ? this.getValueOrCopied('language') : '',
|
||||
rating: this.metadataForm.get('rating')?.value || this.copiedFields['rating'] ? this.getNumberOrCopied('rating') : null,
|
||||
reviewCount: this.metadataForm.get('reviewCount')?.value || this.copiedFields['reviewCount'] ? this.getNumberOrCopied('reviewCount') : null,
|
||||
thumbnailUrl: this.updateThumbnailUrl ? this.fetchedMetadata.thumbnailUrl : '',
|
||||
};
|
||||
|
||||
const updatedBookMetadata = this.buildMetadata();
|
||||
this.metadataService.updateBookMetadata(this.currentBookId, updatedBookMetadata).subscribe({
|
||||
next: (bookMetadata) => {
|
||||
Object.keys(this.copiedFields).forEach((field) => {
|
||||
@@ -139,9 +176,74 @@ export class MetadataPickerComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
copyMissing() {
|
||||
private buildMetadata() {
|
||||
const updatedBookMetadata: BookMetadata = {
|
||||
bookId: this.currentBookId,
|
||||
title: this.metadataForm.get('title')?.value || this.copiedFields['title'] ? this.getValueOrCopied('title') : '',
|
||||
subtitle: this.metadataForm.get('subtitle')?.value || this.copiedFields['subtitle'] ? this.getValueOrCopied('subtitle') : '',
|
||||
authors: this.metadataForm.get('authors')?.value || this.copiedFields['authors'] ? this.getArrayFromFormField('authors', this.fetchedMetadata.authors) : [],
|
||||
categories: this.metadataForm.get('categories')?.value || this.copiedFields['categories'] ? this.getArrayFromFormField('categories', this.fetchedMetadata.categories) : [],
|
||||
publisher: this.metadataForm.get('publisher')?.value || this.copiedFields['publisher'] ? this.getValueOrCopied('publisher') : '',
|
||||
publishedDate: this.metadataForm.get('publishedDate')?.value || this.copiedFields['publishedDate'] ? this.getValueOrCopied('publishedDate') : '',
|
||||
isbn10: this.metadataForm.get('isbn10')?.value || this.copiedFields['isbn10'] ? this.getValueOrCopied('isbn10') : '',
|
||||
isbn13: this.metadataForm.get('isbn13')?.value || this.copiedFields['isbn13'] ? this.getValueOrCopied('isbn13') : '',
|
||||
description: this.metadataForm.get('description')?.value || this.copiedFields['description'] ? this.getValueOrCopied('description') : '',
|
||||
pageCount: this.metadataForm.get('pageCount')?.value || this.copiedFields['pageCount'] ? this.getPageCountOrCopied() : null,
|
||||
language: this.metadataForm.get('language')?.value || this.copiedFields['language'] ? this.getValueOrCopied('language') : '',
|
||||
rating: this.metadataForm.get('rating')?.value || this.copiedFields['rating'] ? this.getNumberOrCopied('rating') : null,
|
||||
reviewCount: this.metadataForm.get('reviewCount')?.value || this.copiedFields['reviewCount'] ? this.getNumberOrCopied('reviewCount') : null,
|
||||
seriesName: this.metadataForm.get('seriesName')?.value || this.copiedFields['seriesName'] ? this.getValueOrCopied('seriesName') : '',
|
||||
seriesNumber: this.metadataForm.get('seriesNumber')?.value || this.copiedFields['seriesNumber'] ? this.getNumberOrCopied('seriesNumber') : null,
|
||||
seriesTotal: this.metadataForm.get('seriesTotal')?.value || this.copiedFields['seriesTotal'] ? this.getNumberOrCopied('seriesTotal') : null,
|
||||
thumbnailUrl: this.updateThumbnailUrl ? this.fetchedMetadata.thumbnailUrl : '',
|
||||
|
||||
titleLocked: this.metadataForm.get('titleLocked')?.value,
|
||||
subtitleLocked: this.metadataForm.get('subtitleLocked')?.value,
|
||||
authorsLocked: this.metadataForm.get('authorsLocked')?.value,
|
||||
categoriesLocked: this.metadataForm.get('categoriesLocked')?.value,
|
||||
publisherLocked: this.metadataForm.get('publisherLocked')?.value,
|
||||
publishedDateLocked: this.metadataForm.get('publishedDateLocked')?.value,
|
||||
isbn10Locked: this.metadataForm.get('isbn10Locked')?.value,
|
||||
isbn13Locked: this.metadataForm.get('isbn13Locked')?.value,
|
||||
descriptionLocked: this.metadataForm.get('descriptionLocked')?.value,
|
||||
pageCountLocked: this.metadataForm.get('pageCountLocked')?.value,
|
||||
languageLocked: this.metadataForm.get('languageLocked')?.value,
|
||||
ratingLocked: this.metadataForm.get('ratingLocked')?.value,
|
||||
reviewCountLocked: this.metadataForm.get('reviewCountLocked')?.value,
|
||||
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
||||
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
||||
};
|
||||
return updatedBookMetadata;
|
||||
}
|
||||
|
||||
private updateMetadata(): void {
|
||||
this.metadataService.updateBookMetadata(this.currentBookId, this.buildMetadata()).subscribe({
|
||||
next: (response) => {
|
||||
this.metadataCenterService.emit(response);
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update lock state'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleLock(field: string): void {
|
||||
const isLocked = this.metadataForm.get(field + 'Locked')?.value;
|
||||
const updatedLockedState = !isLocked;
|
||||
this.metadataForm.get(field + 'Locked')?.setValue(updatedLockedState);
|
||||
if (updatedLockedState) {
|
||||
this.metadataForm.get(field)?.disable();
|
||||
} else {
|
||||
this.metadataForm.get(field)?.enable();
|
||||
}
|
||||
this.updateMetadata();
|
||||
}
|
||||
|
||||
copyMissing(): void {
|
||||
Object.keys(this.fetchedMetadata).forEach((field) => {
|
||||
if (!this.metadataForm.get(field)?.value && this.fetchedMetadata[field]) {
|
||||
const isLocked = this.metadataForm.get(`${field}Locked`)?.value;
|
||||
if (!isLocked && !this.metadataForm.get(field)?.value && this.fetchedMetadata[field]) {
|
||||
this.copyFetchedToCurrent(field);
|
||||
}
|
||||
});
|
||||
@@ -190,6 +292,15 @@ export class MetadataPickerComponent implements OnInit {
|
||||
}
|
||||
|
||||
copyFetchedToCurrent(field: string): void {
|
||||
const isLocked = this.metadataForm.get(`${field}Locked`)?.value;
|
||||
if (isLocked) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: 'Action Blocked',
|
||||
detail: `${field} is locked and cannot be updated.`
|
||||
});
|
||||
return;
|
||||
}
|
||||
const value = this.fetchedMetadata[field];
|
||||
if (value) {
|
||||
this.metadataForm.get(field)?.setValue(value);
|
||||
@@ -217,5 +328,4 @@ export class MetadataPickerComponent implements OnInit {
|
||||
closeDialog() {
|
||||
this.metadataCenterService.closeDialog(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-9
@@ -22,9 +22,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
|
||||
allP3 = {placeholder: 'Set All', value: ''};
|
||||
allP2 = {placeholder: 'Set All', value: ''};
|
||||
allP1 = {placeholder: 'Set All', value: ''};
|
||||
allP3 = {placeholder: 'Set All', value: null as string | null};
|
||||
allP2 = {placeholder: 'Set All', value: null as string | null};
|
||||
allP1 = {placeholder: 'Set All', value: null as string | null};
|
||||
|
||||
fieldOptions: FieldOptions = {
|
||||
title: {p3: null, p2: null, p1: null},
|
||||
@@ -43,9 +43,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
this.refreshCovers = this.currentMetadataOptions.refreshCovers || false;
|
||||
this.mergeCategories = this.currentMetadataOptions.mergeCategories || false;
|
||||
this.fieldOptions = this.currentMetadataOptions.fieldOptions || this.fieldOptions;
|
||||
this.allP3.value = this.currentMetadataOptions.allP3 || '';
|
||||
this.allP2.value = this.currentMetadataOptions.allP2 || '';
|
||||
this.allP1.value = this.currentMetadataOptions.allP1 || '';
|
||||
this.allP3.value = this.currentMetadataOptions.allP3 || null;
|
||||
this.allP2.value = this.currentMetadataOptions.allP2 || null;
|
||||
this.allP1.value = this.currentMetadataOptions.allP1 || null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.allP3.value = '';
|
||||
this.allP2.value = '';
|
||||
this.allP1.value = '';
|
||||
this.allP3.value = null;
|
||||
this.allP2.value = null;
|
||||
this.allP1.value = null;
|
||||
for (const field of Object.keys(this.fieldOptions)) {
|
||||
this.fieldOptions[field as keyof FieldOptions] = {
|
||||
p3: null,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export interface MetadataRefreshOptions {
|
||||
allP3: string;
|
||||
allP2: string;
|
||||
allP1: string;
|
||||
allP3: string | null;
|
||||
allP2: string | null;
|
||||
allP1: string | null;
|
||||
refreshCovers: boolean;
|
||||
mergeCategories: boolean;
|
||||
fieldOptions?: FieldOptions;
|
||||
|
||||
@@ -19,8 +19,8 @@ export class MetadataDialogService {
|
||||
header: 'Open book details',
|
||||
modal: true,
|
||||
closable: true,
|
||||
width: '1200px',
|
||||
height: '835px',
|
||||
width: '1400px',
|
||||
height: '875px',
|
||||
showHeader: false,
|
||||
closeOnEscape: true,
|
||||
dismissableMask: true,
|
||||
|
||||
Reference in New Issue
Block a user