-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option for hiding empty dashboard cards (#213)
* add option for hiding empty dashboard cards * rework add option for hiding empty dashboard cards missed statistics.html * don't exit early in cards * add forms test for dashboard_hide_empty * add tests for cards * fix early exit in card_diaperchange_latest * change dependency of migration * rename migration * introduce hiding of cards in templates * linting * add context to test_card_diaperchange_last * setup MockUserRequest * add context to all cards test cases * add test for settings_dashboard_hide_empty_on * change dashboard_hide_test, but it doesn't work * add test for _user_wants_hide * fix test_user_wants_hide user object, simpliy check for data['empty'] * add test for user_wants_hide to every card * linting * fix trailing whitespace * rename user_wants_hide to hide_empty * fix hidden statistics * add user.refresh_from_db to test case, add test case for dashboard_refresh_rate * Follow redirect and correct assertion Co-authored-by: jcgoette <jcgoette@gmail.com> Co-authored-by: Benjamin Häublein <benjaminh@debian.vm.hp> Co-authored-by: Christopher C. Wells <git@chris-wells.net>
- Loading branch information
1 parent
fe56887
commit 1dca1cc
Showing
10 changed files
with
335 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.5 on 2021-01-19 23:17 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('babybuddy', '0013_auto_20210411_1241'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='settings', | ||
name='dashboard_hide_empty', | ||
field=models.BooleanField(default=False, verbose_name='Hide Empty Dashboard Cards'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
<div class="card card-dashboard card-{{ type }}"> | ||
<div class="card-header"> | ||
<i class="icon icon-{{ type }} pull-left" aria-hidden="true"></i> | ||
{% block header %}{% endblock %} | ||
{% if not empty or not hide_empty %} | ||
<div class="card card-dashboard card-{{ type }}"> | ||
<div class="card-header"> | ||
<i class="icon icon-{{ type }} pull-left" aria-hidden="true"></i> | ||
{% block header %}{% endblock %} | ||
</div> | ||
<div class="card-body"> | ||
<span class="card-title"><strong>{% block title %}{% endblock %}</strong></span> | ||
<div class="card-text"> {% block content %}{% endblock %} </div> | ||
</div> | ||
{% block listgroup %}{% endblock %} | ||
</div> | ||
<div class="card-body"> | ||
<span class="card-title"><strong>{% block title %}{% endblock %}</strong></span> | ||
<div class="card-text">{% block content %}{% endblock %}</div> | ||
</div> | ||
{% block listgroup %}{% endblock %} | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
{% load duration i18n %} | ||
|
||
<div class="card card-dashboard card-statistics"> | ||
<div class="card-header"> | ||
<i class="icon icon-graph pull-left" aria-hidden="true"></i> | ||
{% trans "Statistics" %} | ||
</div> | ||
<div class="card-body text-center"> | ||
<div id="statistics-carousel" class="carousel slide" data-interval="false"> | ||
<div class="carousel-inner"> | ||
{% for stat in stats %} | ||
<div class="carousel-item{% if forloop.counter == 1 %} active{% endif %}"> | ||
<span class="card-title"> | ||
{% if stat.stat %} | ||
{% if stat.type == 'duration' %} | ||
{{ stat.stat|duration_string:'m' }} | ||
{% elif stat.type == 'float' %} | ||
{{ stat.stat|floatformat }} | ||
{% if not empty or not hide_empty %} | ||
<div class="card card-dashboard card-statistics"> | ||
<div class="card-header"> | ||
<i class="icon icon-graph pull-left" aria-hidden="true"></i> | ||
{% trans "Statistics" %} | ||
</div> | ||
<div class="card-body text-center"> | ||
{% if stats|length > 0 %} | ||
<div id="statistics-carousel" class="carousel slide" data-interval="false"> | ||
<div class="carousel-inner"> | ||
{% for stat in stats %} | ||
<div class="carousel-item{% if forloop.counter == 1 %} active{% endif %}"> | ||
<span class="card-title"> | ||
{% if stat.stat %} | ||
{% if stat.type == 'duration' %} | ||
{{ stat.stat|duration_string:'m' }} | ||
{% elif stat.type == 'float' %} | ||
{{ stat.stat|floatformat }} | ||
{% else %} | ||
{{ stat.stat }} | ||
{% endif %} | ||
{% else %} | ||
{{ stat.stat }} | ||
<em>{% trans "Not enough data" %}</em> | ||
{% endif %} | ||
{% else %} | ||
<em>{% trans "Not enough data" %}</em> | ||
{% endif %} | ||
</span> | ||
<div class="card-text">{{ stat.title }}</div> | ||
</div> | ||
{% endfor %} | ||
</span> | ||
<div class="card-text">{{ stat.title }}</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
<a class="carousel-control-prev" href="#statistics-carousel" role="button" data-slide="prev"> | ||
<span class="carousel-control-prev-icon" aria-hidden="true"></span> | ||
<span class="sr-only">{% trans "Previous" %}</span> | ||
</a> | ||
<a class="carousel-control-next" href="#statistics-carousel" role="button" data-slide="next"> | ||
<span class="carousel-control-next-icon" aria-hidden="true"></span> | ||
<span class="sr-only">{% trans "Next" %}</span> | ||
</a> | ||
</div> | ||
<a class="carousel-control-prev" href="#statistics-carousel" role="button" data-slide="prev"> | ||
<span class="carousel-control-prev-icon" aria-hidden="true"></span> | ||
<span class="sr-only">{% trans "Previous" %}</span> | ||
</a> | ||
<a class="carousel-control-next" href="#statistics-carousel" role="button" data-slide="next"> | ||
<span class="carousel-control-next-icon" aria-hidden="true"></span> | ||
<span class="sr-only">{% trans "Next" %}</span> | ||
</a> | ||
{% else %} | ||
<span class="card-title"><strong>{% trans "No data yet" %}</strong></span> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} |
Oops, something went wrong.