From 58d45c90888d63a3fecb3d08ee12a6aa4ab707f8 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 9 Jun 2022 16:23:01 +0300 Subject: [PATCH] Home: Add searchable at search form. Fos: Create fos options for autocomplete --- explore/src/app/fos/fos.component.html | 2 +- explore/src/app/fos/fos.component.ts | 24 +++++++++++++++++++++--- explore/src/app/home/home.component.html | 2 +- explore/src/app/openaireLibrary | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/explore/src/app/fos/fos.component.html b/explore/src/app/fos/fos.component.html index 7dfa3f3c..aca460f5 100644 --- a/explore/src/app/fos/fos.component.html +++ b/explore/src/app/fos/fos.component.html @@ -39,7 +39,7 @@
-
diff --git a/explore/src/app/fos/fos.component.ts b/explore/src/app/fos/fos.component.ts index 05ef696d..4311f3c2 100644 --- a/explore/src/app/fos/fos.component.ts +++ b/explore/src/app/fos/fos.component.ts @@ -16,7 +16,8 @@ import {Location} from "@angular/common"; }) export class FosComponent implements OnInit, OnDestroy { - public fos: any = []; + public fos: any[] = []; + public fosOptions: string[] = []; public index: number = 0; public keywordControl: FormControl; @@ -42,6 +43,7 @@ export class FosComponent implements OnInit, OnDestroy { this.keywordControl = this.fb.control(''); this.httpClient.get(properties.domain+'/assets/vocabulary/fos.json').subscribe(data => { this.fos = data['fos']; + this.convertFosToOptions(); this.subscriptions.push(this.route.queryParams.subscribe(params => { if(params.keyword) { this.keywordControl.setValue(params.keyword); @@ -70,9 +72,25 @@ export class FosComponent implements OnInit, OnDestroy { this.findMatches(); } } + + convertFosToOptions() { + this.fosOptions = []; + 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); + }); + } + }); + } + }); + } findMatches() { - console.log(this.keyword); this.viewResults = JSON.parse(JSON.stringify(this.fos)); let matchLevel1: boolean = false; let matchLevel2: boolean = false; @@ -117,4 +135,4 @@ export class FosComponent implements OnInit, OnDestroy { this.keywordControl.setValue(''); this.location.go(window.location.pathname); } -} \ No newline at end of file +} diff --git a/explore/src/app/home/home.component.html b/explore/src/app/home/home.component.html index c7fb9fa1..308d918e 100644 --- a/explore/src/app/home/home.component.html +++ b/explore/src/app/home/home.component.html @@ -31,7 +31,7 @@ -
+
diff --git a/explore/src/app/openaireLibrary b/explore/src/app/openaireLibrary index f3af762d..5e11488c 160000 --- a/explore/src/app/openaireLibrary +++ b/explore/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit f3af762dab9b3d489dd4f78c46f3537aff840efd +Subproject commit 5e11488c8ff49da0675ce58924a415964aefd968