Indicator utils fixes - related to #8135

- count applied filters when the filter is applied to a field tha has a parameter filter
- apply filters in all select fields not only in the 1st
This commit is contained in:
argirok 2022-10-11 10:24:34 +03:00
parent 1a13bd942c
commit 7347a06eea
1 changed files with 39 additions and 33 deletions

View File

@ -336,7 +336,10 @@ export class IndicatorUtils {
if (key == "index_shortName") {
replacedValue = stakeholder.index_shortName.toLowerCase();
}
//if there is a parameter that is filtered and the value of the parameter changes, count the filter as applied
if(replacedValue !=indicatorPath.parameters[key]){
indicatorPath.filtersApplied++;
}
replacedUrl = replacedUrl.split(ChartHelper.prefix + key + ChartHelper.suffix).join(replacedValue)
});
}
@ -459,11 +462,13 @@ export class IndicatorUtils {
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
queries["query"]["filters"] = [];
}
let field = queries["query"]["select"][0]["field"];
//apply the filter in any select fields
for (let select of queries["query"]["select"]) {
let field = select["field"];
let filterString = IndicatorFilterUtils.getFilter(field&&field.length > 0? field.split(".")[0]:"",filterType);
if (filterString) {
let filter = JSON.parse(filterString);
let filterposition = IndicatorFilterUtils.filterIndexOf(filter,queries["query"]["filters"])
let filterposition = IndicatorFilterUtils.filterIndexOf(filter, queries["query"]["filters"]);
if (filterposition) {
if (queries["query"]["filters"][filterposition.filter]['groupFilters'][filterposition.groupFilter]["values"][0] != filter['groupFilters'][0]["values"][0].replace(ChartHelper.prefix + filterType + ChartHelper.suffix, filterValue)) {
//change filter value
@ -498,6 +503,7 @@ export class IndicatorUtils {
filterApplied = true;
}
}
}
queryIndex++;
}
return { "url":JSON.stringify(newJsonObject), "filtersApplied":(filterApplied)?1:0};