Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add toggle button to show/hide the tables with the weight logs
Roland Geiderc7b87d11bb67
diff --git a/exercises/views.py b/exercises/views.pyindex 6d85a72d8..4c6c93cb3 100644--- a/exercises/views.py+++ b/exercises/views.py@@ -201,7 +201,7 @@ def exercise_view(request, id, comment_id=None):template_data['logs'] = entry_logtemplate_data['json'] = chart_data- template_data['svg_uuid'] = 'id-' + str(uuid.uuid4())+ template_data['svg_uuid'] = str(uuid.uuid4())# Renderreturn render_to_response('view.html',diff --git a/manager/static/js/workout-manager.js b/manager/static/js/workout-manager.jsindex c6a73b3d6..c2a3b32b1 100644--- a/manager/static/js/workout-manager.js+++ b/manager/static/js/workout-manager.js@@ -573,7 +573,7 @@ function weight_log_chart(data, div_id).x(function(d) { return x(d.date); }).y(function(d) { return y(d.weight); });- var svg = d3.select("#" + div_id).append("svg")+ var svg = d3.select("#svg-" + div_id).append("svg").attr("width", width + margin.left + margin.right).attr("height", height + margin.top + margin.bottom).append("g")@@ -658,6 +658,15 @@ function weight_log_chart(data, div_id).text(function(d) { return d.name; });}+function toggle_weight_log_table()+{+ $(".weight-chart-table-toggle").click(function(e) {+ e.preventDefault();+ target = $(this).data('toggleTarget');+ console.log(target);+ $('#' + target).toggle({effect: 'fade', duration: 600});+ });+}/**diff --git a/manager/templates/base.html b/manager/templates/base.htmlindex 036850f11..8ac312f77 100644--- a/manager/templates/base.html+++ b/manager/templates/base.html@@ -25,7 +25,7 @@--><link rel="stylesheet" type="text/css" href="{% static 'css/yaml/demos/css/flexible-grids.css' %} "> <!-- CSS framework for the layout -->- <link rel="stylesheet" type="text/css" href="{% static 'css/yaml/custom-yaml.css' %}"> <!-- Customisations for yaml -->+ <link rel="stylesheet" type="text/css" href="{% static 'css/yaml/custom-yaml.css' %}"> <!-- Customisations for yaml --><link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager.css' %}"> <!-- Own CSS classes and styles --><link rel="stylesheet" type="text/css" href="{% static 'css/jquery-ui.css' %}"> <!-- CSS for JQuery UI elements --><link rel="stylesheet" type="text/css" href="{% static 'css/jquery-ui-custom.css' %}"> <!-- Customization for JQuery CSS -->@@ -36,27 +36,30 @@<script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script><script src="{% static 'js/ubuntu-unity.js' %}" type="text/javascript"></script><script src="{% static 'js/browserid.js' %}" type="text/javascript"></script>-+{% block header %}{% endblock %}-+<script>$(document).ready(function() {-+if (typeof custom_page_init != "undefined"){custom_page_init();}--++// Init the modal dialog for editing formsform_modal_dialog();-+// Initialise the hook to reload the main-contentload_maincontent();++ // Toggle weight chart tables+ toggle_weight_log_table();});</script>--++<title>{% block title %}{% endblock %}</title></head><body>@@ -84,8 +87,8 @@<li {% if active_tab == 'weight' %}class="active"{% endif %}><a href="{% url weight.views.overview %}">{% trans "Weight" %} </a></li><li {% if active_tab == 'nutrition' %}class="active"{% endif %}><a href="{% url nutrition.views.overview %}">{% trans "Nutrition" %} </a></li></ul>--++{% if user.username %}<ul style="float:right;"><li>@@ -105,7 +108,7 @@<div class="ym-grid linearize-level-1"><article class="ym-g80 ym-gl"><div class="ym-gbox-left box invisible" id="ajax-info">-+</div></article></div>diff --git a/manager/templates/tags/render_weight_log.html b/manager/templates/tags/render_weight_log.htmlindex 6ca5b875b..a1da5a537 100644--- a/manager/templates/tags/render_weight_log.html+++ b/manager/templates/tags/render_weight_log.html@@ -5,8 +5,8 @@{% endblock %}-<div style="overflow-x: auto;">-<table class="noborder" style="border: 0 none; width: 7.5em;">+<div style="overflow-x: auto;" class="weight-chart-table">+<table class="noborder" style="border: 0 none; width: 7.5em; display:none;" id="table-{{div_uuid}}"><tr>{% for date, entry_list in log.items %}<td style="padding: 0em; border-top-width: 0px;">@@ -25,5 +25,10 @@</tr></table></div>-<div id="{{div_uuid}}"></div>++<div class="weight-chart-table-toggle" data-toggle-target="table-{{div_uuid}}">+<a href="#">{% trans "Toggle data table" %}</a>+</div>++<div id="svg-{{div_uuid}}"></div>diff --git a/manager/views.py b/manager/views.pyindex a37ef67bf..19372824e 100644--- a/manager/views.py+++ b/manager/views.py@@ -1128,7 +1128,7 @@ class WorkoutLogDetailView(DetailView):if exercise_log:workout_log[day][exercise] = {}workout_log[day][exercise]['log_by_date'] = entry_log- workout_log[day][exercise]['div_uuid'] = 'id-' + str(uuid.uuid4())+ workout_log[day][exercise]['div_uuid'] = str(uuid.uuid4())workout_log[day][exercise]['chart_data'] = chart_datalogger.debug(chart_data)