From 8dbc39a317e764506d66d29e7facda77906ecf63 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 3 Nov 2025 10:34:07 +0000 Subject: [PATCH] Refactor filter bar implementation for consistency and improved usability across case and question views --- atlas/templates/atlas/case_view.html | 14 +- .../generic/partials/filter_bar.html | 165 ++++++++++++++++++ templates/question_table_view.html | 165 +----------------- 3 files changed, 168 insertions(+), 176 deletions(-) create mode 100644 generic/templates/generic/partials/filter_bar.html diff --git a/atlas/templates/atlas/case_view.html b/atlas/templates/atlas/case_view.html index 0666e2c0..73faf58b 100755 --- a/atlas/templates/atlas/case_view.html +++ b/atlas/templates/atlas/case_view.html @@ -10,18 +10,7 @@

Cases

Quick filters:
Show my cases only, all cases -
- -

Filter

-
-
-
- {{ filter.form }} - -
-
- View my cases. -
+ View my cases.
@@ -81,6 +70,7 @@ {% include "generic/partials/page_size_form.html" %} + {% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %}
{% endblock %} diff --git a/generic/templates/generic/partials/filter_bar.html b/generic/templates/generic/partials/filter_bar.html new file mode 100644 index 00000000..ae66af45 --- /dev/null +++ b/generic/templates/generic/partials/filter_bar.html @@ -0,0 +1,165 @@ + +
+
+ + {# show active filters count if available via GET params #} + {% comment %} Compute active filters count (excluding 'page') using supported template tags {% endcomment %} + {% with request.GET|length as param_count %} + {% if param_count > 0 %} + {% if request.GET.page %} + {% with param_count|add:"-1" as active_count %} + {# active_count may be a string; only show badge when not zero #} + {% if active_count != "0" %} + {{ active_count }} + {% endif %} + {% endwith %} + {% else %} + {{ param_count }} + {% endif %} + {% endif %} + {% endwith %} +
+
+ + + +
+
+
+
+
Filters
+
+ +
+
+ + +
+
+
+ {% for field in filter.form.visible_fields %} +
+
+
+ {{ field.label_tag }} +
+
+ {{ field }} +
+ {% if field.errors %} +
{{ field.errors|striptags }}
+ {% endif %} + {% if field.help_text %} +
{{ field.help_text }}
+ {% endif %} +
+
+ {% endfor %} +
+
+ +  Reset + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/templates/question_table_view.html b/templates/question_table_view.html index b93c85cd..e6f9dd36 100644 --- a/templates/question_table_view.html +++ b/templates/question_table_view.html @@ -37,172 +37,9 @@ +{% include "generic/partials/filter_bar.html" with filter=filter app_name=app_name collapse_id="bottom-filter-body" %} -
-
- - {# show active filters count if available via GET params #} - {% comment %} Compute active filters count (excluding 'page') using supported template tags {% endcomment %} - {% with request.GET|length as param_count %} - {% if param_count > 0 %} - {% if request.GET.page %} - {% with param_count|add:"-1" as active_count %} - {# active_count may be a string; only show badge when not zero #} - {% if active_count != "0" %} - {{ active_count }} - {% endif %} - {% endwith %} - {% else %} - {{ param_count }} - {% endif %} - {% endif %} - {% endwith %} -
-
- - - -
-
-
-
-
Filters
-
- -
-
- - -
-
-
- {% for field in filter.form.visible_fields %} -
-
-
- {{ field.label_tag }} -
-
- {{ field }} -
- {% if field.errors %} -
{{ field.errors|striptags }}
- {% endif %} - {% if field.help_text %} -
{{ field.help_text }}
- {% endif %} -
-
- {% endfor %} -
-
- -  Reset - -
-
-
-
-
-
- - - {% endblock %} {% block js %}