Fix logic of creation of empty() sections
@@ -299,31 +299,41 @@ const makeFilterSerializer = ({
const { statusValues, categoryValues } = filters;
const toolStatusValues = allStatusValues[tool][columnId];
const toolCategoryValues = allCategoryValues[tool][columnId];
- const hasStatusFilter =
- statusValues && statusValues.length !== toolStatusValues.length;
- const hasCategoryFilter =
- categoryValues && categoryValues.length !== toolCategoryValues.length;
+
+ const hasStatusFilter = !!statusValues;
+ const hasStatusUnchecked =
+ hasStatusFilter && statusValues.length !== toolStatusValues.length;
+
+ const hasCategoryFilter = !!categoryValues;
+ const hasCategoryUnchecked =
+ hasCategoryFilter &&
+ categoryValues.length !== toolCategoryValues.length;
+
if (hasStatusFilter) {
+ if (hasStatusUnchecked) {
const encodedFilter = createDistinctValueFilters(
statusValues,
toolStatusValues,
);
statusColumnFilter.push(`status(${encodedFilter})`);
+ }
if (!hasCategoryFilter) {
statusColumnFilter.push("category(empty())");
}
}
if (hasCategoryFilter) {
+ if (!hasStatusFilter) {
+ statusColumnFilter.push("status(empty())");
+ }
+ if (hasCategoryUnchecked) {
const encodedFilter = createDistinctValueFilters(
categoryValues,
toolCategoryValues,
true,
);
- if (!hasStatusFilter) {
- statusColumnFilter.push("status(empty())");
- }
statusColumnFilter.push(`category(${encodedFilter})`);
}
+ }
filter = statusColumnFilter.join(",");
} else {
// <valueFilter>
