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 %} {% block header %}{% endblock %}
</div> </div>
<div class="card-body text-danger"> <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 class="card-text text-muted">{% block content %}{% endblock %}</div>
</div> </div>
</div> </div>

View File

@ -2,8 +2,15 @@
{% block header %}Last Diaper Change{% endblock %} {% block header %}Last Diaper Change{% endblock %}
{% block title %} {% block title %}
<strong>{{ change.time|timesince }}</strong> ago {% if change %}
<strong>{{ change.time|timesince }}</strong> ago
{% else %}
Never
{% endif %}
{% endblock %} {% 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' %} {% extends 'cards/diaperchange.html' %}
{% block header %}Diaper Change Types{% endblock %} {% block header %}Diaper Changes{% endblock %}
{% block title %} {% block title %}
<strong>Past Week</strong> Past Week
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% for key, info in stats.items %} {% 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 %} {% if info.wet_pct > 0 %}
<div class="progress-bar bg-primary lead" <div class="progress-bar bg-primary lead"
role="progressbar" role="progressbar"
style="width: {{ info.wet_pct }}%;">{{ info.wet }}&nbsp;wet</div> style="width: {{ info.wet_pct }}%;">{{ info.wet }}&nbsp;wet</div>
{% endif %} {% endif %}
{% if info.solid_pct > 0 %} {% if info.solid_pct > 0 %}
<div class="progress-bar bg-secondary lead" <div class="progress-bar bg-secondary lead"
role="progressbar" role="progressbar"
style="width: {{ info.solid_pct }}%;"> style="width: {{ info.solid_pct }}%;">
<strong>{{ info.solid }}</strong>&nbsp;solid</div> <strong>{{ info.solid }}</strong>&nbsp;solid</div>
{% endif %} {% endif %}
</div> </div>
<div class="text-center text-light small"> <div class="text-center text-light small">
{% if key == 0 %} {% if key == 0 %}
today today
{% elif key == 1 %} {% elif key == 1 %}
yesterday yesterday
{% else %} {% else %}
{{ key }} days ago {{ key }} days ago
{% endif %} {% endif %}
</div> </div>
{% endif %}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %} {% block header %}{% endblock %}
</div> </div>
<div class="card-body text-primary"> <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 class="card-text text-muted">{% block content %}{% endblock %}</div>
</div> </div>
</div> </div>

View File

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

View File

@ -3,5 +3,9 @@
{% block header %}Last Feeding Method{% endblock %} {% block header %}Last Feeding Method{% endblock %}
{% block title %} {% 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 %} {% endblock %}

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %} {% block header %}{% endblock %}
</div> </div>
<div class="card-body"> <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 class="card-text text-muted">{% block content %}{% endblock %}</div>
</div> </div>
</div> </div>

View File

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

View File

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

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %} {% block header %}{% endblock %}
</div> </div>
<div class="card-body text-light"> <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 class="card-text">{% block content %}{% endblock %}</div>
</div> </div>
{% block listgroup %}{% endblock %} {% block listgroup %}{% endblock %}

View File

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

View File

@ -4,7 +4,7 @@
{% block header %}{% endblock %} {% block header %}{% endblock %}
</div> </div>
<div class="card-body text-success"> <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 class="card-text text-muted">{% block content %}{% endblock %}</div>
</div> </div>
{% block listgroup %}{% endblock %} {% block listgroup %}{% endblock %}

View File

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

View File

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