DMP Editor patch: Form is not invalid invalid anymore when change from createnew funder to existing
This commit is contained in:
parent
b82398d97e
commit
b825a80e61
|
@ -55,10 +55,6 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
private readonly _KEY = "Internal";
|
||||
|
||||
|
||||
private initialFunderIdentifier:string;
|
||||
private initialGrantIdentifier:string;
|
||||
private initialProjectIdentifier:string;
|
||||
|
||||
constructor(
|
||||
private grantService: GrantService,
|
||||
private projectService: ProjectService,
|
||||
|
@ -82,11 +78,6 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
|
||||
this.configureAutoCompletes();
|
||||
|
||||
|
||||
this.initialFunderIdentifier = this.funderFormGroup.get('reference').value;
|
||||
this.initialGrantIdentifier = this.grantformGroup.get('reference').value;
|
||||
this.initialProjectIdentifier = this.projectFormGroup.get('reference').value;
|
||||
|
||||
this.initializeReferenceValidators();
|
||||
|
||||
this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0);
|
||||
|
@ -134,9 +125,6 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
)
|
||||
.subscribe(error=>{
|
||||
this.isFunderPending = false;
|
||||
if(this.initialFunderIdentifier === this.funderFormGroup.get('reference').value){
|
||||
error = null;
|
||||
}
|
||||
this.funderFormGroup.get('reference').setErrors(error);
|
||||
if(!error && this.funderFormGroup.get('reference').validator){
|
||||
const validator = this.funderFormGroup.get('reference').validator({} as AbstractControl);
|
||||
|
@ -172,9 +160,6 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
)
|
||||
.subscribe(error=>{
|
||||
this.isGrantPending = false;
|
||||
if(this.initialGrantIdentifier === this.grantformGroup.get('reference').value){
|
||||
error = null;
|
||||
}
|
||||
this.grantformGroup.get('reference').setErrors(error);
|
||||
if(!error && this.grantformGroup.get('reference').validator){
|
||||
const validator = this.grantformGroup.get('reference').validator({} as AbstractControl);
|
||||
|
@ -209,9 +194,6 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
)
|
||||
.subscribe(error=>{
|
||||
this.isProjectPending = false;
|
||||
if(this.initialProjectIdentifier === this.projectFormGroup.get('reference').value){
|
||||
error = null;
|
||||
}
|
||||
this.projectFormGroup.get('reference').setErrors(error);
|
||||
if(!error && this.projectFormGroup.get('reference').validator){
|
||||
const validator = this.projectFormGroup.get('reference').validator({} as AbstractControl);
|
||||
|
@ -299,6 +281,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.grantformGroup.get('label').enable();
|
||||
this.grantformGroup.get('description').enable();
|
||||
|
||||
this.grantformGroup.get('reference').enable();
|
||||
this.grantformGroup.get('reference').setValidators(Validators.required);
|
||||
this.grantformGroup.get('reference').updateValueAndValidity();
|
||||
} else if (this.isClone && !this.isNewVersion) {
|
||||
|
@ -308,14 +291,18 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.grantformGroup.get('description').disable();
|
||||
this.grantformGroup.get('description').reset();
|
||||
|
||||
this.grantformGroup.get('reference').disable();
|
||||
this.grantformGroup.get('reference').clearValidators();
|
||||
this.grantformGroup.get('reference').setErrors(null);
|
||||
this.grantformGroup.get('reference').updateValueAndValidity();
|
||||
} else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) {
|
||||
this.grantformGroup.get('existGrant').disable();
|
||||
this.grantformGroup.get('label').disable();
|
||||
this.grantformGroup.get('description').disable();
|
||||
|
||||
this.grantformGroup.get('reference').disable();
|
||||
this.grantformGroup.get('reference').clearValidators();
|
||||
this.grantformGroup.get('reference').setErrors(null);
|
||||
this.grantformGroup.get('reference').updateValueAndValidity();
|
||||
} else {
|
||||
this.grantformGroup.get('existGrant').enable();
|
||||
|
@ -324,7 +311,9 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.grantformGroup.get('description').disable();
|
||||
this.grantformGroup.get('description').reset();
|
||||
|
||||
this.grantformGroup.get('reference').disable();
|
||||
this.grantformGroup.get('reference').clearValidators();
|
||||
this.grantformGroup.get('reference').setErrors(null);
|
||||
this.grantformGroup.get('reference').updateValueAndValidity();
|
||||
}
|
||||
}
|
||||
|
@ -335,6 +324,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.projectFormGroup.get('label').enable();
|
||||
this.projectFormGroup.get('description').enable();
|
||||
|
||||
this.projectFormGroup.get('reference').enable()
|
||||
this.projectFormGroup.get('reference').setValidators(Validators.required);
|
||||
this.projectFormGroup.get('reference').updateValueAndValidity();
|
||||
} else if (this.isClone && !this.isNewVersion) {
|
||||
|
@ -344,14 +334,18 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.projectFormGroup.get('description').disable();
|
||||
this.projectFormGroup.get('description').reset();
|
||||
|
||||
this.projectFormGroup.get('reference').disable();
|
||||
this.projectFormGroup.get('reference').clearValidators();
|
||||
this.projectFormGroup.get('reference').setErrors(null);
|
||||
this.projectFormGroup.get('reference').updateValueAndValidity();
|
||||
} else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) {
|
||||
this.projectFormGroup.get('existProject').disable();
|
||||
this.projectFormGroup.get('label').disable();
|
||||
this.projectFormGroup.get('description').disable();
|
||||
|
||||
this.projectFormGroup.get('reference').disable();
|
||||
this.projectFormGroup.get('reference').clearValidators();
|
||||
this.projectFormGroup.get('reference').setErrors(null);
|
||||
this.projectFormGroup.get('reference').updateValueAndValidity();
|
||||
} else {
|
||||
this.projectFormGroup.get('existProject').enable();
|
||||
|
@ -360,7 +354,9 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.projectFormGroup.get('description').disable();
|
||||
this.projectFormGroup.get('description').reset();
|
||||
|
||||
this.projectFormGroup.get('reference').disable();
|
||||
this.projectFormGroup.get('reference').clearValidators();
|
||||
this.projectFormGroup.get('reference').setErrors(null);
|
||||
this.projectFormGroup.get('reference').updateValueAndValidity();
|
||||
}
|
||||
}
|
||||
|
@ -370,6 +366,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.funderFormGroup.get('existFunder').disable();
|
||||
this.funderFormGroup.get('label').enable();
|
||||
|
||||
this.funderFormGroup.get('reference').enable();
|
||||
this.funderFormGroup.get('reference').setValidators(Validators.required);
|
||||
this.funderFormGroup.get('reference').updateValueAndValidity();
|
||||
|
||||
|
@ -378,10 +375,13 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.funderFormGroup.get('existFunder').enable();
|
||||
this.funderFormGroup.get('label').disable();
|
||||
this.funderFormGroup.get('label').reset();
|
||||
this.funderFormGroup.get('reference').disable();
|
||||
this.funderFormGroup.get('reference').clearValidators();
|
||||
this.funderFormGroup.get('reference').setErrors(null);
|
||||
this.funderFormGroup.get('reference').updateValueAndValidity();
|
||||
} else {
|
||||
this.funderFormGroup.get('label').enable();
|
||||
this.funderFormGroup.get('reference').enable();
|
||||
this.funderFormGroup.get('reference').setValidators(Validators.required);
|
||||
this.funderFormGroup.get('reference').updateValueAndValidity();
|
||||
}
|
||||
|
@ -389,14 +389,18 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|||
this.funderFormGroup.get('existFunder').disable();
|
||||
this.funderFormGroup.get('label').disable();
|
||||
|
||||
this.funderFormGroup.get('reference').disable();
|
||||
this.funderFormGroup.get('reference').clearValidators();
|
||||
this.funderFormGroup.get('reference').setErrors(null);
|
||||
this.funderFormGroup.get('reference').updateValueAndValidity();
|
||||
} else {
|
||||
this.funderFormGroup.enable();
|
||||
this.funderFormGroup.get('label').disable();
|
||||
this.funderFormGroup.get('label').reset();
|
||||
|
||||
this.funderFormGroup.get('reference').disable();
|
||||
this.funderFormGroup.get('reference').clearValidators();
|
||||
this.funderFormGroup.get('reference').setErrors(null);
|
||||
this.funderFormGroup.get('reference').updateValueAndValidity();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue