From 69c7eebd544cdaad935123f8a3834fd861c18299 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Fri, 7 Apr 2023 12:37:33 +0200 Subject: [PATCH] [WIP] filter btn cox list view --- frontend/main.ts | 31 +++++++++++++++++++++++- frontend/scss/components/_btns.scss | 4 +++ templates/includes/funnel-icon.html.tera | 3 +++ templates/index.html.tera | 18 ++++++++++++-- 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 templates/includes/funnel-icon.html.tera diff --git a/frontend/main.ts b/frontend/main.ts index 890decb..d92d38c 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -4,9 +4,38 @@ import './scss/app.scss' document.addEventListener('DOMContentLoaded', function() { initSearch(); initSidebar(); + initToggle(); }); - function initSearch() { +function initToggle() { + const toggle = document.querySelector('#filterdays-js'); + + if(toggle) { + toggle.addEventListener('click', () => { + toggle.ariaPressed = (toggle.ariaPressed === 'true') ? 'false' : 'true'; + + const daysNoTrips = document.querySelectorAll('div[data-trips="0"]'); + Array.prototype.forEach.call(daysNoTrips, (day: HTMLElement) => { + day.classList.toggle('hidden'); + }); + }); + } + + const coxToggle = document.querySelector('#filtertrips-js'); + + if(coxToggle) { + coxToggle.addEventListener('click', () => { + coxToggle.ariaPressed = (coxToggle.ariaPressed === 'true') ? 'false' : 'true'; + + const noCoxNeeded = document.querySelectorAll('div[data-coxneeded="false"]'); + Array.prototype.forEach.call(noCoxNeeded, (notNeeded: HTMLElement) => { + notNeeded.classList.toggle('hidden'); + }); + }); + } +} + +function initSearch() { const input = document.querySelector('#filter-js'); if(input) { diff --git a/frontend/scss/components/_btns.scss b/frontend/scss/components/_btns.scss index c696504..7bc54bd 100644 --- a/frontend/scss/components/_btns.scss +++ b/frontend/scss/components/_btns.scss @@ -20,4 +20,8 @@ &-fw { @apply w-28; } + + &[aria-pressed='true'] { + @apply outline outline-2 outline-offset-2 outline-primary-600; + } } diff --git a/templates/includes/funnel-icon.html.tera b/templates/includes/funnel-icon.html.tera new file mode 100644 index 0000000..2bbab68 --- /dev/null +++ b/templates/includes/funnel-icon.html.tera @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/templates/index.html.tera b/templates/index.html.tera index fa224c8..fc02ebf 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -10,8 +10,22 @@

Ausfahrten

+ {% if loggedin_user.is_cox %} +
+ + +
+ {% endif %} + {% for day in days %} -
+ {% set amount_trips = day.planned_events | length + day.trips | length %} +

{{ day.day| date(format="%d.%m.%Y") }}

@@ -122,7 +136,7 @@ {% if day.trips | length > 0 %}
{% for trip in day.trips %} -
+
{{ trip.planned_starting_time }} Uhr