From 70b7e30b70fb2477a73d6293d7414bd4add14b63 Mon Sep 17 00:00:00 2001 From: argirok Date: Mon, 29 Jan 2024 17:56:10 +0200 Subject: [PATCH] [angular-16-irish-monitor | DONE | CHANGED] Custom filters: add checks, add custom query --- searchPages/searchUtils/newSearchPage.component.ts | 10 +++++++--- searchPages/searchUtils/searchUtils.class.ts | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index d7cfb611..55b8f256 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -232,14 +232,14 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges { } private getPageContents() { - this.subscriptions.push(this.helper.getPageHelpContents(this.properties, (this.customFilters && this.customFilters[0].queryFieldName == "communityId") ? this.customFilters[0].valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getPageHelpContents(this.properties, (this.customFilters[0] && this.customFilters[0].queryFieldName == "communityId") ? this.customFilters[0].valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { this.pageContents = contents; })); } private getDivContents() { - this.subscriptions.push(this.helper.getDivHelpContents(this.properties, (this.customFilters && this.customFilters[0].queryFieldName == "communityId") ? this.customFilters[0].valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { + this.subscriptions.push(this.helper.getDivHelpContents(this.properties, (this.customFilters[0] && this.customFilters[0].queryFieldName == "communityId") ? this.customFilters[0].valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => { this.divContents = contents; })); } @@ -1245,7 +1245,11 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges { if (this.customFilters) { for (let customFilter of this.customFilters) { if (customFilter.isHiddenFilter) { - allFqs += "&fq=" + StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId))); + if(customFilter.customQuery){ + allFqs += "&fq=" + StringUtils.URIEncode(customFilter.customQuery); + }else { + allFqs += "&fq=" + StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId))); + } } } } diff --git a/searchPages/searchUtils/searchUtils.class.ts b/searchPages/searchUtils/searchUtils.class.ts index 083f7750..433e5e1e 100644 --- a/searchPages/searchUtils/searchUtils.class.ts +++ b/searchPages/searchUtils/searchUtils.class.ts @@ -28,7 +28,8 @@ export class SearchCustomFilter{ isHiddenFilter:boolean; selected:boolean; showFilterMessage:boolean; - constructor( fieldName:string, queryFieldName:string, valueId:string, valueName:string, showFilterMessage:boolean = true ){ + customQuery:string; + constructor( fieldName:string, queryFieldName:string, valueId:string, valueName:string, showFilterMessage:boolean = true, customQuery = null ){ if(valueId == "test" && properties.environment == "development"){ valueId = "covid-19"; } @@ -39,6 +40,7 @@ export class SearchCustomFilter{ this.valueId = valueId; this.valueName = valueName; this.selected = null; + this.customQuery = customQuery; } public getParameters(params={}){