diff --git a/dmp-frontend/src/app/core/query/organisation/organisation-criteria.ts b/dmp-frontend/src/app/core/query/organisation/organisation-criteria.ts index 66cc6a731..2012bf40a 100644 --- a/dmp-frontend/src/app/core/query/organisation/organisation-criteria.ts +++ b/dmp-frontend/src/app/core/query/organisation/organisation-criteria.ts @@ -2,4 +2,5 @@ import { BaseCriteria } from "../base-criteria"; export class OrganisationCriteria extends BaseCriteria { public labelLike: string; + public like?: string; } diff --git a/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.html b/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.html index 750c2bdff..10f6b5c8b 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.html @@ -5,7 +5,7 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} - {{'DMP-EDITOR.MAIN-INFO.ORGANISATION-IDENTIFIER-EXISTS' | translate}} + {{'DMP-EDITOR.MAIN-INFO.ORGANISATION-IDENTIFIER-EXSTS' | translate}} check clear {{'DMP-EDITOR.MAIN-INFO.IDENTIFIER-EXISTS-ORGANISATION-LIST' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.ts b/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.ts index a2e4f73dc..97ef43256 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/add-organization/add-organization.component.ts @@ -29,6 +29,7 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit { private externalSourcesService: ExternalSourcesService, private externalResearcherService: ExternalResearcherService, public dialogRef: MatDialogRef, + private organizationService: OrganisationService, @Inject(MAT_DIALOG_DATA) public data: any ) { super(); @@ -64,11 +65,11 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit { return (control: AbstractControl) :Observable =>{ return control.valueChanges.pipe( debounceTime(600), - mergeMap(value=>this.externalSourcesService.searchDMPOrganizations('',this._REFERENCE_PREFIX +value)), + mergeMap(value=>this.organizationService.searchGeneralOrganisations({criteria:{labelLike:'', like: this._REFERENCE_PREFIX +value}})), takeUntil(this._destroyed), map((response)=>{ if(response && response.length){ - const internalOrganizations = (response as Array).filter(organization=> organization.key === this._KEY); + const internalOrganizations = (response as Array).filter(organization=> organization.key === this._KEY).filter(organization=> organization.reference === this._REFERENCE_PREFIX + control.value); if(internalOrganizations && internalOrganizations.length){ return {organizationIdentifierExists:true}; 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 cffcf316f..82a5f84f9 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 @@ -53,6 +53,12 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { private readonly _GRANT_PREFIX = "dmp:"; private readonly _PROJECT_PREFIX = "dmp:"; private readonly _KEY = "Internal"; + + + private initialFunderIdentifier:string; + private initialGrantIdentifier:string; + private initialProjectIdentifier:string; + constructor( private grantService: GrantService, private projectService: ProjectService, @@ -76,6 +82,11 @@ 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); @@ -123,6 +134,9 @@ 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); @@ -158,6 +172,9 @@ 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); @@ -192,6 +209,9 @@ 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); diff --git a/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts index 89d3a19aa..a676a43c3 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/main-info/main-info.component.ts @@ -147,7 +147,7 @@ export class MainInfoComponent extends BaseComponent implements OnInit { } filterOrganisations(value: string): Observable { - return this.organizationService.searchGeneralOrganisations({ criteria: { labelLike: value, like: value } }); + return this.organizationService.searchGeneralOrganisations({ criteria: { labelLike: value } }); } cantAddOrganizations(): boolean {