search page: remove all various search pages and keep only 'search all' - TODO: redirect old ?active=<entity> to the new path

This commit is contained in:
Alex Martzios 2023-05-10 15:10:00 +03:00
parent 389179540d
commit 619dd3c9fa
1 changed files with 57 additions and 34 deletions

View File

@ -203,26 +203,45 @@ export class SearchAllComponent {
loadAll() { loadAll() {
this.reloadTabs(); this.reloadTabs();
this.subs.push(this.route.queryParams.subscribe(params => { this.subs.push(this.route.queryParams.subscribe(queryParams => {
this.parameters = Object.assign({}, params); this.parameters = Object.assign({}, queryParams);
this.keyword = (params['keyword']) ? params['keyword'] : (params["q"] ? params["q"] : (params["f0"] && params["f0"] == "q" && params["fv0"]?params["fv0"]:"")); this.keyword = (queryParams['keyword']) ? queryParams['keyword'] : (queryParams["q"] ? queryParams["q"] : (queryParams["f0"] && queryParams["f0"] == "q" && queryParams["fv0"]?queryParams["fv0"]:""));
this.selectedFields[0].value = StringUtils.URIDecode(this.keyword); this.selectedFields[0].value = StringUtils.URIDecode(this.keyword);
this.quickFilter.selected = ((params['qf']== undefined || params["qf"] == "true") == true); this.quickFilter.selected = ((queryParams['qf']== undefined || queryParams["qf"] == "true") == true);
if (params["type"] && params["type"].length > 0) { if (queryParams["type"] && queryParams["type"].length > 0) {
this.resultTypes['publication'] = (params["type"].split(",").indexOf("publications") != -1); this.resultTypes['publication'] = (queryParams["type"].split(",").indexOf("publications") != -1);
this.resultTypes['dataset'] = (params["type"].split(",").indexOf("datasets") != -1); this.resultTypes['dataset'] = (queryParams["type"].split(",").indexOf("datasets") != -1);
this.resultTypes['software'] = (params["type"].split(",").indexOf("software") != -1); this.resultTypes['software'] = (queryParams["type"].split(",").indexOf("software") != -1);
this.resultTypes['other'] = (params["type"].split(",").indexOf("other") != -1); this.resultTypes['other'] = (queryParams["type"].split(",").indexOf("other") != -1);
} }
if(this.activeEntity == null && (!params["active"] || params["active"].length ==0)){ let active = null;
if (queryParams["active"] && queryParams["active"].length > 0) {
active = ((["result","projects","organizations","datasources","services"]).indexOf(queryParams["active"])!= -1)?queryParams["active"]:null;
}
this.subs.push(this.route.params.subscribe(params => {
if(this.activeEntity == null && (!params["entity"] || params["entity"].length == 0)){
if (active) {
this.activeEntity = active;
// if((typeof document !== 'undefined')){
// if (active == "result") {
// active = "research-outcomes";
// }
// console.log(location.search);
// let query = location.search.replace(/((active=).*&)|((active=).*)/, '');
// console.log(query);
// this.location.go(location.pathname + '/' + active, query == '?' ? '' : query);
// }
} else {
this.activeEntity = this.getDefaultEntityToShow(); this.activeEntity = this.getDefaultEntityToShow();
}else if(params["active"] && params["active"].length >0 ){
this.activeEntity = ((["result","projects","organizations","datasources","services"]).indexOf(params["active"])!= -1)?params["active"]:this.getDefaultEntityToShow();
}else if (this.activeEntity !=null && (!params["active"] || params["active"].length ==0)){
this.parameters["active"]=this.activeEntity;
if((typeof document !== 'undefined') && location.search && location.search.indexOf("active=") == -1){
this.location.go(location.pathname, ((location.search)?(location.search+"&"):("?")) +"active=" + this.activeEntity);
} }
} else if(params["entity"] && params["entity"].length > 0 ){
let entity = params["entity"];
if(entity == "research-outcomes") {
entity = "result";
} else if (entity == "dataproviders") {
entity = "datasources";
}
this.activeEntity = ((["result","projects","organizations","datasources","services"]).indexOf(entity)!= -1)?entity:this.getDefaultEntityToShow();
} }
if (this.activeEntity == "result") { if (this.activeEntity == "result") {
this.searchResults(); this.searchResults();
@ -237,6 +256,7 @@ export class SearchAllComponent {
} }
this.count(); this.count();
})); }));
}));
} }
getDefaultEntityToShow(){ getDefaultEntityToShow(){
@ -551,7 +571,6 @@ export class SearchAllComponent {
this.activeEntity = entity; this.activeEntity = entity;
this.parameters = {}; this.parameters = {};
this.reload[entity]= true; this.reload[entity]= true;
this.parameters["active"] = entity;
if ( this.keyword.length > 0) { if ( this.keyword.length > 0) {
this.parameters["fv0"] = this.keyword; this.parameters["fv0"] = this.keyword;
this.parameters["f0"] = "q"; this.parameters["f0"] = "q";
@ -559,7 +578,11 @@ export class SearchAllComponent {
if(this.customFilter){ if(this.customFilter){
this.parameters = this.customFilter.getParameters(this.parameters); this.parameters = this.customFilter.getParameters(this.parameters);
} }
this.router.navigate(["/search/find"], {queryParams: this.parameters}); if (entity == "result") {
entity = "research-outcomes";
this.parameters["resultbestaccessright"] = '"' + encodeURIComponent("Open Access") + '"';
}
this.router.navigate(["/search/find", entity], {queryParams: this.parameters});
} }
} }