From 0cd989ff96c602b50156f0368e41cfc573c84e67 Mon Sep 17 00:00:00 2001 From: Jean-Louis Jouannic Date: Tue, 26 Jul 2022 17:28:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20adds=20a=20child=20quick=20switc?= =?UTF-8?q?h=20in=20breadcrumb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This quick switch is available in dashboard, timeline and reports breadcrumbs and allows to quickly switch to the "same" page but for another child --- core/templates/core/child_detail.html | 6 ++++-- core/templates/core/child_quick_switch.html | 17 +++++++++++++++++ core/templatetags/breadcrumb.py | 16 ++++++++++++++++ dashboard/templates/dashboard/child.html | 6 ++++-- reports/templates/reports/base.html | 2 -- reports/templates/reports/bmi_change.html | 1 + .../reports/breadcrumb_common_chunk.html | 7 +++++++ .../templates/reports/diaperchange_amounts.html | 1 + .../reports/diaperchange_lifetimes.html | 1 + .../templates/reports/diaperchange_types.html | 1 + reports/templates/reports/feeding_amounts.html | 1 + reports/templates/reports/feeding_duration.html | 1 + .../reports/head_circumference_change.html | 1 + reports/templates/reports/height_change.html | 1 + reports/templates/reports/pumping_amounts.html | 1 + reports/templates/reports/report_list.html | 13 +++++++++++-- reports/templates/reports/sleep_pattern.html | 1 + reports/templates/reports/sleep_totals.html | 1 + .../templates/reports/tummytime_duration.html | 1 + reports/templates/reports/weight_change.html | 1 + 20 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 core/templates/core/child_quick_switch.html create mode 100644 core/templatetags/breadcrumb.py create mode 100644 reports/templates/reports/breadcrumb_common_chunk.html diff --git a/core/templates/core/child_detail.html b/core/templates/core/child_detail.html index 4caf2885..081ae11e 100644 --- a/core/templates/core/child_detail.html +++ b/core/templates/core/child_detail.html @@ -1,11 +1,13 @@ {% extends 'babybuddy/page.html' %} -{% load duration i18n imagekit static %} +{% load breadcrumb duration i18n imagekit static %} {% block title %}{{ object }}{% endblock %} {% block breadcrumbs %} - + {% endblock %} {% block content %} diff --git a/core/templates/core/child_quick_switch.html b/core/templates/core/child_quick_switch.html new file mode 100644 index 00000000..c899c41a --- /dev/null +++ b/core/templates/core/child_quick_switch.html @@ -0,0 +1,17 @@ +{% load i18n %} + +{{ current_child }} +{% if children.count > 0 %} + + +{% endif %} diff --git a/core/templatetags/breadcrumb.py b/core/templatetags/breadcrumb.py new file mode 100644 index 00000000..37cfae74 --- /dev/null +++ b/core/templatetags/breadcrumb.py @@ -0,0 +1,16 @@ +from django import template + +from core.models import Child + +register = template.Library() + + +@register.inclusion_tag("core/child_quick_switch.html") +def child_quick_switch(current_child, target_url): + children = Child.objects.exclude(slug=current_child.slug) + + return { + "children": children, + "current_child": current_child, + "target_url": target_url, + } diff --git a/dashboard/templates/dashboard/child.html b/dashboard/templates/dashboard/child.html index 464fd47b..0c15103b 100644 --- a/dashboard/templates/dashboard/child.html +++ b/dashboard/templates/dashboard/child.html @@ -1,11 +1,13 @@ {% extends 'babybuddy/page.html' %} -{% load cards i18n %} +{% load breadcrumb cards i18n %} {% block title %}{% trans "Dashboard" %} - {{ object }}{% endblock %} {% block breadcrumbs %} - + {% endblock %} diff --git a/reports/templates/reports/base.html b/reports/templates/reports/base.html index d671dcf3..d4bcbdde 100644 --- a/reports/templates/reports/base.html +++ b/reports/templates/reports/base.html @@ -5,6 +5,4 @@ {% block breadcrumbs %} - - {% endblock %} diff --git a/reports/templates/reports/bmi_change.html b/reports/templates/reports/bmi_change.html index 49c3d36c..ea93c937 100644 --- a/reports/templates/reports/bmi_change.html +++ b/reports/templates/reports/bmi_change.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-bmi-change-child' %} {% endblock %} diff --git a/reports/templates/reports/breadcrumb_common_chunk.html b/reports/templates/reports/breadcrumb_common_chunk.html new file mode 100644 index 00000000..0c64a2fa --- /dev/null +++ b/reports/templates/reports/breadcrumb_common_chunk.html @@ -0,0 +1,7 @@ +{% load breadcrumb i18n %} + + + + diff --git a/reports/templates/reports/diaperchange_amounts.html b/reports/templates/reports/diaperchange_amounts.html index dd54a42a..5175b4a9 100644 --- a/reports/templates/reports/diaperchange_amounts.html +++ b/reports/templates/reports/diaperchange_amounts.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-diaperchange-amounts-child' %} {% endblock %} diff --git a/reports/templates/reports/diaperchange_lifetimes.html b/reports/templates/reports/diaperchange_lifetimes.html index d6616254..caeb2ac8 100644 --- a/reports/templates/reports/diaperchange_lifetimes.html +++ b/reports/templates/reports/diaperchange_lifetimes.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-diaperchange-lifetimes-child' %} {% endblock %} diff --git a/reports/templates/reports/diaperchange_types.html b/reports/templates/reports/diaperchange_types.html index 08407907..41479fb4 100644 --- a/reports/templates/reports/diaperchange_types.html +++ b/reports/templates/reports/diaperchange_types.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-diaperchange-types-child' %} {% endblock %} diff --git a/reports/templates/reports/feeding_amounts.html b/reports/templates/reports/feeding_amounts.html index 204bbde8..ab7969bd 100644 --- a/reports/templates/reports/feeding_amounts.html +++ b/reports/templates/reports/feeding_amounts.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-feeding-amounts-child' %} {% endblock %} diff --git a/reports/templates/reports/feeding_duration.html b/reports/templates/reports/feeding_duration.html index 964121ef..1d7cbdf4 100644 --- a/reports/templates/reports/feeding_duration.html +++ b/reports/templates/reports/feeding_duration.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-feeding-duration-child' %} {% endblock %} diff --git a/reports/templates/reports/head_circumference_change.html b/reports/templates/reports/head_circumference_change.html index f312c1f1..361d8e64 100644 --- a/reports/templates/reports/head_circumference_change.html +++ b/reports/templates/reports/head_circumference_change.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-head-circumference-change-child' %} {% endblock %} diff --git a/reports/templates/reports/height_change.html b/reports/templates/reports/height_change.html index 8acac582..ccc1eaae 100644 --- a/reports/templates/reports/height_change.html +++ b/reports/templates/reports/height_change.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-height-change-child' %} {% endblock %} diff --git a/reports/templates/reports/pumping_amounts.html b/reports/templates/reports/pumping_amounts.html index 7944e390..9dbbb631 100644 --- a/reports/templates/reports/pumping_amounts.html +++ b/reports/templates/reports/pumping_amounts.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-pumping-amounts-child' %} {% endblock %} diff --git a/reports/templates/reports/report_list.html b/reports/templates/reports/report_list.html index 30c10bdb..af62656e 100644 --- a/reports/templates/reports/report_list.html +++ b/reports/templates/reports/report_list.html @@ -1,8 +1,17 @@ {% extends 'reports/base.html' %} -{% load i18n static %} +{% load breadcrumb i18n static %} {% block title %}{% trans "Reports" %} - {{ object }}{% endblock %} +{% block breadcrumbs %} + {{ block.super }} + + + +{% endblock %} + {% block content %}

