Add Reset Button for Metadata Fields in Metadata Picker Tab
This commit is contained in:
committed by
Aditya Chandel
parent
c14d83b593
commit
12e7673805
+40
-12
@@ -20,11 +20,18 @@
|
|||||||
<img [src]="metadataForm.get('thumbnailUrl')?.value" alt="Book Thumbnail" class="thumbnail"/>
|
<img [src]="metadataForm.get('thumbnailUrl')?.value" alt="Book Thumbnail" class="thumbnail"/>
|
||||||
<input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl" class="input"/>
|
<input type="hidden" id="thumbnailUrl" formControlName="thumbnailUrl" class="input"/>
|
||||||
<p-button
|
<p-button
|
||||||
[icon]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : 'pi pi-arrow-left'"
|
[icon]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||||
[outlined]="true"
|
[outlined]="true"
|
||||||
[ngClass]="{'green-outlined-button': isValueSaved('thumbnailUrl'), 'yellow-outlined-button': isValueCopied('thumbnailUrl')}"
|
[ngClass]="
|
||||||
|
{
|
||||||
|
'green-outlined-button': isValueSaved('thumbnailUrl'),
|
||||||
|
'yellow-outlined-button': isValueCopied('thumbnailUrl') && !hoveredFields['thumbnailUrl'],
|
||||||
|
'red-outlined-button': isValueCopied('thumbnailUrl') && hoveredFields['thumbnailUrl']
|
||||||
|
}"
|
||||||
class="arrow-button"
|
class="arrow-button"
|
||||||
(click)="copyFetchedToCurrent('thumbnailUrl')"/>
|
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
|
||||||
|
(mouseenter)="onMouseEnter('thumbnailUrl')"
|
||||||
|
(mouseleave)="onMouseLeave('thumbnailUrl')"/>
|
||||||
<input type="hidden" [value]="fetchedMetadata.thumbnailUrl" class="input" readonly/>
|
<input type="hidden" [value]="fetchedMetadata.thumbnailUrl" class="input" readonly/>
|
||||||
<img [src]="fetchedMetadata.thumbnailUrl ?? null" alt="Fetched Thumbnail" class="thumbnail"/>
|
<img [src]="fetchedMetadata.thumbnailUrl ?? null" alt="Fetched Thumbnail" class="thumbnail"/>
|
||||||
</div>
|
</div>
|
||||||
@@ -37,11 +44,18 @@
|
|||||||
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||||
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||||
<p-button
|
<p-button
|
||||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : 'pi pi-arrow-left'"
|
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||||
[outlined]="true"
|
[outlined]="true"
|
||||||
[ngClass]="{'green-outlined-button': isValueSaved(field.controlName), 'yellow-outlined-button': isValueCopied(field.controlName)}"
|
[ngClass]="
|
||||||
|
{
|
||||||
|
'green-outlined-button': isValueSaved(field.controlName),
|
||||||
|
'yellow-outlined-button': isValueCopied(field.controlName) && !hoveredFields[field.controlName],
|
||||||
|
'red-outlined-button': isValueCopied(field.controlName) && hoveredFields[field.controlName]
|
||||||
|
}"
|
||||||
class="arrow-button"
|
class="arrow-button"
|
||||||
(click)="copyFetchedToCurrent(field.controlName)"/>
|
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||||
|
(mouseenter)="onMouseEnter(field.controlName)"
|
||||||
|
(mouseleave)="onMouseLeave(field.controlName)"/>
|
||||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -53,11 +67,18 @@
|
|||||||
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||||
<textarea rows="6" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
|
<textarea rows="6" pTextarea id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"></textarea>
|
||||||
<p-button
|
<p-button
|
||||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : 'pi pi-arrow-left'"
|
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||||
[outlined]="true"
|
[outlined]="true"
|
||||||
[ngClass]="{'green-outlined-button': isValueSaved(field.controlName), 'yellow-outlined-button': isValueCopied(field.controlName)}"
|
[ngClass]="
|
||||||
|
{
|
||||||
|
'green-outlined-button': isValueSaved(field.controlName),
|
||||||
|
'yellow-outlined-button': isValueCopied(field.controlName) && !hoveredFields[field.controlName],
|
||||||
|
'red-outlined-button': isValueCopied(field.controlName) && hoveredFields[field.controlName]
|
||||||
|
}"
|
||||||
class="arrow-button"
|
class="arrow-button"
|
||||||
(click)="copyFetchedToCurrent(field.controlName)"/>
|
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||||
|
(mouseenter)="onMouseEnter(field.controlName)"
|
||||||
|
(mouseleave)="onMouseLeave(field.controlName)"/>
|
||||||
<textarea rows="6" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
|
<textarea rows="6" pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,11 +90,18 @@
|
|||||||
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
<p-button *ngIf="metadata[field.lockedKey]" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
|
||||||
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
<input pInputText id="{{field.controlName}}" formControlName="{{field.controlName}}" class="input"/>
|
||||||
<p-button
|
<p-button
|
||||||
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : 'pi pi-arrow-left'"
|
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
|
||||||
[outlined]="true"
|
[outlined]="true"
|
||||||
[ngClass]="{'green-outlined-button': isValueSaved(field.controlName), 'yellow-outlined-button': isValueCopied(field.controlName)}"
|
[ngClass]="
|
||||||
|
{
|
||||||
|
'green-outlined-button': isValueSaved(field.controlName),
|
||||||
|
'yellow-outlined-button': isValueCopied(field.controlName) && !hoveredFields[field.controlName],
|
||||||
|
'red-outlined-button': isValueCopied(field.controlName) && hoveredFields[field.controlName]
|
||||||
|
}"
|
||||||
class="arrow-button"
|
class="arrow-button"
|
||||||
(click)="copyFetchedToCurrent(field.controlName)"/>
|
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||||
|
(mouseenter)="onMouseEnter(field.controlName)"
|
||||||
|
(mouseleave)="onMouseLeave(field.controlName)"/>
|
||||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? null" class="input" readonly/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+5
@@ -48,3 +48,8 @@
|
|||||||
--p-button-outlined-primary-border-color: limegreen;
|
--p-button-outlined-primary-border-color: limegreen;
|
||||||
--p-button-outlined-primary-color: limegreen;
|
--p-button-outlined-primary-color: limegreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.red-outlined-button {
|
||||||
|
--p-button-outlined-primary-border-color: #E32636;
|
||||||
|
--p-button-outlined-primary-color: #E32636;
|
||||||
|
}
|
||||||
|
|||||||
+21
-1
@@ -35,7 +35,6 @@ import {Textarea} from 'primeng/textarea';
|
|||||||
})
|
})
|
||||||
export class MetadataPickerComponent implements OnInit {
|
export class MetadataPickerComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
metadataFieldsTop = [
|
metadataFieldsTop = [
|
||||||
{label: 'Title', controlName: 'title', lockedKey: 'titleLocked', fetchedKey: 'title'},
|
{label: 'Title', controlName: 'title', lockedKey: 'titleLocked', fetchedKey: 'title'},
|
||||||
{label: 'Authors', controlName: 'authors', lockedKey: 'authorsLocked', fetchedKey: 'authors'},
|
{label: 'Authors', controlName: 'authors', lockedKey: 'authorsLocked', fetchedKey: 'authors'},
|
||||||
@@ -67,6 +66,7 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
currentBookId!: number;
|
currentBookId!: number;
|
||||||
copiedFields: Record<string, boolean> = {};
|
copiedFields: Record<string, boolean> = {};
|
||||||
savedFields: Record<string, boolean> = {};
|
savedFields: Record<string, boolean> = {};
|
||||||
|
originalMetadata!: BookMetadata;
|
||||||
|
|
||||||
private metadataCenterService = inject(BookMetadataCenterService);
|
private metadataCenterService = inject(BookMetadataCenterService);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
@@ -118,6 +118,8 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.bookMetadata$.subscribe((metadata) => {
|
this.bookMetadata$.subscribe((metadata) => {
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
|
this.originalMetadata = metadata;
|
||||||
|
this.originalMetadata.thumbnailUrl = this.urlHelper.getCoverUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||||
this.currentBookId = metadata.bookId;
|
this.currentBookId = metadata.bookId;
|
||||||
this.metadataForm.patchValue({
|
this.metadataForm.patchValue({
|
||||||
title: metadata.title || '',
|
title: metadata.title || '',
|
||||||
@@ -374,4 +376,22 @@ export class MetadataPickerComponent implements OnInit {
|
|||||||
closeDialog() {
|
closeDialog() {
|
||||||
this.metadataCenterService.closeDialog(true);
|
this.metadataCenterService.closeDialog(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hoveredFields: { [key: string]: boolean } = {};
|
||||||
|
|
||||||
|
onMouseEnter(controlName: string): void {
|
||||||
|
if (this.isValueCopied(controlName) && !this.isValueSaved(controlName)) {
|
||||||
|
this.hoveredFields[controlName] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMouseLeave(controlName: string): void {
|
||||||
|
this.hoveredFields[controlName] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetField(field: string) {
|
||||||
|
this.metadataForm.get(field)?.setValue(this.originalMetadata[field]);
|
||||||
|
this.copiedFields[field] = false;
|
||||||
|
this.hoveredFields[field] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user