From a8f75aafb9a4b0fb18b032e0df19089c7fe360da Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Fri, 30 Apr 2021 14:34:28 +0300 Subject: [PATCH] DMP Editor. Prefixing queries on searching existing identifiers. --- .../add-organization.component.ts | 12 +++++++----- .../add-researcher/add-researcher.component.ts | 9 +++++---- .../funding-info/funding-info.component.ts | 17 +++++++++++------ dmp-frontend/src/assets/i18n/de.json | 4 ++-- dmp-frontend/src/assets/i18n/en.json | 4 ++-- dmp-frontend/src/assets/i18n/es.json | 4 ++-- dmp-frontend/src/assets/i18n/gr.json | 4 ++-- dmp-frontend/src/assets/i18n/pt.json | 4 ++-- dmp-frontend/src/assets/i18n/sk.json | 4 ++-- dmp-frontend/src/assets/i18n/sr.json | 4 ++-- dmp-frontend/src/assets/i18n/tr.json | 4 ++-- 11 files changed, 39 insertions(+), 31 deletions(-) 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 1c7915468..a2e4f73dc 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 @@ -17,6 +17,8 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit { public formGroup: FormGroup; + private readonly _REFERENCE_PREFIX:string = "Internal:"; + private readonly _KEY: string = 'Internal'; private existingReferences: string[] = []; get referenceExists(){ const reference = this.formGroup.get('reference').value; @@ -31,9 +33,9 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit { ) { super(); if(data){ - const researchers = (data as FormControl).value ; - if(researchers){ - this.existingReferences = (researchers as Array).map(researcher => researcher.reference); + const organisations = (data as FormControl).value ; + if(organisations){ + this.existingReferences = (organisations as Array).map(organisation => organisation.reference); } }} @@ -62,11 +64,11 @@ export class AddOrganizationComponent extends BaseComponent implements OnInit { return (control: AbstractControl) :Observable =>{ return control.valueChanges.pipe( debounceTime(600), - mergeMap(value=>this.externalSourcesService.searchDMPOrganizations('',value)), + mergeMap(value=>this.externalSourcesService.searchDMPOrganizations('',this._REFERENCE_PREFIX +value)), takeUntil(this._destroyed), map((response)=>{ if(response && response.length){ - const internalOrganizations = (response as Array).filter(organization=> organization.key === "Internal"); + const internalOrganizations = (response as Array).filter(organization=> organization.key === this._KEY); if(internalOrganizations && internalOrganizations.length){ return {organizationIdentifierExists:true}; diff --git a/dmp-frontend/src/app/ui/dmp/editor/add-researcher/add-researcher.component.ts b/dmp-frontend/src/app/ui/dmp/editor/add-researcher/add-researcher.component.ts index 036e5f475..79b29faec 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/add-researcher/add-researcher.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/add-researcher/add-researcher.component.ts @@ -16,7 +16,8 @@ export class AddResearcherComponent extends BaseComponent implements OnInit { public formGroup: FormGroup; - // private readonly _REFERENCE_PREFIX:string = "dmp:"; + private readonly _REFERENCE_PREFIX:string = "dmp:"; + private readonly _KEY:string = 'Internal'; private existingReferences: string[] = []; get referenceExists(){ const reference = this.formGroup.get('reference').value; @@ -70,12 +71,12 @@ export class AddResearcherComponent extends BaseComponent implements OnInit { return control.valueChanges.pipe( debounceTime(600), takeUntil(this._destroyed), - mergeMap(value=>this.externalSourcesService.searchDMPResearchers({criteria:{name: '',like: null,reference:value }})), + mergeMap(value=>this.externalSourcesService.searchDMPResearchers({criteria:{name: '',like: null,reference: (this._REFERENCE_PREFIX + value) }})), map((response)=>{ if(response && response.length){ - let internalEntries = (response as any[]).filter(record=>record.key === 'Internal'); + let internalEntries = (response as any[]).filter(record=>record.key === this._KEY); if(internalEntries && internalEntries.length){ - internalEntries = internalEntries.filter(record=> (record.reference === (control.value))); + internalEntries = internalEntries.filter(record=> (record.reference === (this._REFERENCE_PREFIX + control.value))); } return internalEntries && internalEntries.length? {researcherIdentifierExists:true} : null; } 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 701dc86dd..cffcf316f 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 @@ -48,6 +48,11 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { isFunderPending:boolean = false; isGrantPending:boolean = false; isProjectPending:boolean = false; + + private readonly _FUNDER_PREFIX = "dmp:"; + private readonly _GRANT_PREFIX = "dmp:"; + private readonly _PROJECT_PREFIX = "dmp:"; + private readonly _KEY = "Internal"; constructor( private grantService: GrantService, private projectService: ProjectService, @@ -101,12 +106,12 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { switchMap(value=> { const requestItem = new RequestItem(); requestItem.criteria = new FunderCriteria(); - requestItem.criteria.exactReference = value; + requestItem.criteria.exactReference = this._FUNDER_PREFIX +value; return this.funderService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); }), map(response=>{ if(response && response.length){ - const internalFunders = (response as Array).filter(funder=> funder.key === 'Internal'); + const internalFunders = (response as Array).filter(funder=> funder.key === this._KEY); if(internalFunders && internalFunders.length){ return {funderIdentifierExists:true}; @@ -136,12 +141,12 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { switchMap(value=> { const requestItem = new RequestItem(); requestItem.criteria = new GrantCriteria(); - requestItem.criteria.exactReference = value; + requestItem.criteria.exactReference = this._GRANT_PREFIX + value; return this.grantService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); }), map(response=>{ if(response && response.length){ - const internalGrants = (response as Array).filter(grant=> grant.key === 'Internal'); + const internalGrants = (response as Array).filter(grant=> grant.key === this._KEY); if(internalGrants && internalGrants.length){ return {grantIdentifierExists:true}; @@ -171,12 +176,12 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { switchMap(value=> { const requestItem = new RequestItem(); requestItem.criteria = new ProjectCriteria(); - requestItem.criteria.exactReference = value; + requestItem.criteria.exactReference = this._PROJECT_PREFIX + value; return this.projectService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); }), map(response=>{ if(response && response.length){ - const internalProjects = (response as Array).filter(project=> project.key === 'Internal'); + const internalProjects = (response as Array).filter(project=> project.key === this._KEY); if(internalProjects && internalProjects.length){ return {projectIdentifierExists:true}; } diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json index 4eb969ee9..044442adc 100644 --- a/dmp-frontend/src/assets/i18n/de.json +++ b/dmp-frontend/src/assets/i18n/de.json @@ -1006,8 +1006,8 @@ "HINT": "A brief description of what the DMP is about, it’s scope and objectives.", "TYPING": "Type more letters of the name so its more possible to find the correct one.", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." }, diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index d83161051..1dde2a135 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1006,8 +1006,8 @@ "HINT": "A brief description of what the DMP is about, it’s scope and objectives.", "TYPING": "Type more letters of the name so its more possible to find the correct one.", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." }, diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index 6ddb744ed..65a7c5f23 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -1006,8 +1006,8 @@ "HINT": "Una breve descripción sobre que trata el PGD, su ámbito y objetivos", "TYPING": "Escriba más letras del nombre para que sea más probable encontrar el correcto", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." }, diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index 3e02286b3..0e43d17bf 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -1006,8 +1006,8 @@ "HINT": "Μία σύντομη περιγραφή του τι αφορά το Σχέδιο Διαχείρισης Δεδομένων, του πεδίου εφαρμογής και των στόχων του.", "TYPING": "Προσθέστε περισσότερα γράμματα στο όνομα ώστε να είναι πιο πιθανό να βρείτε το σωστό.", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." }, diff --git a/dmp-frontend/src/assets/i18n/pt.json b/dmp-frontend/src/assets/i18n/pt.json index 8ec45c514..165080056 100644 --- a/dmp-frontend/src/assets/i18n/pt.json +++ b/dmp-frontend/src/assets/i18n/pt.json @@ -1006,8 +1006,8 @@ "HINT": "Uma breve descrição sobre o tema do PGD, o seu âmbito e objetivos.", "TYPING": "Digite mais letras do nome para que seja possível encontrá-lo mais facilmente.", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." }, diff --git a/dmp-frontend/src/assets/i18n/sk.json b/dmp-frontend/src/assets/i18n/sk.json index b2b434eb8..5b88441bb 100644 --- a/dmp-frontend/src/assets/i18n/sk.json +++ b/dmp-frontend/src/assets/i18n/sk.json @@ -1006,8 +1006,8 @@ "HINT": "Stručný opis toho, čoho sa DMP týka, jeho rozsah a ciele.", "TYPING": "Napíšte viac písmen názvu, aby bolo možné nájsť správny DMP.", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." }, diff --git a/dmp-frontend/src/assets/i18n/sr.json b/dmp-frontend/src/assets/i18n/sr.json index 33d91d8a9..adcd07e00 100644 --- a/dmp-frontend/src/assets/i18n/sr.json +++ b/dmp-frontend/src/assets/i18n/sr.json @@ -1006,8 +1006,8 @@ "HINT": "Kratki opis Plana sa namenom i ciljevima.", "TYPING": "Unesite još neko slovo da bismo lakše pronašli tačno ime.", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." }, diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json index 0a4ac60a6..ed1ca38c4 100644 --- a/dmp-frontend/src/assets/i18n/tr.json +++ b/dmp-frontend/src/assets/i18n/tr.json @@ -1006,8 +1006,8 @@ "HINT": "VYP'nin ne hakkında olduğunun, kapsamının ve hedeflerinin kısa bir açıklaması.", "TYPING": "Doğru olanı bulabilmek için daha fazla harf yazın.", "UNIQUE-IDENTIFIER": "Unique Identifier", - "RESEARCHER-IDENTIFIER-EXISTS": "A researcher with the given identifier already exists.", - "ORGANISATION-IDENTIFIER-EXSTS": "An organisation with the given identifier already exists.", + "RESEARCHER-IDENTIFIER-EXISTS": "Researcher identifier already exists.", + "ORGANISATION-IDENTIFIER-EXSTS": "Organisation identifier already exists.", "IDENTIFIER-EXISTS-RESEARCHER-LIST":"This identifier is already used by a researcher in the researchers list.", "IDENTIFIER-EXISTS-ORGANISATION-LIST":"This identifier is already used by an organisation in the organisations list." },