RED-7762: fields show 'unchanged' by default.

This commit is contained in:
Nicoleta Panaghiu 2023-11-27 11:15:48 +02:00
parent 24bde55bb3
commit 677d6732b0
2 changed files with 20 additions and 9 deletions

View File

@ -49,7 +49,7 @@
<mat-select <mat-select
class="full-width" class="full-width"
formControlName="reason" formControlName="reason"
[placeholder]="'edit-redaction.dialog.content.unchanged' | translate" [placeholder]="!hidePlaceholder ? ('edit-redaction.dialog.content.unchanged' | translate) : ''"
> >
<mat-option <mat-option
*ngFor="let option of legalOptions" *ngFor="let option of legalOptions"
@ -65,7 +65,12 @@
<div class="iqser-input-group w-450"> <div class="iqser-input-group w-450">
<label [translate]="'edit-redaction.dialog.content.legal-basis'"></label> <label [translate]="'edit-redaction.dialog.content.legal-basis'"></label>
<input [value]="form.controls.reason.value?.legalBasis" disabled type="text" /> <input
[value]="form.controls.reason.value?.legalBasis"
disabled
type="text"
[placeholder]="!hidePlaceholder ? ('edit-redaction.dialog.content.unchanged' | translate) : ''"
/>
</div> </div>
<div class="iqser-input-group w-450"> <div class="iqser-input-group w-450">

View File

@ -34,6 +34,7 @@ export class EditRedactionDialogComponent
legalOptions: LegalBasisOption[] = []; legalOptions: LegalBasisOption[] = [];
dictionaries: Dictionary[] = []; dictionaries: Dictionary[] = [];
readonly form = this.#getForm(); readonly form = this.#getForm();
hasTypeChanged = false;
constructor( constructor(
private readonly _justificationsService: JustificationsService, private readonly _justificationsService: JustificationsService,
@ -57,6 +58,12 @@ export class EditRedactionDialogComponent
return null; return null;
} }
get showExtras() {
const type = this.form.get('type').value;
const isSignature = type === SIGNATURE;
return (isSignature && this.isRedacted) || !(this.isImage || this.isHint);
}
get disabled() { get disabled() {
return ( return (
this.form.invalid || this.form.invalid ||
@ -82,6 +89,10 @@ export class EditRedactionDialogComponent
return this.redactBasedTypes.includes(this.form.controls.type.value); return this.redactBasedTypes.includes(this.form.controls.type.value);
} }
get hidePlaceholder() {
return this.hasTypeChanged && this.isRedactBasedType;
}
async ngOnInit() { async ngOnInit() {
this.#setTypes(); this.#setTypes();
const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId)); const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId));
@ -111,10 +122,11 @@ export class EditRedactionDialogComponent
this.form.patchValue({ reason: this.initialFormValue.reason, option: this.initialFormValue.option }); this.form.patchValue({ reason: this.initialFormValue.reason, option: this.initialFormValue.option });
} }
this.form.controls.reason.enable(); this.form.controls.reason.enable();
this.hasTypeChanged = true;
} else { } else {
this.form.patchValue({ reason: null, option: null });
this.form.controls.reason.disable(); this.form.controls.reason.disable();
} }
this.form.patchValue({ reason: null, option: null });
} }
save() { save() {
@ -167,10 +179,4 @@ export class EditRedactionDialogComponent
value: new FormControl<string>(this.allRectangles ? this.data.annotations[0].value : null), value: new FormControl<string>(this.allRectangles ? this.data.annotations[0].value : null),
}); });
} }
get showExtras() {
const type = this.form.get('type').value;
const isSignature = type === SIGNATURE;
return (isSignature && this.isRedacted) || !(this.isImage || this.isHint);
}
} }