From 5885e3ae5cf28cb51596531551de494cbb9b805b Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 18 Oct 2023 18:14:02 +0300 Subject: [PATCH] Fix DMP's funder tab --- .../funding-info/funding-info.component.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts index 1663bcce9..88220c5b4 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts @@ -74,7 +74,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { return ''; } - ngOnInit() { + ngOnInit() { const grantRequestItem: RequestItem = new RequestItem(); grantRequestItem.criteria = new GrantCriteria(); @@ -388,7 +388,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { if(this.isRequired) this.funderFormGroup.get('reference').setValidators(Validators.required); this.funderFormGroup.get('reference').updateValueAndValidity(); - + } else if (this.isClone && !this.isNewVersion) { if (this.funderFormGroup.get('existFunder')) { this.funderFormGroup.get('existFunder').enable(); @@ -435,9 +435,17 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { } } + private hasNewFunder(funder: any) { + return funder.label !== null && funder.label !== undefined && funder.label !== '' && funder.reference !== undefined && funder.reference !== undefined && funder.reference !== ''; + } + + private hasExistingFunder(funder: any) { + return funder.existFunder !== null && funder.existFunder !== undefined && funder.existFunder.reference !== null && funder.existFunder.reference !== undefined; + } + funderValueChanged(funder: any) { - if ((funder.label !== "" && funder.label !== null && funder.label !== undefined && !isNullOrUndefined(funder.reference) && funder.reference.length ) - || (funder.existFunder !== null && funder.existFunder !== undefined && funder.existFunder.id !== undefined)) { + + if (this.hasNewFunder(funder) || this.hasExistingFunder(funder)) { //this.grantformGroup.reset(); this.grantformGroup.enable(); this.setGrantValidators();