From 514953f8867115bcd098980e2c2dc497cb8ba28a Mon Sep 17 00:00:00 2001 From: Felipe Barreta Date: Wed, 18 Dec 2024 12:03:30 -0800 Subject: [PATCH] ALCS-2431 Prevents validation flash and remove admin fee if unchecked on submit --- .../decision-condition-types-dialog.component.html | 6 +++--- .../decision-condition-types-dialog.component.ts | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.html b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.html index 79a359efc..45bfff2b0 100644 --- a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.html +++ b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.html @@ -47,7 +47,7 @@

{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type

Administrative Fee Amount
@@ -82,7 +82,7 @@

{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type

Date
@@ -122,7 +122,7 @@

{{ isEdit ? 'Edit' : 'Create' }} Decision Condition Type

Security Amount
diff --git a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.ts b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.ts index 67f02018b..811f7fb59 100644 --- a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.ts +++ b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types-dialog/decision-condition-types-dialog.component.ts @@ -47,6 +47,7 @@ export class DecisionConditionTypesDialogComponent { @Inject(MAT_DIALOG_DATA) public data: DecisionDialogDataInterface | undefined, private dialogRef: MatDialogRef, ) { + this.isLoading = true; this.service = data?.service; this.conditionService = data?.conditionService; this.isEdit = !!data?.content; @@ -111,6 +112,7 @@ export class DecisionConditionTypesDialogComponent { this.conditionTypeForm.get('isComponentToConditionChecked')?.disable(); this.conditionTypeForm.get('isDescriptionChecked')?.disable(); + this.isLoading = false; } ngOnInit(): void { @@ -144,6 +146,9 @@ export class DecisionConditionTypesDialogComponent { if (this.conditionTypeForm.get('administrativeFeeAmount')?.value !== '') { dto.administrativeFeeAmount = this.conditionTypeForm.get('administrativeFeeAmount')?.value; } + if (!dto.isAdministrativeFeeAmountChecked) { + dto.administrativeFeeAmount = null; + } if (!this.service) return; if (this.isEdit) { await this.service.update(dto.code, dto); @@ -158,11 +163,15 @@ export class DecisionConditionTypesDialogComponent { return (control: AbstractControl): Observable<{ [key: string]: any } | null> => { return of(control.value).pipe( debounceTime(300), - switchMap(() => { + switchMap(async () => { if (!this.conditionService) { throw Error('Condition service not found'); } - return this.conditionService.fetchByTypeCode(this.conditionTypeForm.controls['code'].value); + // prevents the message flash by setting isLoading while fetching codes. + this.isLoading = true; + const result = await this.conditionService.fetchByTypeCode(this.conditionTypeForm.controls['code'].value); + this.isLoading = false; + return result; }), map((conditions) => {