Sync field disablement
This commit is contained in:
+2
-4
@@ -186,16 +186,14 @@
|
||||
<label for="reviewCount">Rating Count (Legacy)</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input [disabled]="true" pInputText id="reviewCount" formControlName="reviewCount" class="w-full"/>
|
||||
<p-button disabled *ngIf="!metadata['reviewCountLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('reviewCount')" severity="success"></p-button>
|
||||
<p-button disabled *ngIf="metadata['reviewCountLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('reviewCount')" severity="warn"></p-button>
|
||||
<p-button disabled icon="pi pi-lock" [outlined]="true" severity="warn"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/4">
|
||||
<label for="rating">Rating (Legacy)</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input [disabled]="true" pInputText id="rating" formControlName="rating" class="w-full"/>
|
||||
<p-button disabled *ngIf="!metadata['ratingLocked']" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('rating')" severity="success"></p-button>
|
||||
<p-button disabled *ngIf="metadata['ratingLocked']" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('rating')" severity="warn"></p-button>
|
||||
<p-button disabled icon="pi pi-lock" [outlined]="true" severity="warn"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+29
-18
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user