From fc2fbb5ba008712b856a60d28e341dc1475fab80 Mon Sep 17 00:00:00 2001 From: argirok Date: Thu, 21 Apr 2022 16:35:34 +0300 Subject: [PATCH] fix issue with selected types filter --- .../searchUtils/newSearchPage.component.ts | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index 15e4ce38..a5202f80 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -1468,23 +1468,25 @@ export class NewSearchPageComponent { }*/ if ((this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")) { this.resultTypes = {values:[],filterId:"type", countSelectedValues: 0, filterType: 'checkbox', originalFilterId: "", valueIsExact: true, title: "Type",filterOperator:"or"}; - if (URLparams["type"]) { - let types = URLparams["type"]; - types = Array.isArray(types) ? types.join(',').split(",") : types.split(","); - for (let type of types) { - if (["publications", "datasets", "software", "other"].indexOf(StringUtils.unquote(type)) != -1 && this.resultTypeOptions[StringUtils.unquote(type)]) { - this.resultTypes.values.push({ - name: this.resultTypeOptions[StringUtils.unquote(type)].name, - id: StringUtils.unquote(type), - selected: true, - number: 0 - }); - this.resultTypes.countSelectedValues++; - } + for (let typeOption of Object.keys(this.resultTypeOptions)) { + let type = typeOption; + if ( URLparams["type"] && URLparams["type"].indexOf(type)==-1 || !URLparams["type"]) { + this.resultTypes.values.push({ + name: this.resultTypeOptions[StringUtils.unquote(type)].name, + id: StringUtils.unquote(type), + selected: false, + number: 0 + }); + }else{ + this.resultTypes.values.push({ + name: this.resultTypeOptions[StringUtils.unquote(type)].name, + id: StringUtils.unquote(type), + selected: true, + number: 0 + }); + this.resultTypes.countSelectedValues++; } - } - } this.URLCreatedFilters = filters;