From 6f13ab475a71fcc53f4eb70307ae8b60b20375f8 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 8 Jan 2024 15:36:27 +0200 Subject: [PATCH] [develop | DONE | CHANGED]: Show code in Fields of Science (FoS) when fos field is queried in filters, or not, when foslabel field is queried. 1. searchFields.base.ts: Added method "getFosParameter()" to check if "fos" or "foslabel" is in RESULT_REFINE_FIELDS | Removed environment check for fos in RESULT_REFINE_FIELDS and RESULT_FIELDS_ORDERED. 2. resultLanding.service.ts & landing-utils/fos.component.ts & fos/fos.component: Include code in fos labels when fos field is queried, otherwise (foslabel) not. --- fos/fos.component.html | 4 ++-- fos/fos.component.ts | 4 +++- landingPages/landing-utils/fos.component.ts | 6 ++++-- landingPages/result/resultLanding.service.ts | 7 ++++++- utils/properties/searchFields.base.ts | 8 ++++++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/fos/fos.component.html b/fos/fos.component.html index d9635936..5121aa2f 100644 --- a/fos/fos.component.html +++ b/fos/fos.component.html @@ -113,7 +113,7 @@
- {{subChild.label}} + {{searchFieldsHelper.getFosParameter() == 'foslabel' ? subChild.label : subChild.id}}
@@ -139,7 +139,7 @@
+ class="uk-link-text" [innerHTML]="highlightKeyword(searchFieldsHelper.getFosParameter() == 'foslabel' ? subSubItem.label : subSubItem.id)">
diff --git a/fos/fos.component.ts b/fos/fos.component.ts index 043e7bd5..3065b2c0 100644 --- a/fos/fos.component.ts +++ b/fos/fos.component.ts @@ -15,6 +15,7 @@ import {PiwikService} from "../utils/piwik/piwik.service"; import {debounceTime, distinctUntilChanged} from "rxjs/operators"; import Timeout = NodeJS.Timeout; import {ISVocabulariesService} from "../utils/staticAutoComplete/ISVocabularies.service"; +import {SearchFields} from "../utils/properties/searchFields"; declare var UIkit; @@ -46,6 +47,7 @@ export class FosComponent implements OnInit, OnDestroy { private timeout: Timeout; @ViewChild('tabs') tabs: ElementRef; public sliderInit: boolean = false; + private searchFieldsHelper: SearchFields = new SearchFields(); constructor( private vocabulariesService: ISVocabulariesService, @@ -217,6 +219,6 @@ export class FosComponent implements OnInit, OnDestroy { public buildFosQueryParam(fos) { // return {'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}; - return (properties.environment !== 'production' ? ({'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}) : ({'fos': this.urlEncodeAndQuote(fos.id)})); + return (this.searchFieldsHelper.getFosParameter() == 'foslabel' ? ({'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}) : ({'fos': this.urlEncodeAndQuote(fos.id)})); } } diff --git a/landingPages/landing-utils/fos.component.ts b/landingPages/landing-utils/fos.component.ts index 7b201015..e489cbd9 100644 --- a/landingPages/landing-utils/fos.component.ts +++ b/landingPages/landing-utils/fos.component.ts @@ -2,6 +2,7 @@ import {Component, EventEmitter, Input, Output} from "@angular/core"; import {RouterHelper} from "../../utils/routerHelper.class"; import {properties} from "../../../../environments/environment"; import {StringUtils} from "../../utils/string-utils.class"; +import {SearchFields} from "../../utils/properties/searchFields"; @Component({ selector: 'fos', @@ -96,6 +97,7 @@ export class FosComponent { public routerHelper: RouterHelper = new RouterHelper(); public properties = properties; public title: string = "Fields of Science"; + private searchFieldsHelper: SearchFields = new SearchFields(); public viewAllClick() { // if(this.subjects.length <= this.threshold*2) { @@ -122,11 +124,11 @@ export class FosComponent { public buildFosQueryParam(fos) { // return {'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}; - return (properties.environment !== 'production' ? ({'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}) : ({'fos': this.urlEncodeAndQuote(fos.id)})); + return (this.searchFieldsHelper.getFosParameter() == 'foslabel' ? ({'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}) : ({'fos': this.urlEncodeAndQuote(fos.id)})); } public buildFosHrefParam(fos): string { // return ('foslabel='+this.urlEncodeAndQuote(fos.id+"||"+fos.label)); - return (properties.environment !== 'production' ? ('foslabel='+this.urlEncodeAndQuote(fos.id+"||"+fos.label)) : ('fos='+this.urlEncodeAndQuote(fos.id))); + return (this.searchFieldsHelper.getFosParameter() == 'foslabel' ? ('foslabel='+this.urlEncodeAndQuote(fos.id+"||"+fos.label)) : ('fos='+this.urlEncodeAndQuote(fos.id))); } } diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 7ed58bb0..df6e8745 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -9,6 +9,7 @@ import {HostedByCollectedFrom, Organization} from "../../utils/result-preview/re import {Dates, Identifier, StringUtils} from "../../utils/string-utils.class"; import {properties} from "../../../../environments/environment"; import {HelperFunctions} from "../../utils/HelperFunctions.class"; +import {SearchFields} from "../../utils/properties/searchFields"; @Injectable() export class ResultLandingService { @@ -312,9 +313,13 @@ export class ResultLandingService { this.resultLandingInfo.subjects = subjectResults[0]; this.resultLandingInfo.otherSubjects = subjectResults[1]; this.resultLandingInfo.classifiedSubjects = subjectResults[2]; + if (subjectResults[3]) { + let searchFieldsHelper: SearchFields = new SearchFields(); subjectResults[3].forEach(element => { - this.resultLandingInfo.fos.push({id: element, label: element.replace(/^\d+/, '').trim()}); + this.resultLandingInfo.fos.push( + {id: element, label: searchFieldsHelper.getFosParameter() == "foslabel" ? element.replace(/^\d+/, '').trim() : element} + ); }); } if (this.resultLandingInfo.fos) { diff --git a/utils/properties/searchFields.base.ts b/utils/properties/searchFields.base.ts index 335409be..3b4a19bd 100644 --- a/utils/properties/searchFields.base.ts +++ b/utils/properties/searchFields.base.ts @@ -16,7 +16,7 @@ export class SearchFieldsBase { // Remove Collected From Filter "collectedfrom","collectedfrom" public RESULT_REFINE_FIELDS = [ - "instancetypename", properties.environment!='production'?"foslabel":'fos', "relfunder", + "instancetypename", "foslabel", "relfunder", "relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id", "relproject", "sdg", "country", "resultlanguagename", "resulthostingdatasource", "community"]; @@ -25,7 +25,7 @@ export class SearchFieldsBase { {type: "refine", title: "", values: ["instancetypename"]}, {type: "range", title: "", values: ["resultacceptanceyear", "resultacceptanceyear"]}, {type: "refine", title: "", values: [ - properties.environment!='production'?"foslabel":'fos', "relfunder", + "foslabel", "relfunder", "relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id", "relproject", "sdg", "country", "resultlanguagename", "resulthostingdatasource", "community" ]} @@ -885,6 +885,10 @@ export class SearchFieldsBase { } return "or"; } + + getFosParameter() { + return this.RESULT_REFINE_FIELDS.includes("foslabel") ? "foslabel" : "fos"; + } } export class FieldDetails {