From cbe3d51e03488330bbb69e3b1cdc9211e4126169 Mon Sep 17 00:00:00 2001
From: adityachandelgit <>
Date: Wed, 23 Apr 2025 16:45:39 -0600
Subject: [PATCH] Sync field disablement
---
.../metadata-editor.component.html | 6 +--
.../metadata-editor.component.ts | 47 ++++++++++++-------
2 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.html b/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.html
index 7f5042cfa..6f7fe5013 100644
--- a/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.html
+++ b/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.html
@@ -186,16 +186,14 @@
diff --git a/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.ts b/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.ts
index 0dc45b038..5bc657df2 100644
--- a/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.ts
+++ b/booklore-ui/src/app/metadata/book-metadata-center/metadata-editor/metadata-editor.component.ts
@@ -161,24 +161,35 @@ export class MetadataEditorComponent implements OnInit {
thumbnailUrlLocked: metadata.coverLocked || 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.amazonReviewCountLocked) this.metadataForm.get('amazonReviewCount')?.disable();
- if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable();
- if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.disable();
- if (metadata.goodreadsRatingLocked) this.metadataForm.get('goodreadsRating')?.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();
+ const lockableFields: { key: keyof BookMetadata, control: string }[] = [
+ { key: 'titleLocked', control: 'title' },
+ { key: 'subtitleLocked', control: 'subtitle' },
+ { key: 'authorsLocked', control: 'authors' },
+ { key: 'categoriesLocked', control: 'categories' },
+ { key: 'publisherLocked', control: 'publisher' },
+ { key: 'publishedDateLocked', control: 'publishedDate' },
+ { key: 'languageLocked', control: 'language' },
+ { key: 'isbn10Locked', control: 'isbn10' },
+ { key: 'isbn13Locked', control: 'isbn13' },
+ { key: 'amazonReviewCountLocked', control: 'amazonReviewCount' },
+ { key: 'amazonRatingLocked', control: 'amazonRating' },
+ { key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount' },
+ { key: 'goodreadsRatingLocked', control: 'goodreadsRating' },
+ { key: 'pageCountLocked', control: 'pageCount' },
+ { key: 'descriptionLocked', control: 'description' },
+ { key: 'seriesNameLocked', control: 'seriesName' },
+ { key: 'seriesNumberLocked', control: 'seriesNumber' },
+ { key: 'seriesTotalLocked', control: 'seriesTotal' }
+ ];
+
+ lockableFields.forEach(({ key, control }) => {
+ const isLocked = metadata[key] === true;
+ const formControl = this.metadataForm.get(control);
+ if (formControl) {
+ isLocked ? formControl.disable() : formControl.enable();
+ }
+ });
+
this.metadataForm.get('reviewCount')?.disable();
this.metadataForm.get('rating')?.disable();
}