food diary bug fix, blocking calorie count
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{% load static %}
|
||||
{% block title %}Food · Tasknest{% endblock %}
|
||||
{% block content %}
|
||||
<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261015-quantity">
|
||||
<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261017-nutrition">
|
||||
{% include 'food/partials/diary_content.html' %}
|
||||
<script defer src="{% static 'food/quantity.js' %}?v=20261015"></script>
|
||||
<script defer src="{% static 'food/nutrient_help.js' %}?v=20261015-quantity"></script>
|
||||
|
||||
@@ -1,14 +1,41 @@
|
||||
<div id="food-nutrition-summary">
|
||||
<section class="food-card" id="food-summary"><h2>Calories</h2>{% if calorie_goal is not None and totals.calories_kcal is not None %}<p class="food-remaining">{% if calorie_remaining < 0 %}{{ calorie_remaining|floatformat:0|cut:'-' }} kcal over goal{% else %}{{ calorie_remaining|floatformat:0 }} kcal remaining{% endif %}</p><div class="food-progress" role="progressbar" aria-label="Calories eaten" aria-valuenow="{{ totals.calories_kcal|floatformat:0 }}" aria-valuemin="0" aria-valuemax="{{ calorie_goal }}"><span style="width:{{ calorie_percent }}%"></span></div><p>{{ totals.calories_kcal|floatformat:0 }} kcal eaten · Goal: {{ calorie_goal }} kcal</p>{% else %}<p class="food-remaining">{% if totals.calories_kcal is None %}Calories unknown{% else %}{{ totals.calories_kcal|floatformat:0 }} kcal eaten{% endif %}</p><p>No calorie goal. <a href="{% url 'planner:user-settings' %}">Set one in Settings</a>.</p>{% endif %}</section>
|
||||
<section class="food-macros" id="food-macro-summary" aria-label="Daily nutrition goals">{% for macro in macros %}<article class="food-card food-macro food-macro--{{ macro.color }}" aria-labelledby="food-goal-{{ macro.slug }}">
|
||||
<button class="food-help-trigger" type="button" aria-label="{% if help_language|slice:':2' == 'nl' %}Hulp bij {{ macro.guidance.title }}{% else %}About {{ macro.guidance.title }}{% endif %}" aria-expanded="false" aria-controls="food-help-{{ macro.slug }}" data-food-help-trigger><span aria-hidden="true">?</span></button>
|
||||
<div class="food-ring" {% if macro.percent is not None %}style="--progress:{{ macro.percent }}%" role="progressbar" aria-label="{{ macro.label }} progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="{{ macro.percent }}" aria-valuetext="{% if macro.incomplete %}At least {% endif %}{{ macro.eaten|floatformat:1 }} g of {{ macro.goal|floatformat:1 }} g{% if macro.incomplete %}; some food entries have unknown fibre{% endif %}"{% else %}aria-label="{{ macro.label }} progress unknown"{% endif %}><span aria-hidden="true">{% if macro.percent is not None %}{{ macro.percent }}%{% else %}—{% endif %}</span></div>
|
||||
<div><h3 id="food-goal-{{ macro.slug }}">{{ macro.label }}</h3><p>{% if macro.eaten is None %}Unknown{% elif macro.incomplete %}At least {{ macro.eaten|floatformat:1 }} g{% else %}{{ macro.eaten|floatformat:1 }} g eaten{% endif %}{% if macro.goal is not None %} · {{ macro.goal|floatformat:1 }} g goal{% endif %}</p>{% if macro.incomplete %}<p>Some entries unknown</p>{% elif macro.goal is not None %}<p>{% if macro.remaining < 0 %}{{ macro.remaining|floatformat:1|cut:'-' }} g over target{% else %}{{ macro.remaining|floatformat:1 }} g remaining{% endif %}</p>{% else %}<p>No target</p>{% endif %}</div>
|
||||
<div class="food-help-popover" id="food-help-{{ macro.slug }}" role="region" aria-labelledby="food-help-title-{{ macro.slug }}" hidden>
|
||||
<div class="food-help-heading"><h4 id="food-help-title-{{ macro.slug }}">{{ macro.guidance.title }}</h4><button type="button" class="food-help-close" data-food-help-close aria-label="{% if help_language|slice:':2' == 'nl' %}Sluiten{% else %}Close{% endif %}">×</button></div>
|
||||
<p>{{ macro.guidance.explanation }}</p><strong>{% if help_language|slice:':2' == 'nl' %}Goede bronnen:{% else %}Good sources:{% endif %}</strong>
|
||||
<ul>{% for group, foods in macro.guidance.sources %}<li><strong>{{ group }}</strong>{% if foods %}: {{ foods }}{% endif %}</li>{% endfor %}</ul>
|
||||
{% if macro.guidance.tip %}<p class="food-help-tip">{{ macro.guidance.tip }}</p>{% endif %}
|
||||
</div>
|
||||
</article>{% endfor %}</section>
|
||||
<section class="food-card" id="food-summary" aria-labelledby="food-calories-title">
|
||||
<h2 id="food-calories-title">Calories</h2>
|
||||
{% if nutrition_incomplete.calories_kcal %}
|
||||
<p class="food-remaining">{% if known_counts.calories_kcal %}At least {{ totals.calories_kcal|floatformat:0 }} kcal eaten{% else %}Known calories unavailable{% endif %}</p>
|
||||
{% else %}
|
||||
<p class="food-remaining">{{ totals.calories_kcal|floatformat:0 }} kcal eaten</p>
|
||||
{% endif %}
|
||||
{% if calorie_goal is not None %}
|
||||
<p>Goal: {{ calorie_goal }} kcal</p>
|
||||
{% if nutrition_incomplete.calories_kcal %}<p class="food-partial-note"><span class="food-warning-mark" aria-hidden="true">!</span> Remaining amount unknown until missing calories are added.</p>
|
||||
{% else %}<p>{% if calorie_remaining < 0 %}{{ calorie_remaining|floatformat:0|cut:'-' }} kcal over goal{% else %}{{ calorie_remaining|floatformat:0 }} kcal remaining{% endif %}</p>{% endif %}
|
||||
{% if known_counts.calories_kcal or not missing_entries %}<div class="food-progress" role="progressbar" aria-label="Calories eaten" aria-valuenow="{{ totals.calories_kcal|floatformat:0 }}" aria-valuemin="0" aria-valuemax="{{ calorie_goal }}" aria-valuetext="{% if nutrition_incomplete.calories_kcal %}At least {% endif %}{{ totals.calories_kcal|floatformat:0 }} kcal of {{ calorie_goal }} kcal{% if nutrition_incomplete.calories_kcal %}; total incomplete{% endif %}"><span style="width:{{ calorie_percent }}%"></span></div>{% endif %}
|
||||
{% else %}<p>No calorie goal. <a href="{% url 'planner:user-settings' %}">Set one in Settings</a>.</p>{% endif %}
|
||||
</section>
|
||||
{% if missing_entries %}
|
||||
<section class="food-card food-incomplete-warning" aria-labelledby="food-incomplete-title">
|
||||
<h2 id="food-incomplete-title"><span class="food-warning-mark" aria-hidden="true">!</span> Nutrition incomplete</h2>
|
||||
<p>Some foods have missing nutrition. The totals above and below show only known values and may be incomplete.</p>
|
||||
<details><summary>{{ missing_entries|length }} food entr{{ missing_entries|length|pluralize:'y,ies' }} to review</summary>
|
||||
<ul>{% for missing in missing_entries %}<li><a href="#food-entry-{{ missing.entry.pk }}">{{ missing.entry.product_name_snapshot }}</a>: {{ missing.nutrients }}</li>{% endfor %}</ul>
|
||||
</details>
|
||||
</section>
|
||||
{% endif %}
|
||||
<section class="food-macros" id="food-macro-summary" aria-label="Daily nutrition goals">
|
||||
{% for macro in macros %}<article class="food-card food-macro food-macro--{{ macro.color }}" aria-labelledby="food-goal-{{ macro.slug }}">
|
||||
<button class="food-help-trigger" type="button" aria-label="{% if help_language|slice:':2' == 'nl' %}Hulp bij {{ macro.guidance.title }}{% else %}About {{ macro.guidance.title }}{% endif %}" aria-expanded="false" aria-controls="food-help-{{ macro.slug }}" data-food-help-trigger><span aria-hidden="true">?</span></button>
|
||||
<div class="food-ring" {% if macro.percent is not None %}style="--progress:{{ macro.percent }}%" role="progressbar" aria-label="{{ macro.label }} progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="{{ macro.percent }}" aria-valuetext="{% if macro.incomplete %}At least {% endif %}{{ macro.eaten|floatformat:1 }} g of {{ macro.goal|floatformat:1 }} g{% if macro.incomplete %}; total incomplete{% endif %}"{% else %}aria-label="{{ macro.label }} progress unknown"{% endif %}><span aria-hidden="true">{% if macro.percent is not None %}{{ macro.percent }}%{% else %}—{% endif %}</span></div>
|
||||
<div><h3 id="food-goal-{{ macro.slug }}">{{ macro.label }}</h3>
|
||||
<p>{% if macro.eaten is None %}Known amount unavailable{% elif macro.incomplete %}At least {{ macro.eaten|floatformat:1 }} g{% else %}{{ macro.eaten|floatformat:1 }} g eaten{% endif %}{% if macro.goal is not None %} · {{ macro.goal|floatformat:1 }} g goal{% endif %}</p>
|
||||
{% if macro.incomplete %}<p><span class="food-warning-mark" aria-hidden="true">!</span> {% if macro.goal is not None %}Remaining unknown{% else %}Nutrition incomplete · No target{% endif %}</p>{% elif macro.goal is not None %}<p>{% if macro.remaining < 0 %}{{ macro.remaining|floatformat:1|cut:'-' }} g over target{% else %}{{ macro.remaining|floatformat:1 }} g remaining{% endif %}</p>{% else %}<p>No target</p>{% endif %}
|
||||
</div>
|
||||
<div class="food-help-popover" id="food-help-{{ macro.slug }}" role="region" aria-labelledby="food-help-title-{{ macro.slug }}" hidden>
|
||||
<div class="food-help-heading"><h4 id="food-help-title-{{ macro.slug }}">{{ macro.guidance.title }}</h4><button type="button" class="food-help-close" data-food-help-close aria-label="{% if help_language|slice:':2' == 'nl' %}Sluiten{% else %}Close{% endif %}">×</button></div>
|
||||
<p>{{ macro.guidance.explanation }}</p><strong>{% if help_language|slice:':2' == 'nl' %}Goede bronnen:{% else %}Good sources:{% endif %}</strong>
|
||||
<ul>{% for group, foods in macro.guidance.sources %}<li><strong>{{ group }}</strong>{% if foods %}: {{ foods }}{% endif %}</li>{% endfor %}</ul>
|
||||
{% if macro.guidance.tip %}<p class="food-help-tip">{{ macro.guidance.tip }}</p>{% endif %}
|
||||
</div>
|
||||
</article>{% endfor %}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user