Clean up card content when no data is in the database.

This commit is contained in:
Christopher Charbonneau Wells 2017-10-27 20:12:39 -04:00
parent 28c2238423
commit 6ce6599b39
15 changed files with 82 additions and 49 deletions

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %}
</div>
<div class="card-body text-danger">
<h4 class="card-title">{% block title %}{% endblock %}</h4>
<span class="card-title h4"><strong>{% block title %}{% endblock %}</strong></span>
<div class="card-text text-muted">{% block content %}{% endblock %}</div>
</div>
</div>

View File

@ -2,8 +2,15 @@
{% block header %}Last Diaper Change{% endblock %}
{% block title %}
<strong>{{ change.time|timesince }}</strong> ago
{% if change %}
<strong>{{ change.time|timesince }}</strong> ago
{% else %}
Never
{% endif %}
{% endblock %}
{% block content %}{{ change.attributes|join:', ' }}{% endblock %}
{% block content %}
{% if change %}{{ change.attributes|join:', ' }}{% endif %}
{% endblock %}

View File

@ -1,36 +1,38 @@
{% extends 'cards/diaperchange.html' %}
{% block header %}Diaper Change Types{% endblock %}
{% block header %}Diaper Changes{% endblock %}
{% block title %}
<strong>Past Week</strong>
Past Week
{% endblock %}
{% block content %}
{% for key, info in stats.items %}
<div class="progress mt-3">
{% if info.wet > 0 or info.solid > 0 %}
<div class="progress mt-3">
{% if info.wet_pct > 0 %}
<div class="progress-bar bg-primary lead"
role="progressbar"
style="width: {{ info.wet_pct }}%;">{{ info.wet }}&nbsp;wet</div>
{% endif %}
{% if info.wet_pct > 0 %}
<div class="progress-bar bg-primary lead"
role="progressbar"
style="width: {{ info.wet_pct }}%;">{{ info.wet }}&nbsp;wet</div>
{% endif %}
{% if info.solid_pct > 0 %}
<div class="progress-bar bg-secondary lead"
role="progressbar"
style="width: {{ info.solid_pct }}%;">
<strong>{{ info.solid }}</strong>&nbsp;solid</div>
{% endif %}
</div>
<div class="text-center text-light small">
{% if key == 0 %}
today
{% elif key == 1 %}
yesterday
{% else %}
{{ key }} days ago
{% endif %}
</div>
{% if info.solid_pct > 0 %}
<div class="progress-bar bg-secondary lead"
role="progressbar"
style="width: {{ info.solid_pct }}%;">
<strong>{{ info.solid }}</strong>&nbsp;solid</div>
{% endif %}
</div>
<div class="text-center text-light small">
{% if key == 0 %}
today
{% elif key == 1 %}
yesterday
{% else %}
{{ key }} days ago
{% endif %}
</div>
{% endif %}
{% endfor %}
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %}
</div>
<div class="card-body text-primary">
<h4 class="card-title">{% block title %}{% endblock %}</h4>
<span class="card-title h4"><strong>{% block title %}{% endblock %}</strong></span>
<div class="card-text text-muted">{% block content %}{% endblock %}</div>
</div>
</div>

View File

@ -3,12 +3,18 @@
{% block header %}Last Feeding{% endblock %}
{% block title %}
<strong>{{ feeding.end|timesince }}</strong> ago
{% if feeding %}
{{ feeding.end|timesince }} ago
{% else %}
Never
{% endif %}
{% endblock %}
{% block content %}
{{ feeding.type }}, {{ feeding.method }}
{% if feeding.amount %}
, {{ feeding.amount }}oz.
{% if feeding %}
{{ feeding.type }}, {{ feeding.method }}
{% if feeding.amount %}
, {{ feeding.amount }}oz.
{% endif %}
{% endif %}
{% endblock %}

View File

@ -3,5 +3,9 @@
{% block header %}Last Feeding Method{% endblock %}
{% block title %}
<div class="display-4 text-center">{{ feeding.method }}</div>
{% if feeding %}
<div class="display-4 text-center">{{ feeding.method }}</div>
{% else %}
None
{% endif %}
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %}
</div>
<div class="card-body">
<h4 class="card-title">{% block title %}{% endblock %}</h4>
<span class="card-title h4"><strong>{% block title %}{% endblock %}</strong></span>
<div class="card-text text-muted">{% block content %}{% endblock %}</div>
</div>
</div>

View File

@ -13,4 +13,6 @@
{% endif %}
{% endblock %}
{% block content %}{{ count }} sleep entries{% endblock %}
{% block content %}
{% if count > 0 %}{{ count }} sleep entries{% endif %}
{% endblock %}

View File

@ -4,7 +4,11 @@
{% block header %}Last Slept{% endblock %}
{% block title %}
<strong>{{ sleep.end|timesince }}</strong> ago
{% if sleep %}
{{ sleep.end|timesince }} ago
{% else %}
Never
{% endif %}
{% endblock %}
{% block content %}{{ sleep.duration|duration_string }}{% endblock %}

View File

@ -14,5 +14,5 @@
{% endblock %}
{% block content %}
{{ total.duration__sum|duration_string }} <br/>
{% if total.duration__sum %}{{ total.duration__sum|duration_string }}{% endif %}
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %}
</div>
<div class="card-body text-light">
<h4 class="card-title">{% block title %}{% endblock %}</h4>
<span class="card-title h4"><strong>{% block title %}{% endblock %}</strong></span>
<div class="card-text">{% block content %}{% endblock %}</div>
</div>
{% block listgroup %}{% endblock %}

View File

@ -4,7 +4,7 @@
{% block title %}
{% with instances|length as count %}
<strong>{{ count }}</strong> active timer{{ count|pluralize }}
{{ count }} active timer{{ count|pluralize }}
{% endwith %}
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %}
</div>
<div class="card-body text-success">
<h4 class="card-title">{% block title %}{% endblock %}</h4>
<span class="card-title h4"><strong>{% block title %}{% endblock %}</strong></span>
<div class="card-text text-muted">{% block content %}{% endblock %}</div>
</div>
{% block listgroup %}{% endblock %}

View File

@ -4,11 +4,13 @@
{% block header %}Today's Tummy Time{% endblock %}
{% block title %}
<strong>{{ stats.total|duration_string }}</strong>
{% endblock %}
{% block content %}
{{ stats.count }} total entries
{% if stats.count > 0 %}
{{ stats.total|duration_string }}
{% else %}
<i class="icon icon-sad" aria-hidden="true"></i>
<strong>None yet today</strong>
<i class="icon icon-sad" aria-hidden="true"></i>
{% endif %}
{% endblock %}
{% block listgroup %}

View File

@ -4,12 +4,18 @@
{% block header %}Last Tummy Time{% endblock %}
{% block title %}
<strong>{{ tummytime.end|timesince }}</strong> ago
{% if tummytime %}
<strong>{{ tummytime.time|timesince }}</strong> ago
{% else %}
Never
{% endif %}
{% endblock %}
{% block content %}
{{ tummytime.duration|duration_string }}
{% if tummytime.milestone %}
<br /> {{ tummytime.milestone }}
{% if tummytime %}
{{ tummytime.duration|duration_string }}
{% if tummytime.milestone %}
<br /> {{ tummytime.milestone }}
{% endif %}
{% endif %}
{% endblock %}