Revision 58552
Added by Argiro Kokogiannaki almost 4 years ago
searchBar.component.ts | ||
---|---|---|
6 | 6 |
@Component({ |
7 | 7 |
selector: 'search-bar', |
8 | 8 |
templateUrl: 'searchBar.component.html', |
9 |
styles:[` |
|
10 |
.mat-select-panel-wrap { |
|
11 |
z-index: 2001 |
|
12 |
} |
|
13 |
`] |
|
14 | 9 |
|
15 | 10 |
}) |
16 | 11 |
export class SearchBarComponent { |
... | ... | |
22 | 17 |
keyword: string = ""; |
23 | 18 |
entityType = "all"; |
24 | 19 |
enableSearchbar:boolean = true; |
25 |
@Input() customFilter: SearchCustomFilter = null; |
|
20 |
customFilter: SearchCustomFilter = null; |
|
21 |
@Input() communityId; |
|
22 |
@Input() onlyresults:boolean=false; |
|
26 | 23 |
parameters = {}; |
24 |
advancedSearchLink = null; |
|
27 | 25 |
constructor(private router: Router, |
28 | 26 |
private route: ActivatedRoute ) { |
29 | 27 |
} |
... | ... | |
31 | 29 |
ngOnInit() { |
32 | 30 |
|
33 | 31 |
// this.activeRouteEnabled = false; |
32 |
if(this.communityId){ |
|
33 |
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); |
|
34 |
} |
|
34 | 35 |
this.route.queryParams.subscribe(params => { |
35 | 36 |
this.parameters = Object.assign({}, params); |
36 | 37 |
this.entityType = "all"; |
37 |
if (params["type"] && params["type"].length > 0) { |
|
38 |
let types= params["type"].split(","); |
|
39 |
if(types.length == 1){ |
|
40 |
if(types.indexOf("publications")!=-1 ){ |
|
38 |
if(this.onlyresults) { |
|
39 |
if (params["type"] && params["type"].length > 0) { |
|
40 |
let types = params["type"].split(","); |
|
41 |
if (types.length == 1) { |
|
42 |
if (types.indexOf("publications") != -1) { |
|
41 | 43 |
this.entityType = "publications"; |
42 |
}else if(types.indexOf("datasets")!=-1 ){ |
|
43 |
this.entityType = "datasets"; |
|
44 |
}else if(types.indexOf("software")!=-1 ){ |
|
45 |
this.entityType = "software"; |
|
46 |
}else if(types.indexOf("other")!=-1 ){ |
|
47 |
this.entityType = "other"; |
|
44 |
} else if (types.indexOf("datasets") != -1) { |
|
45 |
this.entityType = "datasets"; |
|
46 |
} else if (types.indexOf("software") != -1) { |
|
47 |
this.entityType = "software"; |
|
48 |
} else if (types.indexOf("other") != -1) { |
|
49 |
this.entityType = "other"; |
|
50 |
} |
|
48 | 51 |
} |
49 | 52 |
} |
53 |
}else{ |
|
54 |
let currentRoute= this.getCurrentRoute(); |
|
55 |
if(currentRoute== this.properties.searchLinkToProjects){ |
|
56 |
this.entityType = "project"; |
|
57 |
}else if(currentRoute== this.properties.searchLinkToDataProviders){ |
|
58 |
this.entityType = "dataprovider"; |
|
59 |
}else if(currentRoute== this.properties.searchLinkToOrganizations){ |
|
60 |
this.entityType = "organization"; |
|
61 |
}else{ |
|
62 |
this.entityType = "result"; |
|
63 |
} |
|
50 | 64 |
} |
51 |
if(this.getCurrentRoute() == "/search/advanced/research-outcomes" ){
|
|
65 |
if(this.getCurrentRoute() == this.properties.searchLinkToAdvancedResults){
|
|
52 | 66 |
this.enableSearchbar = false; |
53 | 67 |
}else{ |
54 | 68 |
this.enableSearchbar = true; |
55 | 69 |
} |
56 |
// this.initialize(); |
|
70 |
if(this.entityType == "result"){ |
|
71 |
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults; |
|
72 |
}else{ |
|
73 |
this.advancedSearchLink = null; |
|
74 |
} |
|
57 | 75 |
}); |
58 | 76 |
|
59 | 77 |
} |
60 | 78 |
|
61 |
/* |
|
62 |
ngOnDestroy() { |
|
63 |
this.sub.unsubscribe(); |
|
64 |
} |
|
65 |
|
|
66 |
initialize() { |
|
67 |
this.activeRouteEnabled = false; |
|
68 |
this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user); |
|
69 |
/!*if (this.properties.adminToolsAPIURL && this.communityId) { |
|
70 |
this.config.getCommunityInformation(this.properties, this.communityId).subscribe(data => { |
|
71 |
for (var i = 0; i < data['entities'].length; i++) { |
|
72 |
|
|
73 |
this.showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"]; |
|
74 |
} |
|
75 |
for (var i = 0; i < data['pages'].length; i++) { |
|
76 |
this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"]; |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
}, |
|
81 |
error => { |
|
82 |
this.handleError("Error getting community information (e.g. pages,entities) for community with id: " + this.communityId, error); |
|
83 |
}); |
|
84 |
}*!/ |
|
85 |
|
|
86 |
}*/ |
|
87 |
|
|
88 | 79 |
isEnabled(required, enabled) { |
89 | 80 |
if (!required) { |
90 | 81 |
return true; |
... | ... | |
96 | 87 |
} |
97 | 88 |
return true; |
98 | 89 |
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
private handleError(message: string, error) { |
|
103 |
console.error("NavigationBar (component): " + message, error); |
|
104 |
} |
|
105 |
|
|
106 | 90 |
getCurrentRoute() { |
107 | 91 |
return this.router.url.split('?')[0]; |
108 | 92 |
} |
109 | 93 |
entityChanged($event){ |
110 | 94 |
this.entityType = $event.entity; |
111 | 95 |
this.searchRoute = $event.simpleUrl; |
112 |
|
|
113 |
// this.selectedEntityAdvancedUrl = $event.advancedUrl; |
|
114 |
// check if it is search or not |
|
115 |
//no search page |
|
116 |
|
|
96 |
if(!this.onlyresults && this.entityType == "result") { |
|
97 |
this.parameters["qf"] = true; |
|
98 |
} |
|
99 |
if(this.entityType == "result"){ |
|
100 |
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults; |
|
101 |
}else{ |
|
102 |
this.advancedSearchLink = null; |
|
103 |
} |
|
117 | 104 |
} |
118 | 105 |
keywordChanged(){ |
119 |
// this.parameters = {}; |
|
106 |
if(!this.onlyresults) { |
|
107 |
this.parameters = {}; |
|
108 |
} |
|
120 | 109 |
if ( this.keyword.length > 0) { |
121 | 110 |
this.parameters["fv0"] = this.keyword; |
122 | 111 |
this.parameters["f0"] = "q"; |
... | ... | |
124 | 113 |
delete this.parameters['fv0']; |
125 | 114 |
delete this.parameters['f0']; |
126 | 115 |
} |
127 |
if(this.entityType != "all"){ |
|
116 |
if(this.onlyresults && this.entityType != "all"){
|
|
128 | 117 |
this.parameters["type"] = this.entityType; |
129 | 118 |
}else{ |
130 | 119 |
delete this.parameters['type']; |
... | ... | |
133 | 122 |
if(!this.parameters["qf"]) { |
134 | 123 |
this.parameters["qf"] = true; |
135 | 124 |
} |
136 |
console.log(this.parameters); |
|
137 | 125 |
this.router.navigate([this.searchRoute], {queryParams: this.parameters} ); |
138 | 126 |
} |
139 | 127 |
} |
Also available in: Unified diff
[Library|Trunk]
Search:
-Entities Selection: add check if route is enabled
-Delay in result types checkboxes to 2 s
-Use breadcrumb component
-add connect background
-remove space between names in showAuthors component
-Filters:
-message about top 100 always visible
-rename to view all
-change css for search input
-show 100 if results > 95
-view less under the 2nd list
-Search bar:
-select contains all avaliable entities not only search results
-
Landing pages:
-correct issue with pmid in landing
-correct issue with date in cite this
-Hide Addthis:
value in properties