[Library|Trunk]
Search Bar: catch more events and initialize on params change, route chnages, and on entity changed git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58579 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
0b5cf0f6f8
commit
b35ebb80fc
|
@ -1,5 +1,5 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ActivatedRoute, NavigationEnd, NavigationStart, Router} from '@angular/router';
|
||||
import {EnvProperties} from "../../utils/properties/env-properties";
|
||||
import {SearchCustomFilter} from "../../searchPages/searchUtils/searchUtils.class";
|
||||
|
||||
|
@ -24,6 +24,12 @@ export class SearchBarComponent {
|
|||
advancedSearchLink = null;
|
||||
constructor(private router: Router,
|
||||
private route: ActivatedRoute ) {
|
||||
this.router.events.subscribe((e) => {
|
||||
if(e instanceof NavigationEnd){
|
||||
// console.log(e)
|
||||
this.initialize();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -32,9 +38,9 @@ export class SearchBarComponent {
|
|||
if(this.communityId){
|
||||
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
|
||||
}
|
||||
this.entityType = "all";
|
||||
this.route.queryParams.subscribe(params => {
|
||||
this.parameters = Object.assign({}, params);
|
||||
this.entityType = "all";
|
||||
if(this.onlyresults) {
|
||||
if (params["type"] && params["type"].length > 0) {
|
||||
let types = params["type"].split(",");
|
||||
|
@ -50,7 +56,12 @@ export class SearchBarComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}
|
||||
});
|
||||
this.initialize()
|
||||
}
|
||||
initialize(){
|
||||
if(!this.onlyresults){
|
||||
let currentRoute= this.getCurrentRoute();
|
||||
if(currentRoute== this.properties.searchLinkToProjects){
|
||||
this.entityType = "project";
|
||||
|
@ -67,15 +78,15 @@ export class SearchBarComponent {
|
|||
}else{
|
||||
this.enableSearchbar = true;
|
||||
}
|
||||
if(this.getCurrentRoute() == this.properties.searchLinkToResults){
|
||||
this.showAdvancedLink();
|
||||
}
|
||||
showAdvancedLink(){
|
||||
if(this.getCurrentRoute() == this.properties.searchLinkToResults && this.entityType == "result"){
|
||||
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults;
|
||||
}else{
|
||||
this.advancedSearchLink = null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
isEnabled(required, enabled) {
|
||||
if (!required) {
|
||||
return true;
|
||||
|
@ -96,11 +107,7 @@ export class SearchBarComponent {
|
|||
if(!this.onlyresults && this.entityType == "result") {
|
||||
this.parameters["qf"] = true;
|
||||
}
|
||||
/* if(this.entityType == "result"){
|
||||
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults;
|
||||
}else{
|
||||
this.advancedSearchLink = null;
|
||||
}*/
|
||||
this.showAdvancedLink();
|
||||
}
|
||||
keywordChanged(){
|
||||
if(!this.onlyresults) {
|
||||
|
|
Loading…
Reference in New Issue