Allow metadata fields to be explicitly cleared
This commit is contained in:
committed by
Aditya Chandel
parent
df233d8f95
commit
e8cd58cd42
+1
-1
@@ -6,7 +6,7 @@
|
||||
@if (isLoading) {
|
||||
<p-progressSpinner [style]="{position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)'}"></p-progressSpinner>
|
||||
}
|
||||
<div class="flex-grow overflow-auto p-4">
|
||||
<div class="flex-grow overflow-auto py-2 px-2">
|
||||
<div class="flex flex-row w-full gap-4">
|
||||
<div class="flex flex-col items-center gap-2 relative">
|
||||
<img
|
||||
|
||||
+115
-64
@@ -6,7 +6,7 @@ import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular
|
||||
import {Observable} from 'rxjs';
|
||||
import {AsyncPipe, NgClass} from '@angular/common';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Book, BookMetadata} from '../../../model/book.model';
|
||||
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../model/book.model';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {FileUpload, FileUploadErrorEvent, FileUploadEvent} from 'primeng/fileupload';
|
||||
import {HttpResponse} from '@angular/common/http';
|
||||
@@ -77,6 +77,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
refreshingBookIds = new Set<number>();
|
||||
isAutoFetching = false;
|
||||
|
||||
originalMetadata!: BookMetadata;
|
||||
|
||||
constructor() {
|
||||
this.metadataForm = new FormGroup({
|
||||
title: new FormControl(''),
|
||||
@@ -90,9 +92,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
description: new FormControl(''),
|
||||
pageCount: new FormControl(''),
|
||||
language: new FormControl(''),
|
||||
rating: new FormControl(''),
|
||||
reviewCount: new FormControl(''),
|
||||
asin: new FormControl(''),
|
||||
personalRating: new FormControl(''),
|
||||
amazonRating: new FormControl(''),
|
||||
amazonReviewCount: new FormControl(''),
|
||||
goodreadsId: new FormControl(''),
|
||||
@@ -118,6 +119,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
pageCountLocked: new FormControl(false),
|
||||
languageLocked: new FormControl(false),
|
||||
asinLocked: new FormControl(false),
|
||||
personalRatingLocked: new FormControl(false),
|
||||
amazonRatingLocked: new FormControl(false),
|
||||
amazonReviewCountLocked: new FormControl(false),
|
||||
goodreadsIdLocked: new FormControl(''),
|
||||
@@ -148,6 +150,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
this.isAutoFetching = false;
|
||||
}
|
||||
|
||||
this.originalMetadata = structuredClone(metadata);
|
||||
|
||||
if (this.quillEditor?.quill) {
|
||||
this.quillEditor.quill.root.innerHTML = metadata.description;
|
||||
this.quillDisabled();
|
||||
@@ -181,6 +185,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
rating: metadata.rating ?? null,
|
||||
reviewCount: metadata.reviewCount ?? null,
|
||||
asin: metadata.asin ?? null,
|
||||
personalRating: metadata.personalRating ?? null,
|
||||
amazonRating: metadata.amazonRating ?? null,
|
||||
amazonReviewCount: metadata.amazonReviewCount ?? null,
|
||||
goodreadsId: metadata.goodreadsId ?? null,
|
||||
@@ -205,6 +210,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
pageCountLocked: metadata.pageCountLocked ?? false,
|
||||
languageLocked: metadata.languageLocked ?? false,
|
||||
asinLocked: metadata.asinLocked ?? false,
|
||||
personalRatingLocked: metadata.personalRatingLocked ?? false,
|
||||
amazonRatingLocked: metadata.amazonRatingLocked ?? false,
|
||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked ?? false,
|
||||
goodreadsIdLocked: metadata.goodreadsIdLocked ?? false,
|
||||
@@ -233,6 +239,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{key: 'asinLocked', control: 'asin'},
|
||||
{key: 'amazonReviewCountLocked', control: 'amazonReviewCount'},
|
||||
{key: 'amazonRatingLocked', control: 'amazonRating'},
|
||||
{key: 'personalRatingLocked', control: 'personalRating'},
|
||||
{key: 'goodreadsIdLocked', control: 'goodreadsId'},
|
||||
{key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount'},
|
||||
{key: 'goodreadsRatingLocked', control: 'goodreadsRating'},
|
||||
@@ -254,21 +261,17 @@ export class MetadataEditorComponent implements OnInit {
|
||||
isLocked ? formControl.disable() : formControl.enable();
|
||||
}
|
||||
}
|
||||
|
||||
this.metadataForm.get('reviewCount')?.disable();
|
||||
this.metadataForm.get('rating')?.disable();
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
this.isSaving = true;
|
||||
this.bookService.updateBookMetadata(this.currentBookId, this.buildMetadata(undefined), false).subscribe({
|
||||
this.bookService.updateBookMetadata(this.currentBookId, this.buildMetadataWrapper(undefined), false).subscribe({
|
||||
next: (response) => {
|
||||
this.isSaving = false;
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
},
|
||||
error: (err) => {
|
||||
this.isSaving = false;
|
||||
console.error('Update metadata failed:', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
@@ -327,69 +330,117 @@ export class MetadataEditorComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
private buildMetadata(shouldLockAllFields: boolean | undefined) {
|
||||
const updatedBookMetadata: BookMetadata = {
|
||||
private buildMetadataWrapper(shouldLockAllFields?: boolean): MetadataUpdateWrapper {
|
||||
const form = this.metadataForm;
|
||||
|
||||
const metadata: BookMetadata = {
|
||||
bookId: this.currentBookId,
|
||||
title: this.metadataForm.get('title')?.value,
|
||||
subtitle: this.metadataForm.get('subtitle')?.value,
|
||||
authors: this.metadataForm.get('authors')?.value ?? [],
|
||||
categories: this.metadataForm.get('categories')?.value ?? [],
|
||||
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,
|
||||
asin: this.metadataForm.get('asin')?.value,
|
||||
amazonRating: this.metadataForm.get('amazonRating')?.value,
|
||||
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value,
|
||||
goodreadsId: this.metadataForm.get('goodreadsId')?.value,
|
||||
goodreadsRating: this.metadataForm.get('goodreadsRating')?.value,
|
||||
goodreadsReviewCount: this.metadataForm.get('goodreadsReviewCount')?.value,
|
||||
hardcoverId: this.metadataForm.get('hardcoverId')?.value,
|
||||
hardcoverRating: this.metadataForm.get('hardcoverRating')?.value,
|
||||
hardcoverReviewCount: this.metadataForm.get('hardcoverReviewCount')?.value,
|
||||
googleId: this.metadataForm.get('googleId')?.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,
|
||||
title: form.get('title')?.value,
|
||||
subtitle: form.get('subtitle')?.value,
|
||||
authors: form.get('authors')?.value ?? [],
|
||||
categories: form.get('categories')?.value ?? [],
|
||||
publisher: form.get('publisher')?.value,
|
||||
publishedDate: form.get('publishedDate')?.value,
|
||||
isbn10: form.get('isbn10')?.value,
|
||||
isbn13: form.get('isbn13')?.value,
|
||||
description: form.get('description')?.value,
|
||||
pageCount: form.get('pageCount')?.value,
|
||||
rating: form.get('rating')?.value,
|
||||
reviewCount: form.get('reviewCount')?.value,
|
||||
asin: form.get('asin')?.value,
|
||||
personalRating: form.get('personalRating')?.value,
|
||||
amazonRating: form.get('amazonRating')?.value,
|
||||
amazonReviewCount: form.get('amazonReviewCount')?.value,
|
||||
goodreadsId: form.get('goodreadsId')?.value,
|
||||
goodreadsRating: form.get('goodreadsRating')?.value,
|
||||
goodreadsReviewCount: form.get('goodreadsReviewCount')?.value,
|
||||
hardcoverId: form.get('hardcoverId')?.value,
|
||||
hardcoverRating: form.get('hardcoverRating')?.value,
|
||||
hardcoverReviewCount: form.get('hardcoverReviewCount')?.value,
|
||||
googleId: form.get('googleId')?.value,
|
||||
language: form.get('language')?.value,
|
||||
seriesName: form.get('seriesName')?.value,
|
||||
seriesNumber: form.get('seriesNumber')?.value,
|
||||
seriesTotal: form.get('seriesTotal')?.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,
|
||||
asinLocked: this.metadataForm.get('asinLocked')?.value,
|
||||
amazonRatingLocked: this.metadataForm.get('amazonRatingLocked')?.value,
|
||||
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
||||
goodreadsIdLocked: this.metadataForm.get('goodreadsIdLocked')?.value,
|
||||
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
|
||||
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
|
||||
hardcoverIdLocked: this.metadataForm.get('hardcoverIdLocked')?.value,
|
||||
hardcoverRatingLocked: this.metadataForm.get('hardcoverRatingLocked')?.value,
|
||||
hardcoverReviewCountLocked: this.metadataForm.get('hardcoverReviewCountLocked')?.value,
|
||||
googleIdLocked: this.metadataForm.get('googleIdLocked')?.value,
|
||||
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
||||
seriesTotalLocked: this.metadataForm.get('seriesTotalLocked')?.value,
|
||||
coverLocked: this.metadataForm.get('thumbnailUrlLocked')?.value,
|
||||
// Locks
|
||||
titleLocked: form.get('titleLocked')?.value,
|
||||
subtitleLocked: form.get('subtitleLocked')?.value,
|
||||
authorsLocked: form.get('authorsLocked')?.value,
|
||||
categoriesLocked: form.get('categoriesLocked')?.value,
|
||||
publisherLocked: form.get('publisherLocked')?.value,
|
||||
publishedDateLocked: form.get('publishedDateLocked')?.value,
|
||||
isbn10Locked: form.get('isbn10Locked')?.value,
|
||||
isbn13Locked: form.get('isbn13Locked')?.value,
|
||||
descriptionLocked: form.get('descriptionLocked')?.value,
|
||||
pageCountLocked: form.get('pageCountLocked')?.value,
|
||||
languageLocked: form.get('languageLocked')?.value,
|
||||
asinLocked: form.get('asinLocked')?.value,
|
||||
amazonRatingLocked: form.get('amazonRatingLocked')?.value,
|
||||
personalRatingLocked: form.get('personalRatingLocked')?.value,
|
||||
amazonReviewCountLocked: form.get('amazonReviewCountLocked')?.value,
|
||||
goodreadsIdLocked: form.get('goodreadsIdLocked')?.value,
|
||||
goodreadsRatingLocked: form.get('goodreadsRatingLocked')?.value,
|
||||
goodreadsReviewCountLocked: form.get('goodreadsReviewCountLocked')?.value,
|
||||
hardcoverIdLocked: form.get('hardcoverIdLocked')?.value,
|
||||
hardcoverRatingLocked: form.get('hardcoverRatingLocked')?.value,
|
||||
hardcoverReviewCountLocked: form.get('hardcoverReviewCountLocked')?.value,
|
||||
googleIdLocked: form.get('googleIdLocked')?.value,
|
||||
seriesNameLocked: form.get('seriesNameLocked')?.value,
|
||||
seriesNumberLocked: form.get('seriesNumberLocked')?.value,
|
||||
seriesTotalLocked: form.get('seriesTotalLocked')?.value,
|
||||
coverLocked: form.get('thumbnailUrlLocked')?.value,
|
||||
|
||||
...(shouldLockAllFields !== undefined && {allFieldsLocked: shouldLockAllFields}),
|
||||
...(shouldLockAllFields !== undefined && {allFieldsLocked: shouldLockAllFields})
|
||||
};
|
||||
return updatedBookMetadata;
|
||||
|
||||
const original = this.originalMetadata;
|
||||
|
||||
const wasCleared = (key: keyof BookMetadata): boolean => {
|
||||
const current = (metadata[key] as any) ?? null;
|
||||
const prev = (original[key] as any) ?? null;
|
||||
|
||||
const isEmpty = (val: any): boolean =>
|
||||
val === null || val === '' || (Array.isArray(val) && val.length === 0);
|
||||
|
||||
return isEmpty(current) && !isEmpty(prev);
|
||||
};
|
||||
|
||||
const clearFlags: MetadataClearFlags = {
|
||||
title: wasCleared('title'),
|
||||
subtitle: wasCleared('subtitle'),
|
||||
authors: wasCleared('authors'),
|
||||
categories: wasCleared('categories'),
|
||||
publisher: wasCleared('publisher'),
|
||||
publishedDate: wasCleared('publishedDate'),
|
||||
isbn10: wasCleared('isbn10'),
|
||||
isbn13: wasCleared('isbn13'),
|
||||
description: wasCleared('description'),
|
||||
pageCount: wasCleared('pageCount'),
|
||||
language: wasCleared('language'),
|
||||
asin: wasCleared('asin'),
|
||||
personalRating: wasCleared('personalRating'),
|
||||
amazonRating: wasCleared('personalRating'),
|
||||
amazonReviewCount: wasCleared('amazonReviewCount'),
|
||||
goodreadsId: wasCleared('goodreadsId'),
|
||||
goodreadsRating: wasCleared('goodreadsRating'),
|
||||
goodreadsReviewCount: wasCleared('goodreadsReviewCount'),
|
||||
hardcoverId: wasCleared('hardcoverId'),
|
||||
hardcoverRating: wasCleared('hardcoverRating'),
|
||||
hardcoverReviewCount: wasCleared('hardcoverReviewCount'),
|
||||
googleId: wasCleared('googleId'),
|
||||
seriesName: wasCleared('seriesName'),
|
||||
seriesNumber: wasCleared('seriesNumber'),
|
||||
seriesTotal: wasCleared('seriesTotal'),
|
||||
cover: false
|
||||
};
|
||||
|
||||
return {metadata, clearFlags};
|
||||
}
|
||||
|
||||
private updateMetadata(shouldLockAllFields: boolean | undefined): void {
|
||||
this.bookService.updateBookMetadata(this.currentBookId, this.buildMetadata(shouldLockAllFields), false).subscribe({
|
||||
let metadataUpdateWrapper = this.buildMetadataWrapper(shouldLockAllFields);
|
||||
this.bookService.updateBookMetadata(this.currentBookId, metadataUpdateWrapper, false).subscribe({
|
||||
next: (response) => {
|
||||
if (shouldLockAllFields !== undefined) {
|
||||
this.messageService.add({
|
||||
|
||||
+47
-5
@@ -1,5 +1,5 @@
|
||||
import {Component, DestroyRef, EventEmitter, inject, Input, OnInit, Output} from '@angular/core';
|
||||
import {Book, BookMetadata} from '../../../model/book.model';
|
||||
import {Book, BookMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../model/book.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
@@ -127,6 +127,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
pageCountLocked: new FormControl(false),
|
||||
languageLocked: new FormControl(false),
|
||||
asinLocked: new FormControl(false),
|
||||
personalRatingLocked: new FormControl(false),
|
||||
amazonRatingLocked: new FormControl(false),
|
||||
amazonReviewCountLocked: new FormControl(false),
|
||||
goodreadsIdLocked: new FormControl(false),
|
||||
@@ -193,6 +194,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
pageCountLocked: metadata.pageCountLocked || false,
|
||||
languageLocked: metadata.languageLocked || false,
|
||||
asinLocked: metadata.asinLocked || false,
|
||||
personalRatingLocked: metadata.personalRatingLocked || false,
|
||||
amazonRatingLocked: metadata.amazonRatingLocked || false,
|
||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
||||
goodreadsIdLocked: metadata.goodreadsIdLocked || false,
|
||||
@@ -218,6 +220,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
if (metadata.isbn10Locked) this.metadataForm.get('isbn10')?.disable();
|
||||
if (metadata.isbn13Locked) this.metadataForm.get('isbn13')?.disable();
|
||||
if (metadata.asinLocked) this.metadataForm.get('asin')?.disable();
|
||||
if (metadata.personalRatingLocked) this.metadataForm.get('personalRating')?.disable();
|
||||
if (metadata.amazonReviewCountLocked) this.metadataForm.get('amazonReviewCount')?.disable();
|
||||
if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable();
|
||||
if (metadata.googleIdLocked) this.metadataForm.get('googleIdCount')?.disable();
|
||||
@@ -238,7 +241,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
onSave(): void {
|
||||
this.isSaving = true;
|
||||
const updatedBookMetadata = this.buildMetadata(undefined);
|
||||
const updatedBookMetadata = this.buildMetadataWrapper(undefined);
|
||||
this.bookService.updateBookMetadata(this.currentBookId, updatedBookMetadata, false).subscribe({
|
||||
next: (bookMetadata) => {
|
||||
this.isSaving = false;
|
||||
@@ -256,7 +259,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private buildMetadata(shouldLockAllFields: boolean | undefined) {
|
||||
private buildMetadataWrapper(shouldLockAllFields: boolean | undefined): MetadataUpdateWrapper {
|
||||
const updatedBookMetadata: BookMetadata = {
|
||||
bookId: this.currentBookId,
|
||||
title: this.metadataForm.get('title')?.value || this.copiedFields['title'] ? this.getValueOrCopied('title') : '',
|
||||
@@ -271,6 +274,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
pageCount: this.metadataForm.get('pageCount')?.value || this.copiedFields['pageCount'] ? this.getPageCountOrCopied() : null,
|
||||
language: this.metadataForm.get('language')?.value || this.copiedFields['language'] ? this.getValueOrCopied('language') : '',
|
||||
asin: this.metadataForm.get('asin')?.value || this.copiedFields['asin'] ? this.getValueOrCopied('asin') : '',
|
||||
personalRating: this.metadataForm.get('personalRating')?.value || this.copiedFields['personalRating'] ? this.getNumberOrCopied('personalRating') : null,
|
||||
amazonRating: this.metadataForm.get('amazonRating')?.value || this.copiedFields['amazonRating'] ? this.getNumberOrCopied('amazonRating') : null,
|
||||
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value || this.copiedFields['amazonReviewCount'] ? this.getNumberOrCopied('amazonReviewCount') : null,
|
||||
goodreadsId: this.metadataForm.get('goodreadsId')?.value || this.copiedFields['goodreadsId'] ? this.getValueOrCopied('goodreadsId') : '',
|
||||
@@ -297,6 +301,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
pageCountLocked: this.metadataForm.get('pageCountLocked')?.value,
|
||||
languageLocked: this.metadataForm.get('languageLocked')?.value,
|
||||
asinLocked: this.metadataForm.get('asinLocked')?.value,
|
||||
personalRatingLocked: this.metadataForm.get('personalRatingLocked')?.value,
|
||||
amazonRatingLocked: this.metadataForm.get('amazonRatingLocked')?.value,
|
||||
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
||||
goodreadsIdLocked: this.metadataForm.get('goodreadsIdLocked')?.value,
|
||||
@@ -313,7 +318,44 @@ export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
...(shouldLockAllFields !== undefined && {allFieldsLocked: shouldLockAllFields}),
|
||||
};
|
||||
return updatedBookMetadata;
|
||||
|
||||
const clearFlags: MetadataClearFlags = this.inferClearFlags(updatedBookMetadata, this.originalMetadata);
|
||||
|
||||
return {
|
||||
metadata: updatedBookMetadata,
|
||||
clearFlags: clearFlags
|
||||
};
|
||||
}
|
||||
|
||||
private inferClearFlags(current: BookMetadata, original: BookMetadata): MetadataClearFlags {
|
||||
return {
|
||||
title: !current.title && !!original.title,
|
||||
subtitle: !current.subtitle && !!original.subtitle,
|
||||
authors: current.authors?.length === 0 && original.authors?.length! > 0,
|
||||
categories: current.categories?.length === 0 && original.categories?.length! > 0,
|
||||
publisher: !current.publisher && !!original.publisher,
|
||||
publishedDate: !current.publishedDate && !!original.publishedDate,
|
||||
isbn10: !current.isbn10 && !!original.isbn10,
|
||||
isbn13: !current.isbn13 && !!original.isbn13,
|
||||
description: !current.description && !!original.description,
|
||||
pageCount: current.pageCount === null && original.pageCount !== null,
|
||||
language: !current.language && !!original.language,
|
||||
asin: !current.asin && !!original.asin,
|
||||
amazonRating: current.amazonRating === null && original.amazonRating !== null,
|
||||
amazonReviewCount: current.amazonReviewCount === null && original.amazonReviewCount !== null,
|
||||
goodreadsId: !current.goodreadsId && !!original.goodreadsId,
|
||||
goodreadsRating: current.goodreadsRating === null && original.goodreadsRating !== null,
|
||||
goodreadsReviewCount: current.goodreadsReviewCount === null && original.goodreadsReviewCount !== null,
|
||||
hardcoverId: !current.hardcoverId && !!original.hardcoverId,
|
||||
hardcoverRating: current.hardcoverRating === null && original.hardcoverRating !== null,
|
||||
hardcoverReviewCount: current.hardcoverReviewCount === null && original.hardcoverReviewCount !== null,
|
||||
googleId: !current.googleId && !!original.googleId,
|
||||
seriesName: !current.seriesName && !!original.seriesName,
|
||||
seriesNumber: current.seriesNumber === null && original.seriesNumber !== null,
|
||||
seriesTotal: current.seriesTotal === null && original.seriesTotal !== null,
|
||||
cover: !current.thumbnailUrl && !!original.thumbnailUrl,
|
||||
personalRating: current.personalRating === null && original.personalRating !== null,
|
||||
};
|
||||
}
|
||||
|
||||
getThumbnail() {
|
||||
@@ -325,7 +367,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
}
|
||||
|
||||
private updateMetadata(shouldLockAllFields: boolean | undefined): void {
|
||||
this.bookService.updateBookMetadata(this.currentBookId, this.buildMetadata(shouldLockAllFields), false).subscribe({
|
||||
this.bookService.updateBookMetadata(this.currentBookId, this.buildMetadataWrapper(shouldLockAllFields), false).subscribe({
|
||||
next: (response) => {
|
||||
if (shouldLockAllFields !== undefined) {
|
||||
this.messageService.add({
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@
|
||||
<img [src]="metadata.thumbnailUrl || 'assets/images/missing-cover.jpg'" alt="Image" class="img-fixed-dimensions pr-2"/>
|
||||
<div class=" flex flex-col w-full m-2">
|
||||
<div class="flex flex-row gap-4 justify-between">
|
||||
<p class="font-bold">{{ truncateText(metadata['title'], 90) }}</p>
|
||||
<p class="font-bold">{{ truncateText(metadata['title']!, 90) }}</p>
|
||||
<div class="flex gap-2">
|
||||
<p>ISBN: {{ metadata['isbn10'] || metadata['asin'] }}</p>
|
||||
<p> | </p>
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<p>by {{ truncateText(metadata['authors'].join(', '), 70) }}</p>
|
||||
<p>by {{ truncateText(metadata['authors']!.join(', '), 70) }}</p>
|
||||
<p> | </p>
|
||||
<p>Source: <span [innerHTML]="buildProviderLink(metadata)"></span></p>
|
||||
</div>
|
||||
|
||||
+19
-19
@@ -1,4 +1,4 @@
|
||||
<div class="pt-2 flex flex-col h-full">
|
||||
<div class="pt-2 flex flex-col h-full px-2 w-full">
|
||||
@if (book$ | async; as book) {
|
||||
<div>
|
||||
<div class="flex flex-row">
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
</div>
|
||||
<div class="flex flex-col justify-between">
|
||||
<div class="pl-6 flex flex-col w-full">
|
||||
<div class="pl-6 flex flex-col">
|
||||
<div class="flex flex-row items-center justify-between">
|
||||
<div>
|
||||
@if (book?.metadata!.seriesName) {
|
||||
@@ -55,7 +55,6 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 pt-2">
|
||||
<div class="flex items-center gap-2">
|
||||
<i class="pi pi-thumbs-up-fill"
|
||||
@@ -142,12 +141,14 @@
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="flex gap-2 pt-4 overflow-x-auto scrollbar-hide">
|
||||
@for (category of book?.metadata!.categories; track category) {
|
||||
<a (click)="goToCategory(category)" class="shrink-0 no-underline cursor-pointer">
|
||||
<p-tag [value]="category"></p-tag>
|
||||
</a>
|
||||
}
|
||||
<div class="overflow-x-auto pt-4 scrollbar-hide max-w-full w-full">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
@for (category of book?.metadata!.categories; track category) {
|
||||
<a (click)="goToCategory(category)" class="shrink-0 no-underline cursor-pointer">
|
||||
<p-tag [value]="category"></p-tag>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid gap-x-20 gap-y-2 pt-6" style="grid-template-columns: repeat(5, max-content);">
|
||||
<div>
|
||||
@@ -162,7 +163,7 @@
|
||||
<p-menu #menu [popup]="true" [model]="readStatusMenuItems"></p-menu>
|
||||
</p>
|
||||
</div>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Publisher:</span> {{ book?.metadata!.publisher || '-' }}</p>
|
||||
<p class="whitespace-nowrap max-w-[250px] overflow-hidden text-ellipsis"><span class="font-bold">Publisher:</span> {{ book?.metadata!.publisher || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Published:</span> {{ book?.metadata!.publishedDate || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">Language:</span> {{ book?.metadata!.language || '-' }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">ISBN 10:</span> {{ book?.metadata!.isbn10 || '-' }}</p>
|
||||
@@ -199,7 +200,7 @@
|
||||
<p class="whitespace-nowrap"><span class="font-bold">File Size:</span> {{ getFileSizeInMB(book) }}</p>
|
||||
<p class="whitespace-nowrap"><span class="font-bold">ISBN 13:</span> {{ book?.metadata!.isbn13 || '-' }}</p>
|
||||
</div>
|
||||
<div class="pt-2 flex items-center gap-2 w-full">
|
||||
<div class="pt-2 flex items-center gap-2">
|
||||
<span class="font-semibold flex-shrink-0">File Path:</span>
|
||||
<p-toggleButton
|
||||
[(ngModel)]="showFilePath"
|
||||
@@ -214,7 +215,7 @@
|
||||
class="flex items-center gap-4 flex-grow"
|
||||
style="min-width: 0;">
|
||||
<p
|
||||
class="font-mono text-sm text-gray-400 overflow-x-auto whitespace-nowrap flex-grow"
|
||||
class="font-mono text-sm text-gray-400 whitespace-nowrap flex-grow"
|
||||
style="min-width: 0;">
|
||||
{{ book?.filePath }}
|
||||
</p>
|
||||
@@ -298,7 +299,6 @@
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
|
||||
<div class="flex-1 space-y-2 px-2">
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }" class="transition-all duration-300 overflow-hidden description-container">
|
||||
<div class="readonly-editor px-2">
|
||||
@@ -311,12 +311,12 @@
|
||||
@if (book.metadata!.description && book.metadata!.description.length > 100) {
|
||||
<div class="text-left">
|
||||
<button pButton
|
||||
type="button"
|
||||
[label]="isExpanded ? 'Show less' : 'Show more'"
|
||||
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
|
||||
iconPos="right"
|
||||
class="p-button-text p-button-sm"
|
||||
(click)="toggleExpand()">
|
||||
type="button"
|
||||
[label]="isExpanded ? 'Show less' : 'Show more'"
|
||||
[icon]="isExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'"
|
||||
iconPos="right"
|
||||
class="p-button-text p-button-sm"
|
||||
(click)="toggleExpand()">
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
+22
-10
@@ -6,7 +6,7 @@ import {BookService} from '../../../service/book.service';
|
||||
import {Rating, RatingRateEvent} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Tag} from 'primeng/tag';
|
||||
import {Book, BookMetadata, BookRecommendation, ReadStatus} from '../../../model/book.model';
|
||||
import {Book, BookMetadata, BookRecommendation, MetadataClearFlags, MetadataUpdateWrapper, ReadStatus} from '../../../model/book.model';
|
||||
import {Divider} from 'primeng/divider';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
@@ -346,17 +346,29 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
return 'bg-blue-500';
|
||||
}
|
||||
|
||||
onPersonalRatingChange(book: Book, event: RatingRateEvent): void {
|
||||
const rating = event.value;
|
||||
if (!book || !book.metadata) return;
|
||||
const updatedMetadata = {
|
||||
...book.metadata,
|
||||
personalRating: rating
|
||||
};
|
||||
this.bookService.updateBookMetadata(book.id, updatedMetadata, false).subscribe({
|
||||
onPersonalRatingChange(book: Book, { value: personalRating }: RatingRateEvent): void {
|
||||
if (!book?.metadata) return;
|
||||
|
||||
const updatedMetadata = { ...book.metadata, personalRating };
|
||||
|
||||
this.bookService.updateBookMetadata(book.id, {
|
||||
metadata: updatedMetadata,
|
||||
clearFlags: { personalRating: false }
|
||||
}, false).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Rating Saved',
|
||||
detail: 'Personal rating updated successfully'
|
||||
});
|
||||
},
|
||||
error: (err) => {
|
||||
error: err => {
|
||||
console.error('Failed to update personal rating:', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Update Failed',
|
||||
detail: 'Could not update personal rating'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user