Fix multi-book review dialog to accurately reflect current state (#1111)
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@
|
||||
|
||||
<p-divider></p-divider>
|
||||
|
||||
<div class="flex justify-end px-4">
|
||||
<div class="flex justify-end px-4 pt-4">
|
||||
<p-button icon="pi pi-refresh" label="Reset" outlined="true" severity="warn" (onClick)="resetFieldLocks()"></p-button>
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<div class="flex gap-4 justify-center">
|
||||
|
||||
+18
-14
@@ -22,10 +22,10 @@
|
||||
<div class="form-row">
|
||||
<label class="label"></label>
|
||||
<div class="input-container">
|
||||
@if (!book.metadata!['coverLocked']) {
|
||||
@if (!metadataForm.get('coverLocked')?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['coverLocked']) {
|
||||
@if (metadataForm.get('coverLocked')?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('thumbnailUrl')" severity="warn"></p-button>
|
||||
}
|
||||
<p-image
|
||||
@@ -65,13 +65,14 @@
|
||||
<div class="form-row">
|
||||
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
|
||||
<div class="input-container">
|
||||
@if (!book.metadata![field.lockedKey]) {
|
||||
@if (!metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
@if (metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<input pSize="small" fluid pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||
<input pSize="small" fluid pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"
|
||||
[disabled]="metadataForm.get(field.lockedKey)?.value"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||
[outlined]="true"
|
||||
@@ -93,10 +94,10 @@
|
||||
<div class="form-row">
|
||||
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
|
||||
<div class="input-container">
|
||||
@if (!book.metadata![field.lockedKey]) {
|
||||
@if (!metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
@if (metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<div class="w-full px-4">
|
||||
@@ -110,7 +111,8 @@
|
||||
[suggestions]="getFiltered(field.controlName)"
|
||||
(completeMethod)="filterItems($event, field.controlName)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
|
||||
(onSelect)="onAutoCompleteSelect(field.controlName, $event)">
|
||||
(onSelect)="onAutoCompleteSelect(field.controlName, $event)"
|
||||
[disabled]="metadataForm.get(field.lockedKey)?.value">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
<p-button
|
||||
@@ -142,13 +144,14 @@
|
||||
<div class="form-row">
|
||||
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
|
||||
<div class="input-container">
|
||||
@if (!book.metadata![field.lockedKey]) {
|
||||
@if (!metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
@if (metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<textarea rows="3" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
|
||||
<textarea rows="3" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"
|
||||
[disabled]="metadataForm.get(field.lockedKey)?.value"></textarea>
|
||||
<p-button
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||
[outlined]="true"
|
||||
@@ -170,13 +173,14 @@
|
||||
<div class="form-row">
|
||||
<label for="{{field.controlName}}" class="label">{{ field.label }}</label>
|
||||
<div class="input-container">
|
||||
@if (!book.metadata![field.lockedKey]) {
|
||||
@if (!metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata![field.lockedKey]) {
|
||||
@if (metadataForm.get(field.lockedKey)?.value) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||
}
|
||||
<input pInputText pSize="small" id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||
<input pInputText pSize="small" id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"
|
||||
[disabled]="metadataForm.get(field.lockedKey)?.value"/>
|
||||
<p-button
|
||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||
[outlined]="true"
|
||||
|
||||
+34
-25
@@ -265,31 +265,40 @@ export class MetadataPickerComponent implements OnInit {
|
||||
coverLocked: 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.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();
|
||||
if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.disable();
|
||||
if (metadata.goodreadsRatingLocked) this.metadataForm.get('goodreadsRating')?.disable();
|
||||
if (metadata.hardcoverIdLocked) this.metadataForm.get('hardcoverId')?.disable();
|
||||
if (metadata.hardcoverReviewCountLocked) this.metadataForm.get('hardcoverReviewCount')?.disable();
|
||||
if (metadata.hardcoverRatingLocked) this.metadataForm.get('hardcoverRating')?.disable();
|
||||
if (metadata.googleIdLocked) this.metadataForm.get('googleId')?.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();
|
||||
// Always enable all fields before applying locked state
|
||||
Object.keys(this.metadataForm.controls).forEach((key) => {
|
||||
if (!key.endsWith('Locked')) {
|
||||
this.metadataForm.get(key)?.enable({emitEvent: false});
|
||||
}
|
||||
});
|
||||
|
||||
if (metadata.titleLocked) this.metadataForm.get('title')?.disable({emitEvent: false});
|
||||
if (metadata.subtitleLocked) this.metadataForm.get('subtitle')?.disable({emitEvent: false});
|
||||
if (metadata.authorsLocked) this.metadataForm.get('authors')?.disable({emitEvent: false});
|
||||
if (metadata.categoriesLocked) this.metadataForm.get('categories')?.disable({emitEvent: false});
|
||||
if (metadata.publisherLocked) this.metadataForm.get('publisher')?.disable({emitEvent: false});
|
||||
if (metadata.publishedDateLocked) this.metadataForm.get('publishedDate')?.disable({emitEvent: false});
|
||||
if (metadata.languageLocked) this.metadataForm.get('language')?.disable({emitEvent: false});
|
||||
if (metadata.isbn10Locked) this.metadataForm.get('isbn10')?.disable({emitEvent: false});
|
||||
if (metadata.isbn13Locked) this.metadataForm.get('isbn13')?.disable({emitEvent: false});
|
||||
if (metadata.asinLocked) this.metadataForm.get('asin')?.disable({emitEvent: false});
|
||||
if (metadata.personalRatingLocked) this.metadataForm.get('personalRating')?.disable({emitEvent: false});
|
||||
if (metadata.amazonReviewCountLocked) this.metadataForm.get('amazonReviewCount')?.disable({emitEvent: false});
|
||||
if (metadata.amazonRatingLocked) this.metadataForm.get('amazonRating')?.disable({emitEvent: false});
|
||||
if (metadata.googleIdLocked) this.metadataForm.get('googleIdCount')?.disable({emitEvent: false});
|
||||
if (metadata.comicvineIdLocked) this.metadataForm.get('comicvineId')?.disable({emitEvent: false});
|
||||
if (metadata.goodreadsIdLocked) this.metadataForm.get('goodreadsId')?.disable({emitEvent: false});
|
||||
if (metadata.goodreadsReviewCountLocked) this.metadataForm.get('goodreadsReviewCount')?.disable({emitEvent: false});
|
||||
if (metadata.goodreadsRatingLocked) this.metadataForm.get('goodreadsRating')?.disable({emitEvent: false});
|
||||
if (metadata.hardcoverIdLocked) this.metadataForm.get('hardcoverId')?.disable({emitEvent: false});
|
||||
if (metadata.hardcoverReviewCountLocked) this.metadataForm.get('hardcoverReviewCount')?.disable({emitEvent: false});
|
||||
if (metadata.hardcoverRatingLocked) this.metadataForm.get('hardcoverRating')?.disable({emitEvent: false});
|
||||
if (metadata.googleIdLocked) this.metadataForm.get('googleId')?.disable({emitEvent: false});
|
||||
if (metadata.pageCountLocked) this.metadataForm.get('pageCount')?.disable({emitEvent: false});
|
||||
if (metadata.descriptionLocked) this.metadataForm.get('description')?.disable({emitEvent: false});
|
||||
if (metadata.seriesNameLocked) this.metadataForm.get('seriesName')?.disable({emitEvent: false});
|
||||
if (metadata.seriesNumberLocked) this.metadataForm.get('seriesNumber')?.disable({emitEvent: false});
|
||||
if (metadata.seriesTotalLocked) this.metadataForm.get('seriesTotal')?.disable({emitEvent: false});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+16
-23
@@ -46,7 +46,7 @@
|
||||
<p-divider layout="vertical"/>
|
||||
|
||||
<p-button
|
||||
label="Lock Metadata"
|
||||
label="Lock All"
|
||||
icon="pi pi-lock"
|
||||
severity="warn"
|
||||
[outlined]="true"
|
||||
@@ -54,7 +54,7 @@
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
label="Unlock Metadata"
|
||||
label="Unlock All"
|
||||
icon="pi pi-lock-open"
|
||||
severity="success"
|
||||
[outlined]="true"
|
||||
@@ -64,37 +64,30 @@
|
||||
<p-divider layout="vertical"/>
|
||||
|
||||
<p-button
|
||||
label="Previous"
|
||||
icon="pi pi-angle-left"
|
||||
severity="secondary"
|
||||
[outlined]="true"
|
||||
(click)="previous()"
|
||||
[disabled]="currentIndex === 0">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
[label]="isLast ? 'Reject & Finish' : 'Reject & Next'"
|
||||
[icon]="isLast ? 'pi pi-times-circle' : 'pi pi-angle-right'"
|
||||
iconPos="right"
|
||||
severity="danger"
|
||||
[outlined]="true"
|
||||
(click)="onReject()">
|
||||
</p-button>
|
||||
|
||||
<p-button
|
||||
[label]="isLast ? 'Save & Finish' : 'Save & Next'"
|
||||
[icon]="isLast ? 'pi pi-check-circle' : 'pi pi-angle-right'"
|
||||
label="Accept & Save"
|
||||
icon="pi pi-check-circle"
|
||||
iconPos="right"
|
||||
severity="success"
|
||||
[outlined]="true"
|
||||
(click)="onSave(currentProposal!)">
|
||||
</p-button>
|
||||
|
||||
<p-divider layout="vertical"/>
|
||||
|
||||
<p-button
|
||||
[label]="isLast ? 'Finish & Close' : 'Next'"
|
||||
[icon]="isLast ? 'pi pi-check-circle' : 'pi pi-angle-right'"
|
||||
iconPos="right"
|
||||
severity="info"
|
||||
[outlined]="true"
|
||||
(click)="onNext()">
|
||||
</p-button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="p-4 h-full flex items-center justify-center">
|
||||
<p-progressSpinner styleClass="w-8 h-8" strokeWidth="4"></p-progressSpinner>
|
||||
<p-progressSpinner class="w-8 h-8" strokeWidth="4"></p-progressSpinner>
|
||||
</div>
|
||||
}
|
||||
|
||||
+1
-46
@@ -93,59 +93,22 @@ export class MetadataReviewDialogComponent implements OnInit {
|
||||
return this.proposals[this.currentIndex] ?? null;
|
||||
}
|
||||
|
||||
onReject(): void {
|
||||
const currentProposal = this.currentProposal;
|
||||
if (!currentProposal) return;
|
||||
|
||||
this.metadataTaskService.updateProposalStatus(currentProposal.taskId, currentProposal.proposalId, 'REJECTED').subscribe({
|
||||
next: () => {
|
||||
if (this.isLast) {
|
||||
this.metadataTaskService.deleteTask(currentProposal.taskId).subscribe(() => {
|
||||
this.progressService.clearTask(currentProposal.taskId);
|
||||
this.dialogRef.close();
|
||||
});
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
if (this.isLast) {
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onSave(updatedFields: Partial<FetchedProposal>): void {
|
||||
const currentProposal = this.currentProposal;
|
||||
if (!currentProposal) return;
|
||||
|
||||
this.pickerComponent.onSave();
|
||||
|
||||
this.metadataTaskService.updateProposalStatus(currentProposal.taskId, currentProposal.proposalId, 'ACCEPTED').subscribe({
|
||||
next: () => {
|
||||
if (this.isLast) {
|
||||
this.metadataTaskService.deleteTask(currentProposal.taskId).subscribe(() => {
|
||||
this.progressService.clearTask(currentProposal.taskId);
|
||||
this.dialogRef.close();
|
||||
});
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
if (this.isLast) {
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.next();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
next(): void {
|
||||
onNext(): void {
|
||||
const nextIndex = this.currentIndex + 1;
|
||||
if (nextIndex >= this.proposals.length) {
|
||||
this.dialogRef.close();
|
||||
@@ -155,14 +118,6 @@ export class MetadataReviewDialogComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
previous(): void {
|
||||
const prevIndex = this.currentIndex - 1;
|
||||
if (prevIndex >= 0) {
|
||||
this.currentIndex = prevIndex;
|
||||
this.currentIndexSubject.next(prevIndex);
|
||||
}
|
||||
}
|
||||
|
||||
lockAllMetadata(): void {
|
||||
this.pickerComponent?.lockAll();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user