From e4cf5149f5cc167078f4391c7fef42738e4eb543 Mon Sep 17 00:00:00 2001 From: MusikAnimal Date: Sun, 14 Jan 2024 23:20:01 -0500 Subject: [PATCH] EditCounter: add CSV to download formats for the timecard Fix wikitext output Bug: T346608 --- templates/editCounter/timecard.csv.twig | 12 ++++++++++++ templates/editCounter/timecard.html.twig | 2 +- templates/editCounter/timecard.wikitext.twig | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 templates/editCounter/timecard.csv.twig diff --git a/templates/editCounter/timecard.csv.twig b/templates/editCounter/timecard.csv.twig new file mode 100644 index 000000000..bb9ff77f1 --- /dev/null +++ b/templates/editCounter/timecard.csv.twig @@ -0,0 +1,12 @@ +{% set days = { + 1: msg('sunday'), + 2: msg('monday'), + 3: msg('tuesday'), + 4: msg('wednesday'), + 5: msg('thursday'), + 6: msg('friday'), + 7: msg('saturday') +}%},{% for period in 0..23 %}{{ period }}:00{% if not(loop.last) %},{% endif %}{% endfor %} +{% for day in 1..7 %} + +{{ days[day] }},{% for item in ec.timeCard|filter(item => item.day_of_week == day and item.hour != 24) %}{{ item.value }}{% if not(loop.last) %},{% endif %}{% endfor %}{% endfor %} diff --git a/templates/editCounter/timecard.html.twig b/templates/editCounter/timecard.html.twig index eb6d8e980..3edf71efd 100644 --- a/templates/editCounter/timecard.html.twig +++ b/templates/editCounter/timecard.html.twig @@ -3,7 +3,7 @@ {% import 'macros/layout.html.twig' as layout %} {% block downloadLink %} - {{ layout.downloadLink('EditCounterTimecard', {project:project.domain, username:user.usernameIdent}, ['wikitext'], 'UserApiTimeCard') }} + {{ layout.downloadLink('EditCounterTimecard', {project:project.domain, username:user.usernameIdent}, ['wikitext', 'csv'], 'UserApiTimeCard') }} {% endblock %} {% block ecBody %} diff --git a/templates/editCounter/timecard.wikitext.twig b/templates/editCounter/timecard.wikitext.twig index 9818bbdc3..c3474c9c1 100644 --- a/templates/editCounter/timecard.wikitext.twig +++ b/templates/editCounter/timecard.wikitext.twig @@ -23,8 +23,8 @@ {| class="wikitable" ! -{% for period in 0..11 %} -! {{ period * 2 }}:00 +{% for period in 0..23 %} +! {{ period }}:00 {% endfor %} |- {% for day in 1..7 %}