diff --git a/frontend/main.ts b/frontend/main.ts index d92d38c..b08912a 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -33,6 +33,30 @@ function initToggle() { }); }); } + + const monthToggle = document.querySelector('#filtermonth-js'); + const months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; + + if(monthToggle) { + monthToggle.addEventListener('click', () => { + monthToggle.ariaPressed = (monthToggle.ariaPressed === 'true') ? 'false' : 'true'; + const currentMonth = monthToggle.dataset.month; + + if(currentMonth) { + const index = months.indexOf(currentMonth); + if (index > -1) { // only splice array when item is found + months.splice(index, 1); // 2nd parameter means remove one item only + } + + Array.prototype.forEach.call(months, (month: HTMLElement) => { + const notThisMonth = document.querySelectorAll('div[data-month="' + month + '"]'); + Array.prototype.forEach.call(notThisMonth, (notThisMonth: HTMLElement) => { + notThisMonth.classList.toggle('hidden'); + }); + }); + } + }); + } } function initSearch() { diff --git a/frontend/scss/components/_btns.scss b/frontend/scss/components/_btns.scss index 7bc54bd..f05a25c 100644 --- a/frontend/scss/components/_btns.scss +++ b/frontend/scss/components/_btns.scss @@ -22,6 +22,6 @@ } &[aria-pressed='true'] { - @apply outline outline-2 outline-offset-2 outline-primary-600; + @apply outline outline-2 outline-offset-2 outline-primary-600 bg-primary-100 text-primary-950; } } diff --git a/templates/index.html.tera b/templates/index.html.tera index ff243e1..5021283 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -11,7 +11,7 @@

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") }} {{ day.day | date(format="%A", locale="de_AT") }}