on ajoute un bouton de réinitialisation des filtres
This commit is contained in:
		@@ -1,6 +1,3 @@
 | 
			
		||||
const isOpenClass = "modal-is-open";
 | 
			
		||||
const openingClass = "modal-is-opening";
 | 
			
		||||
const closingClass = "modal-is-closing";
 | 
			
		||||
let visibleModal = null;
 | 
			
		||||
 | 
			
		||||
// Toggle modal
 | 
			
		||||
 
 | 
			
		||||
@@ -244,6 +244,7 @@ article#filters {
 | 
			
		||||
    .buttons-filter {
 | 
			
		||||
        float: right;
 | 
			
		||||
        text-align: right;
 | 
			
		||||
        display: none;
 | 
			
		||||
    }
 | 
			
		||||
    form>label {
 | 
			
		||||
        display: inline-block;
 | 
			
		||||
@@ -271,4 +272,9 @@ article#filters {
 | 
			
		||||
            margin-left: 0.3em;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.disabled {
 | 
			
		||||
    pointer-events: none;
 | 
			
		||||
    opacity: 0.4;
 | 
			
		||||
}
 | 
			
		||||
@@ -18,10 +18,13 @@
 | 
			
		||||
</summary>
 | 
			
		||||
<section>
 | 
			
		||||
<form method="get" class="form django-form">
 | 
			
		||||
                {% csrf_token %}<br />
 | 
			
		||||
                {{ filter.form }}<br />
 | 
			
		||||
                <button type="submit">Appliquer le filtre</button><br />
 | 
			
		||||
</form>
 | 
			
		||||
</section>
 | 
			
		||||
</details>
 | 
			
		||||
{% if filter.is_active %}
 | 
			
		||||
<a href="{{ filter.get_url_without_filters }}" role="button">Supprimer le filtre</a>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
</article>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,8 @@
 | 
			
		||||
{% load cat_extra %}
 | 
			
		||||
<div class="buttons-filter">
 | 
			
		||||
    <label for="switch-categories">
 | 
			
		||||
        filtrer par catégorie
 | 
			
		||||
        <input type="checkbox" id="switch-categories" name="switch-categories" role="switch">
 | 
			
		||||
      </label>
 | 
			
		||||
<div class="buttons-filter" data-target="{{ widget.attrs.id }}">
 | 
			
		||||
      <label for="all-categories">
 | 
			
		||||
        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>
 | 
			
		||||
</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 %}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,8 @@
 | 
			
		||||
{% load cat_extra %}
 | 
			
		||||
<div class="buttons-filter">
 | 
			
		||||
<label for="switch-tags">
 | 
			
		||||
    filtrer par étiquette
 | 
			
		||||
    <input type="checkbox" id="switch-tags" name="switch-tags" role="switch">
 | 
			
		||||
  </label>
 | 
			
		||||
<div class="buttons-filter" data-target="{{ widget.attrs.id }}">
 | 
			
		||||
  <label for="all-tags">
 | 
			
		||||
    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>
 | 
			
		||||
</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 %}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@
 | 
			
		||||
 | 
			
		||||
{% block entete_header %}
 | 
			
		||||
    {% css_categories %}
 | 
			
		||||
    <script src="{% static 'js/filters.js' %}"></script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block title %}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
{% block entete_header %}
 | 
			
		||||
    {% css_categories %}
 | 
			
		||||
    <script src="{% static 'js/modal.js' %}"></script>
 | 
			
		||||
    <script src="{% static 'js/filters.js' %}"></script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block title %}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
{% block entete_header %}
 | 
			
		||||
    {% css_categories %}
 | 
			
		||||
    <script src="{% static 'js/modal.js' %}"></script>
 | 
			
		||||
    <script src="{% static 'js/filters.js' %}"></script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block title %}
 | 
			
		||||
 
 | 
			
		||||
@@ -206,6 +206,9 @@ class EventFilter(django_filters.FilterSet):
 | 
			
		||||
            print(self.form.data)
 | 
			
		||||
            return ""
 | 
			
		||||
 | 
			
		||||
    def get_url_without_filters(self):
 | 
			
		||||
        return self.request.build_absolute_uri().split("?")[0]
 | 
			
		||||
 | 
			
		||||
    def get_categories(self):
 | 
			
		||||
        return self.form.cleaned_data["category"]
 | 
			
		||||
 | 
			
		||||
@@ -226,7 +229,7 @@ def month_view(request, year = None, month = None):
 | 
			
		||||
    if month is None:
 | 
			
		||||
        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)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
@@ -241,7 +244,7 @@ def week_view(request, year = None, week = None):
 | 
			
		||||
    if week is None:
 | 
			
		||||
        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)
 | 
			
		||||
 | 
			
		||||
    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)
 | 
			
		||||
    
 | 
			
		||||
    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))
 | 
			
		||||
 | 
			
		||||
    context = {"day": day, "events": events, "filter": filter}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user