Categorical filter is now mutually exclusive

This commit is contained in:
Francesco
2023-09-30 10:29:18 +02:00
parent e72fcda5fe
commit bb3f9e7bcb
2 changed files with 39 additions and 19 deletions

View File

@@ -49,11 +49,17 @@
<!--/*--> Handle non categorical filter <!--*/-->
<th:block th:if="${!field.isFilterableCategorical()}">
<form action="" method="GET">
<!--/*--> Propagate queryParams containing other filters with hidden fields <!--*/-->
<th:block th:each="p : ${queryParams.keySet()}">
<input th:each="v : ${queryParams.get(p)}"
th:name="${p}" th:value="${v}" type="hidden"
th:if="${p.startsWith('filter_')}">
<!--/*--> Propagate query filters with hidden fields <!--*/-->
<th:block th:each="filter : ${activeFilters}">
<input type="hidden"
name="filter_field"
th:value="${filter.getField().getJavaName()}">
<input type="hidden"
name="filter_op"
th:value="${filter.getOp()}">
<input type="hidden"
name="filter_value"
th:value="${filter.getValue()}">
</th:block>
<div class="input-group pe-2">
@@ -103,11 +109,20 @@
<ul class="categorical-select">
<li th:each="categoricalValue : ${field.getConnectedSchema().findAll()}">
<form action="" method="GET">
<!--/*--> Propagate queryParams containing other filters with hidden fields <!--*/-->
<th:block th:each="p : ${queryParams.keySet()}">
<input th:each="v : ${queryParams.get(p)}"
th:name="${p}" th:value="${v}" type="hidden"
th:if="${p.startsWith('filter_')}">
<!--/*--> Propagate query filters with hidden fields <!--*/-->
<th:block th:each="filter : ${activeFilters}">
<!--/*--> This field is categorical so we don't propagate it, to make it mutually exclusive <!--*/-->
<th:block th:unless="${field.getJavaName() == filter.getField().getJavaName()}">
<input type="hidden"
name="filter_field"
th:value="${filter.getField().getJavaName()}">
<input type="hidden"
name="filter_op"
th:value="${filter.getOp()}">
<input type="hidden"
name="filter_value"
th:value="${filter.getValue()}">
</th:block>
</th:block>
<!-- Reset page when applying filter to start back at page 1 -->
@@ -130,11 +145,20 @@
<ul class="categorical-select">
<li th:each="categoricalValue : ${field.getAllValues()}">
<form action="" method="GET">
<!--/*--> Propagate queryParams containing other filters with hidden fields <!--*/-->
<th:block th:each="p : ${queryParams.keySet()}">
<input th:each="v : ${queryParams.get(p)}"
th:name="${p}" th:value="${v}" type="hidden"
th:if="${p.startsWith('filter_')}">
<!--/*--> Propagate query filters with hidden fields <!--*/-->
<th:block th:each="filter : ${activeFilters}">
<!--/*--> This field is categorical so we don't propagate it, to make it mutually exclusive <!--*/-->
<th:block th:unless="${field.getJavaName() == filter.getField().getJavaName()}">
<input type="hidden"
name="filter_field"
th:value="${filter.getField().getJavaName()}">
<input type="hidden"
name="filter_op"
th:value="${filter.getOp()}">
<input type="hidden"
name="filter_value"
th:value="${filter.getValue()}">
</th:block>
</th:block>
<!-- Reset page when applying filter to start back at page 1 -->