Search researcher add keyword as URL parameter

This commit is contained in:
argirok 2023-11-13 14:54:52 +02:00
parent dfa7c2a8c2
commit cff2dc8048
2 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,6 @@
<div class=" uk-flex uk-flex-center ">
<div search-input [(value)]="keyword" [placeholder]="'Search for author or ORCID...'"
[searchInputClass]="'inner background'" (searchEmitter)="search()" class="uk-width-xlarge@l uk-width-large@m"></div>
[searchInputClass]="'inner background'" (searchEmitter)="keywordChanged()" class="uk-width-xlarge@l uk-width-large@m"></div>
</div>
<div class="uk-margin-top">

View File

@ -7,7 +7,7 @@ import {SearchResearchResultsService} from "../../openaireLibrary/services/searc
import {forkJoin, Subscriber} from "rxjs";
import {properties} from "../../../environments/environment";
import {BaseComponent} from "../../openaireLibrary/sharedComponents/base/base.component";
import {Router} from "@angular/router";
import {ActivatedRoute, Router} from "@angular/router";
import {SEOService} from "../../openaireLibrary/sharedComponents/SEO/SEO.service";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
import {Meta, Title} from "@angular/platform-browser";
@ -33,6 +33,8 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit
constructor(private _searchOrcidService: SearchOrcidService,
private _searchResearchResultsService: SearchResearchResultsService,
protected _router: Router,
protected _route: ActivatedRoute,
protected seoService: SEOService,
protected _piwikService: PiwikService,
protected _title: Title,
@ -43,10 +45,12 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit
this.title = 'Researcher Monitors';
this.description = 'Researcher Monitors';
this.setMetadata();
if (this.keyword != null && this.keyword.length > 0) {
this.search();
}
this.subscriptions.push(this._route.queryParams.subscribe(params => {
if (params['keyword']) {
this.keyword = params['keyword'];
this.search();
}
}));
}
ngOnDestroy() {
@ -56,6 +60,10 @@ export class SearchResearcherComponent extends BaseComponent implements OnInit
}
});
}
keywordChanged(){
this._router.navigate(['/researcher'], {queryParams: {keyword:this.keyword}});
}
search() {
//uncomment to disable search with no keyword
if (this.keyword.length == 0) {