|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|