Fix DMP's funder tab

This commit is contained in:
George Kalampokis 2023-10-18 18:14:02 +03:00
parent 093837c395
commit 5885e3ae5c
1 changed files with 12 additions and 4 deletions

View File

@ -74,7 +74,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
return ''; return '';
} }
ngOnInit() { ngOnInit() {
const grantRequestItem: RequestItem<GrantCriteria> = new RequestItem(); const grantRequestItem: RequestItem<GrantCriteria> = new RequestItem();
grantRequestItem.criteria = new GrantCriteria(); grantRequestItem.criteria = new GrantCriteria();
@ -388,7 +388,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
if(this.isRequired) if(this.isRequired)
this.funderFormGroup.get('reference').setValidators(Validators.required); this.funderFormGroup.get('reference').setValidators(Validators.required);
this.funderFormGroup.get('reference').updateValueAndValidity(); this.funderFormGroup.get('reference').updateValueAndValidity();
} else if (this.isClone && !this.isNewVersion) { } else if (this.isClone && !this.isNewVersion) {
if (this.funderFormGroup.get('existFunder')) { if (this.funderFormGroup.get('existFunder')) {
this.funderFormGroup.get('existFunder').enable(); 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) { 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.reset();
this.grantformGroup.enable(); this.grantformGroup.enable();
this.setGrantValidators(); this.setGrantValidators();