Reports

@@ -22,4 +31,4 @@ {% trans "Weight" %}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/reports/templates/reports/sleep_pattern.html b/reports/templates/reports/sleep_pattern.html index a650a3ce..407e97fb 100644 --- a/reports/templates/reports/sleep_pattern.html +++ b/reports/templates/reports/sleep_pattern.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-sleep-pattern-child' %} {% endblock %} diff --git a/reports/templates/reports/sleep_totals.html b/reports/templates/reports/sleep_totals.html index fe8f84cb..2ef07064 100644 --- a/reports/templates/reports/sleep_totals.html +++ b/reports/templates/reports/sleep_totals.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-sleep-totals-child' %} {% endblock %} diff --git a/reports/templates/reports/tummytime_duration.html b/reports/templates/reports/tummytime_duration.html index 9e49c872..05f63411 100644 --- a/reports/templates/reports/tummytime_duration.html +++ b/reports/templates/reports/tummytime_duration.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-tummy-time-duration-child' %} {% endblock %} diff --git a/reports/templates/reports/weight_change.html b/reports/templates/reports/weight_change.html index 3e5a1f22..9d812759 100644 --- a/reports/templates/reports/weight_change.html +++ b/reports/templates/reports/weight_change.html @@ -5,5 +5,6 @@ {% block breadcrumbs %} {{ block.super }} + {% include 'reports/breadcrumb_common_chunk.html' with target_url='reports:report-weight-change-child' %} {% endblock %}