on ajoute un bouton de réinitialisation des filtres
This commit is contained in:
parent
f1c6917f30
commit
6b5176893a
@ -1,6 +1,3 @@
|
|||||||
const isOpenClass = "modal-is-open";
|
|
||||||
const openingClass = "modal-is-opening";
|
|
||||||
const closingClass = "modal-is-closing";
|
|
||||||
let visibleModal = null;
|
let visibleModal = null;
|
||||||
|
|
||||||
// Toggle modal
|
// Toggle modal
|
||||||
|
@ -244,6 +244,7 @@ article#filters {
|
|||||||
.buttons-filter {
|
.buttons-filter {
|
||||||
float: right;
|
float: right;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
form>label {
|
form>label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@ -272,3 +273,8 @@ article#filters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
@ -18,10 +18,13 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<section>
|
<section>
|
||||||
<form method="get" class="form django-form">
|
<form method="get" class="form django-form">
|
||||||
{% csrf_token %}<br />
|
|
||||||
{{ filter.form }}<br />
|
{{ filter.form }}<br />
|
||||||
<button type="submit">Appliquer le filtre</button><br />
|
<button type="submit">Appliquer le filtre</button><br />
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
</details>
|
</details>
|
||||||
|
{% if filter.is_active %}
|
||||||
|
<a href="{{ filter.get_url_without_filters }}" role="button">Supprimer le filtre</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
{% load cat_extra %}
|
{% load cat_extra %}
|
||||||
<div class="buttons-filter">
|
<div class="buttons-filter" data-target="{{ widget.attrs.id }}">
|
||||||
<label for="switch-categories">
|
|
||||||
filtrer par catégorie
|
|
||||||
<input type="checkbox" id="switch-categories" name="switch-categories" role="switch">
|
|
||||||
</label>
|
|
||||||
<label for="all-categories">
|
<label for="all-categories">
|
||||||
toutes
|
toutes
|
||||||
<input type="checkbox" id="all-categories" name="all-categories" checked>
|
<input class="all-elements" type="checkbox" id="all-categories" name="all-categories" onChange="toggleSelectAllFilterElements(event)">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="options-filter" id="{{ widget.attrs.id }}"{% if widget.attrs.class %} class="{{ widget.attrs.class }}"{% endif %}>{% for group, options, index in widget.optgroups %}{% if group %}
|
<div class="options-filter" id="{{ widget.attrs.id }}"{% if widget.attrs.class %} class="{{ widget.attrs.class }}"{% endif %}>{% for group, options, index in widget.optgroups %}{% if group %}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
{% load cat_extra %}
|
{% load cat_extra %}
|
||||||
<div class="buttons-filter">
|
<div class="buttons-filter" data-target="{{ widget.attrs.id }}">
|
||||||
<label for="switch-tags">
|
|
||||||
filtrer par étiquette
|
|
||||||
<input type="checkbox" id="switch-tags" name="switch-tags" role="switch">
|
|
||||||
</label>
|
|
||||||
<label for="all-tags">
|
<label for="all-tags">
|
||||||
toutes
|
toutes
|
||||||
<input type="checkbox" id="all-tags" name="all-tags" checked>
|
<input class="all-elements" type="checkbox" id="all-tags" name="all-tags" onChange="toggleSelectAllFilterElements(event)">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="options-filter" id="{{ widget.attrs.id }}"{% if widget.attrs.class %} class="{{ widget.attrs.class }}"{% endif %}>{% for group, options, index in widget.optgroups %}{% if group %}
|
<div class="options-filter" id="{{ widget.attrs.id }}"{% if widget.attrs.class %} class="{{ widget.attrs.class }}"{% endif %}>{% for group, options, index in widget.optgroups %}{% if group %}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
{% block entete_header %}
|
{% block entete_header %}
|
||||||
{% css_categories %}
|
{% css_categories %}
|
||||||
|
<script src="{% static 'js/filters.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
{% block entete_header %}
|
{% block entete_header %}
|
||||||
{% css_categories %}
|
{% css_categories %}
|
||||||
<script src="{% static 'js/modal.js' %}"></script>
|
<script src="{% static 'js/modal.js' %}"></script>
|
||||||
|
<script src="{% static 'js/filters.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
{% block entete_header %}
|
{% block entete_header %}
|
||||||
{% css_categories %}
|
{% css_categories %}
|
||||||
<script src="{% static 'js/modal.js' %}"></script>
|
<script src="{% static 'js/modal.js' %}"></script>
|
||||||
|
<script src="{% static 'js/filters.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -206,6 +206,9 @@ class EventFilter(django_filters.FilterSet):
|
|||||||
print(self.form.data)
|
print(self.form.data)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def get_url_without_filters(self):
|
||||||
|
return self.request.build_absolute_uri().split("?")[0]
|
||||||
|
|
||||||
def get_categories(self):
|
def get_categories(self):
|
||||||
return self.form.cleaned_data["category"]
|
return self.form.cleaned_data["category"]
|
||||||
|
|
||||||
@ -226,7 +229,7 @@ def month_view(request, year = None, month = None):
|
|||||||
if month is None:
|
if month is None:
|
||||||
month = now.month
|
month = now.month
|
||||||
|
|
||||||
filter = EventFilter(request.GET, queryset=Event.objects.all())
|
filter = EventFilter(request.GET, queryset=Event.objects.all(), request=request)
|
||||||
cmonth = CalendarMonth(year, month, filter)
|
cmonth = CalendarMonth(year, month, filter)
|
||||||
|
|
||||||
|
|
||||||
@ -241,7 +244,7 @@ def week_view(request, year = None, week = None):
|
|||||||
if week is None:
|
if week is None:
|
||||||
week = now.isocalendar()[1]
|
week = now.isocalendar()[1]
|
||||||
|
|
||||||
filter = EventFilter(request.GET, queryset=Event.objects.all())
|
filter = EventFilter(request.GET, queryset=Event.objects.all(), request=request)
|
||||||
cweek = CalendarWeek(year, week, filter)
|
cweek = CalendarWeek(year, week, filter)
|
||||||
|
|
||||||
context = {"year": year, "week": week, "calendar": cweek, "filter": filter }
|
context = {"year": year, "week": week, "calendar": cweek, "filter": filter }
|
||||||
@ -259,7 +262,7 @@ def day_view(request, year = None, month = None, day = None):
|
|||||||
|
|
||||||
day = date(year, month, day)
|
day = date(year, month, day)
|
||||||
|
|
||||||
filter = EventFilter(request.GET, Event.objects.all())
|
filter = EventFilter(request.GET, Event.objects.all(), request=request)
|
||||||
events = filter.qs.filter((Q(start_day__lte=day) & (Q(end_day__gte=day)) | Q(start_day=day))).order_by("start_day", F("start_time").desc(nulls_last=True))
|
events = filter.qs.filter((Q(start_day__lte=day) & (Q(end_day__gte=day)) | Q(start_day=day))).order_by("start_day", F("start_time").desc(nulls_last=True))
|
||||||
|
|
||||||
context = {"day": day, "events": events, "filter": filter}
|
context = {"day": day, "events": events, "filter": filter}
|
||||||
|
Loading…
Reference in New Issue
Block a user