From 5d5d8b12434917fb1ecf1165bd9a40b7bd5fc787 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Tue, 11 Jan 2022 16:32:33 +0100 Subject: [PATCH] # 61 Filter frontend * finished filter frontend --- konova/filters.py | 27 ++++++++++++++++++++------- templates/filter/checkbox_filter.html | 5 +++++ templates/filter/query_filter.html | 10 ++++++++++ templates/generic_index.html | 13 +++++++++---- 4 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 templates/filter/checkbox_filter.html create mode 100644 templates/filter/query_filter.html diff --git a/konova/filters.py b/konova/filters.py index 9b3461c..0044582 100644 --- a/konova/filters.py +++ b/konova/filters.py @@ -71,7 +71,8 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet): widget=forms.TextInput( attrs={ "placeholder": _("District"), - "title": _("Search for district") + "title": _("Search for district"), + "class": "form-control", } ), ) @@ -83,7 +84,8 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet): widget=forms.TextInput( attrs={ "placeholder": _("Parcel gmrkng"), - "title": _("Search for parcel gmrkng") + "title": _("Search for parcel gmrkng"), + "class": "form-control", } ), ) @@ -95,7 +97,8 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet): widget=forms.TextInput( attrs={ "placeholder": _("Parcel"), - "title": _("Search for parcel") + "title": _("Search for parcel"), + "class": "form-control", } ), ) @@ -107,7 +110,8 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet): widget=forms.TextInput( attrs={ "placeholder": _("Parcel counter"), - "title": _("Search for parcel counter") + "title": _("Search for parcel counter"), + "class": "form-control", } ), ) @@ -120,7 +124,8 @@ class GeoReferencedTableFilterMixin(django_filters.FilterSet): widget=forms.TextInput( attrs={ "placeholder": _("Parcel number"), - "title": _("Search for parcel number") + "title": _("Search for parcel number"), + "class": "form-control", } ), ) @@ -251,7 +256,11 @@ class ShareableTableFilterMixin(django_filters.FilterSet): method='filter_show_all', label=_("Show unshared"), label_suffix=_(""), - widget=forms.CheckboxInput() + widget=forms.CheckboxInput( + attrs={ + "class": "form-check-input", + } + ) ) class Meta: @@ -291,7 +300,11 @@ class RecordableTableFilterMixin(django_filters.FilterSet): method='filter_show_recorded', label=_("Show recorded"), label_suffix=_(""), - widget=forms.CheckboxInput() + widget=forms.CheckboxInput( + attrs={ + "class": "form-check-input", + } + ) ) class Meta: diff --git a/templates/filter/checkbox_filter.html b/templates/filter/checkbox_filter.html new file mode 100644 index 0000000..9341036 --- /dev/null +++ b/templates/filter/checkbox_filter.html @@ -0,0 +1,5 @@ +{% for field in form %} +
+ {{field}} +
+{% endfor %} \ No newline at end of file diff --git a/templates/filter/query_filter.html b/templates/filter/query_filter.html new file mode 100644 index 0000000..24c867a --- /dev/null +++ b/templates/filter/query_filter.html @@ -0,0 +1,10 @@ +
+ {% for field in form %} + {% if not field.is_hidden %} +
+ {{field}} +
+ {% else %} + {% endif %} + {% endfor %} +
\ No newline at end of file diff --git a/templates/generic_index.html b/templates/generic_index.html index 66ab652..cd2c326 100644 --- a/templates/generic_index.html +++ b/templates/generic_index.html @@ -83,12 +83,17 @@
- {{table.filter.query_filter.form.as_p}} + {% with table.filter.query_filter.form as form %} + {% include 'filter/query_filter.html' %} + {% endwith %}
-
- {{table.filter.checkbox_filter.form.as_p}} +
+ {% with table.filter.checkbox_filter.form as form %} + {% include 'filter/checkbox_filter.html' %} + {% endwith %}
-
+
+