From d7394fa4820cd40e22aa93f9437dfd2485a959f8 Mon Sep 17 00:00:00 2001 From: milanmajchrak <90026355+milanmajchrak@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:54:06 +0200 Subject: [PATCH] Clear funding input type only when the type is `N/A` (#631) --- ...ynamic-sponsor-scrollable-dropdown.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts index fece3308784..37b2fcf34f2 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts @@ -111,7 +111,10 @@ export class DsDynamicSponsorScrollableDropdownComponent extends DsDynamicScroll (input as DsDynamicInputModel).value = ''; break; case DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN: - (input as DynamicScrollableDropdownModel).value = ''; + // Remove it only if the funding type is `N/A` + if (this.fundingTypeIsNotApplicable(fundingTypeValue)) { + (input as DynamicScrollableDropdownModel).value = ''; + } break; default: break; @@ -142,10 +145,17 @@ export class DsDynamicSponsorScrollableDropdownComponent extends DsDynamicScroll } // if the funding type is `N/A` -> clean inputs - if (isEqual(fundingTypeValue, this.translateService.instant('autocomplete.suggestion.sponsor.empty'))) { + if (this.fundingTypeIsNotApplicable(fundingTypeValue)) { return true; } return false; } + + /** + * Check if the funding type is `N/A` + */ + fundingTypeIsNotApplicable(fundingTypeValue) { + return isEqual(fundingTypeValue, this.translateService.instant('autocomplete.suggestion.sponsor.empty')); + } }