From f595ec50359559abe5f7db2103ca962219bc7d2d Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 May 2024 15:04:56 +0300 Subject: [PATCH 1/6] [develop | WIP | ADDED]: [DEVELOPMENT ONLY] Added level4 in browse Fields of Science (FoS) 1. smooth-scroll.ts: Get behavior from current navigation > extras > state. 2. fos.component: Display level 4 FoS and handle url fragments and page scrolling accordingly. --- fos/fos.component.html | 116 +++++++++++++++++++++++++++++++++++---- fos/fos.component.ts | 122 ++++++++++++++++++++++++++++++++++------- utils/smooth-scroll.ts | 8 ++- 3 files changed, 210 insertions(+), 36 deletions(-) diff --git a/fos/fos.component.html b/fos/fos.component.html index 1d0c8bf5..5bc80108 100644 --- a/fos/fos.component.html +++ b/fos/fos.component.html @@ -36,9 +36,11 @@ -
+ +
-
+ @@ -137,10 +223,16 @@ class="uk-link-text" [innerHTML]="highlightKeyword(subItem.id)"> -
+
+ +
+ + +
diff --git a/fos/fos.component.ts b/fos/fos.component.ts index 3065b2c0..e86317ea 100644 --- a/fos/fos.component.ts +++ b/fos/fos.component.ts @@ -16,6 +16,7 @@ import {debounceTime, distinctUntilChanged} from "rxjs/operators"; import Timeout = NodeJS.Timeout; import {ISVocabulariesService} from "../utils/staticAutoComplete/ISVocabularies.service"; import {SearchFields} from "../utils/properties/searchFields"; +import {HelperFunctions} from "../utils/HelperFunctions.class"; declare var UIkit; @@ -28,6 +29,8 @@ export class FosComponent implements OnInit, OnDestroy { public url: string = null; public pageTitle: string = "OpenAIRE | Fields of Science"; public pageDescription: string = "We have integrated a Field-of-Science (FoS) taxonomy into our dataset to organize and discover research more effectively. Using the full capabilities of the OpenAIRE Graph (full-texts, citations, references, venues) we apply AI and bring forward any multidisciplinarity potential."; + public scrollPos = 0; + public selectedParentLevels = []; public fos: any[] = []; public fosOptions: string[] = []; public activeSection: string; @@ -82,21 +85,43 @@ export class FosComponent implements OnInit, OnDestroy { item.classList.remove('uk-active'); }); if (this.route.snapshot.fragment) { - this.activeSection = this.route.snapshot.fragment; - let i = this.fos.findIndex(item => item.id == this.route.snapshot.fragment); - slider.show(i); + let splitFragment = this.route.snapshot.fragment.split("||"); + this.activeSection = this.route.snapshot.fragment.split("||")[0]; + let i = this.fos.findIndex(item => (item.id == this.route.snapshot.fragment || this.route.snapshot.fragment.startsWith(item.id+"||"))); + if(i <0 || i>this.fos.length-1) { + this._router.navigate(['./'], {fragment: "", relativeTo: this.route, state: {disableScroll: true}}); + } else { + if (splitFragment.length > 1) { + let level1 = this.fos[i]; + let level2 = null; + let level3 = null; + if (level1.children) { + level2 = level1.children.find(item => item.code == splitFragment[1]); + if (level2 && level2.children) { + level3 = level2.children.find(item => item.code == splitFragment[2]); + this.selectedParentLevels = [this.fos[i], level2, level3]; + } + } + if(!level2 || !level3) { + this._router.navigate(['./'], {fragment: level1.id, relativeTo: this.route, state: {disableScroll: true}}); + } + } else { + slider.show(i); + } + } } else { this.activeSection = this.fos[0].id; } this.cdr.detectChanges(); }); } + this.subscriptions.push(this.route.fragment.subscribe(fragment => { if(fragment) { - this.activeSection = fragment; + this.activeSection = fragment.split("||")[0]; if(this.tabs) { let slider = UIkit.slider(this.tabs.nativeElement); - let i = this.fos.findIndex(item => item.id == fragment); + let i = this.fos.findIndex(item => (item.id == fragment || fragment.startsWith(item.id+"||"))); slider.show(i); } } else { @@ -105,13 +130,16 @@ export class FosComponent implements OnInit, OnDestroy { })); this.keywordControl = this.fb.control(''); this.subscriptions.push(this.keywordControl.valueChanges.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => { - this.keyword = value; - this.findMatches(this.keyword); - if (typeof IntersectionObserver !== 'undefined') { - setTimeout(() => { - this.setObserver(); - }); - } + if(this.keyword !== undefined || value) { + this.selectedParentLevels = []; + } + this.keyword = value; + this.findMatches(this.keyword); + if (typeof IntersectionObserver !== 'undefined') { + setTimeout(() => { + this.setObserver(); + }); + } })); }); } @@ -154,11 +182,16 @@ export class FosComponent implements OnInit, OnDestroy { this.fos.forEach(fos => { this.fosOptions.push(fos.id); if(fos.children) { - fos.children.forEach(child => { - this.fosOptions.push(child.id); - if(child.children) { - child.children.forEach(child2 => { - this.fosOptions.push(child2.id); + fos.children.forEach(l2 => { + this.fosOptions.push(l2.id); + if(l2.children) { + l2.children.forEach(l3 => { + this.fosOptions.push(l3.id); + if(l3.children) { + l3.children.forEach(l4 => { + this.fosOptions.push(l4.id); + }) + } }); } }); @@ -170,19 +203,29 @@ export class FosComponent implements OnInit, OnDestroy { this.viewResults = JSON.parse(JSON.stringify(this.fos)); let matchLevel1: boolean = false; let matchLevel2: boolean = false; + let matchLevel3: boolean = false; // 1st level search if(this.viewResults.length) { this.viewResults = this.viewResults.filter(item => { matchLevel1 = !!item.id.includes(value?.toLowerCase()); - // // 2nd level search + // 2nd level search if(item.children?.length && !matchLevel1) { item.children = item.children.filter(subItem => { matchLevel2 = !!subItem.id.includes(value?.toLowerCase()); // 3rd level search if(subItem.children?.length && !matchLevel2) { - subItem.children = subItem.children.filter(subSubItem => subSubItem.id.includes(value?.toLowerCase())); + subItem.children = subItem.children.filter(subSubItem => { + matchLevel3 = subSubItem.id.includes(value?.toLowerCase()); + // 4th level search + if(subSubItem.children?.length && !matchLevel3) { + subSubItem.children = subSubItem.children.filter(level4Item => { + return level4Item.id.toLowerCase().includes(value?.toLowerCase()) + }); + } + return subSubItem.children?.length > 0 || matchLevel3; + }); } - return subItem.children?.length > 0 || matchLevel2; + return subItem.children?.length > 0; }); } return item.children?.length > 0; @@ -191,7 +234,7 @@ export class FosComponent implements OnInit, OnDestroy { } highlightKeyword(name) { - if(name.includes(this.keyword.toLowerCase())) { + if(name.toLowerCase().includes(this.keyword.toLowerCase())) { return name.replace(new RegExp(this.keyword, "gi"), (matchedValue) => `${matchedValue}`); } else { return name; @@ -221,4 +264,41 @@ export class FosComponent implements OnInit, OnDestroy { // return {'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}; return (this.searchFieldsHelper.getFosParameter() == 'foslabel' ? ({'foslabel': this.urlEncodeAndQuote(fos.id+"||"+fos.label)}) : ({'fos': this.urlEncodeAndQuote(fos.id)})); } + + public backClicked() { + let id = this.selectedParentLevels[0].id; + this.selectedParentLevels=[]; + this.cdr.detectChanges(); + + if(this.scrollPos) { + HelperFunctions.scrollTo(0, this.scrollPos); + this._router.navigate(['./'], {fragment: id, relativeTo: this.route, state: {disableScroll: true}}); + } else { + this._router.navigate(['./'], { + fragment: id, + relativeTo: this.route, + state: {disableScroll: false, behavior: 'auto'} + }); + } + + this.cdr.detectChanges(); + if (typeof IntersectionObserver !== 'undefined') { + setTimeout(() => { + this.setObserver(); + }, 200); + } + } + + public moreClicked(level1, level2, level3) { + this.scrollPos = window.scrollY; + + if(this.observer) { + this.observer.disconnect(); + } + this.selectedParentLevels=[level1, level2, level3]; + this.cdr.detectChanges(); + this._router.navigate(['./'], + {fragment: this.selectedParentLevels[0].id+"||"+this.selectedParentLevels[1].code+"||"+this.selectedParentLevels[2].code, + relativeTo: this.route, state: {disableScroll: false, behavior: 'auto'}}); + } } diff --git a/utils/smooth-scroll.ts b/utils/smooth-scroll.ts index c828b450..15400e43 100644 --- a/utils/smooth-scroll.ts +++ b/utils/smooth-scroll.ts @@ -24,10 +24,11 @@ export class SmoothScroll { } else if (event instanceof NavigationEnd) { let headerOffset = (this.layoutService.isMobileValue?0:Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--header-height'))) + 35; if(!this.router.getCurrentNavigation().extras?.state?.disableScroll) { + let behavior = this.router.getCurrentNavigation().extras?.state?.behavior ? this.router.getCurrentNavigation().extras?.state?.behavior : "smooth"; if (this.interval) { clearInterval(this.interval); } - const fragment = router.parseUrl(router.url).fragment; + const fragment = router.parseUrl(routerurl).fragment; if (this.lastComponent !== this.currentComponent) { window.scrollTo({top: 0}); } @@ -48,7 +49,7 @@ export class SmoothScroll { } else { clearInterval(interval); const y = element.getBoundingClientRect().top + window.scrollY + yOffset; - window.scrollTo({top: y, behavior: 'smooth'}); + window.scrollTo({top: y, behavior: behavior}); } }, 50); } @@ -58,7 +59,7 @@ export class SmoothScroll { }, 100); } else { setTimeout( () => { - window.scrollTo({top: 0, behavior: 'smooth'}); + window.scrollTo({top: 0, behavior: behavior}); }, 0); } } @@ -77,3 +78,4 @@ export class SmoothScroll { } } } +. \ No newline at end of file From 1f4c0566c7f4f526124507d5b5ee9b7387893fe8 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 May 2024 15:16:00 +0300 Subject: [PATCH 2/6] [develop | DONE | FIXED]: availableOn.component.ts: Removed environment check in
shown in mobile under fulltext. --- landingPages/landing-utils/availableOn.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/landingPages/landing-utils/availableOn.component.ts b/landingPages/landing-utils/availableOn.component.ts index 85fef1ea..507afcb8 100644 --- a/landingPages/landing-utils/availableOn.component.ts +++ b/landingPages/landing-utils/availableOn.component.ts @@ -33,8 +33,9 @@ import {RouterHelper} from "../../utils/routerHelper.class";
-

-
+

+
+
From 019530c22255c42b873ebe5eb30616638e4e6d8f Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 May 2024 15:17:26 +0300 Subject: [PATCH 3/6] [develop | DONE | FIXED]: parsingFunctions.class.ts: In "parseEoscSubjects()" method, initialize subjects if needed. --- landingPages/landing-utils/parsingFunctions.class.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index 26c1f9d0..00e90aa8 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -665,6 +665,9 @@ export class ParsingFunctions { } if(properties.environment != "production" && classifiedSubjects != null) { + if (subjects == undefined) { + subjects = new Array(); + } for (let classified of classifiedSubjects.keys()) { subjects = subjects.concat(classifiedSubjects.get(classified)); } From d3746b28d0445a5712b2ba3b85a28a110eff87c9 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 May 2024 15:18:54 +0300 Subject: [PATCH 4/6] [develop | DONE | CHANGED]: organization.service.ts & searchOrganizations.service.ts: Removed environment check for parsing organization pid. --- services/organization.service.ts | 2 +- services/searchOrganizations.service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/organization.service.ts b/services/organization.service.ts index b74bd92f..44a81633 100644 --- a/services/organization.service.ts +++ b/services/organization.service.ts @@ -95,7 +95,7 @@ export class OrganizationService { } } - if(organization['pid'] && properties.environment != "production") { + if(organization['pid']) { this.organizationInfo.identifiers = this.parsingFunctions.parseIdentifiers(organization['pid']); } } diff --git a/services/searchOrganizations.service.ts b/services/searchOrganizations.service.ts index 019b8146..60b4d794 100644 --- a/services/searchOrganizations.service.ts +++ b/services/searchOrganizations.service.ts @@ -175,7 +175,7 @@ export class SearchOrganizationsService { result.country = resData.country.classname; } - if(resData['pid'] && properties.environment != "production") { + if(resData['pid']) { result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']); } From 8bcafd30262da4c1fb72733231c23417b03c3822 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 May 2024 15:24:04 +0300 Subject: [PATCH 5/6] [develop | DONE | FIXED]: smooth-scroll.ts: Accidental error by mistyping. --- utils/smooth-scroll.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/smooth-scroll.ts b/utils/smooth-scroll.ts index 15400e43..40014030 100644 --- a/utils/smooth-scroll.ts +++ b/utils/smooth-scroll.ts @@ -28,7 +28,7 @@ export class SmoothScroll { if (this.interval) { clearInterval(this.interval); } - const fragment = router.parseUrl(routerurl).fragment; + const fragment = router.parseUrl(router.url).fragment; if (this.lastComponent !== this.currentComponent) { window.scrollTo({top: 0}); } @@ -77,5 +77,4 @@ export class SmoothScroll { clearInterval(this.interval); } } -} -. \ No newline at end of file +} \ No newline at end of file From 2a28cd8ad5e917de507e6c112f9949a18fc263ea Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 May 2024 15:59:32 +0300 Subject: [PATCH 6/6] [develop | DONE | CHANGED]: #9764 - searchOrganizations.service.ts: Parse and display organization legalname and legalshortname. --- services/searchOrganizations.service.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/searchOrganizations.service.ts b/services/searchOrganizations.service.ts index 60b4d794..2bf09fca 100644 --- a/services/searchOrganizations.service.ts +++ b/services/searchOrganizations.service.ts @@ -100,13 +100,16 @@ export class SearchOrganizationsService { result['title'] = {"name": '', "accessMode": ''}; - if(resData.legalshortname) { - result['title'].name = StringUtils.HTMLToString(String(resData.legalshortname)); - } - if(!result['title'].name || result['title'].name == '') { + if(resData.legalname) { result['title'].name = StringUtils.HTMLToString(String(resData.legalname)); + } else { + result['title'].name = ""; } + if(resData.legalshortname) { + result['acronym'] = StringUtils.HTMLToString(String(resData.legalshortname)); + } + //result['title'].url = OpenaireProperties.getsearchLinkToOrganization(); //result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];