From 948dbb6c11f217400cd3842dc13974dc23f121b2 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 28 Jul 2022 20:13:25 +0200 Subject: add chevron buttons to collapse year/month summary --- fietsboek/static/fietsboek.js | 21 +++++++++++++++++++++ fietsboek/static/theme.css | 4 ++++ fietsboek/templates/home.jinja2 | 8 ++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/fietsboek/static/fietsboek.js b/fietsboek/static/fietsboek.js index 265032e..f99a531 100644 --- a/fietsboek/static/fietsboek.js +++ b/fietsboek/static/fietsboek.js @@ -271,6 +271,27 @@ function saveImageDescriptionClicked(event) { addHandler("#imageDescriptionModal button.btn-success", "click", saveImageDescriptionClicked); +/** + * Handler to toggle (collapse/expand) the yearly/monthly summary. + * + * @param event - The triggering event. + */ +function toggleSummary(event) { + const chevron = event.target; + const containing = chevron.closest("a"); + const summary = containing.nextElementSibling; + bootstrap.Collapse.getOrCreateInstance(summary).toggle(); + if (chevron.classList.contains("bi-chevron-down")) { + chevron.classList.remove("bi-chevron-down"); + chevron.classList.add("bi-chevron-right"); + } else { + chevron.classList.remove("bi-chevron-right"); + chevron.classList.add("bi-chevron-down"); + } +} + +addHandler(".summary-toggler", "click", toggleSummary); + /* * Handler to enable the "Download archive button" ... */ diff --git a/fietsboek/static/theme.css b/fietsboek/static/theme.css index 01ee06e..3f7f74d 100644 --- a/fietsboek/static/theme.css +++ b/fietsboek/static/theme.css @@ -81,6 +81,10 @@ strong { max-width: 100%; } +.summary-toggler { + cursor: pointer; +} + .admin-badge-list * { margin-left: 5px; margin-right: 5px; diff --git a/fietsboek/templates/home.jinja2 b/fietsboek/templates/home.jinja2 index 6825c62..4a9c3ad 100644 --- a/fietsboek/templates/home.jinja2 +++ b/fietsboek/templates/home.jinja2 @@ -6,11 +6,11 @@ {% if summary %}
{% for year in summary %} - {{ year.year }} — {{ (year.total_length / 1000) | round(2) | format_decimal }} km -