Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Revert and improve changeset from 4504c1fce58b

Roland Geider7a55d0ddb3dd
diff --git a/manager/static/js/workout-manager.js b/manager/static/js/workout-manager.js
index 7f85f8720..a03a08706 100644
--- a/manager/static/js/workout-manager.js
+++ b/manager/static/js/workout-manager.js
@@ -361,6 +361,12 @@ function getDate(d) {
function weight_chart(data)
{
+ // Return if there is no data to process
+ if(data == '')
+ {
+ return;
+ }
+
var minDate = getDate(data[0].x),
maxDate = getDate(data[data.length-1].x);
@@ -441,4 +447,4 @@ function weight_chart(data)
entry_id = $(this).attr('id').match(/\d+/);
scatterplot_modal_dialog(entry_id);
});
-}
\ No newline at end of file
+}
diff --git a/weight/templates/weight_overview.html b/weight/templates/weight_overview.html
index 01f18c348..8617c46eb 100644
--- a/weight/templates/weight_overview.html
+++ b/weight/templates/weight_overview.html
@@ -33,42 +33,41 @@ $(document).ready(function () {
var date_min = $("#weight_filter_from").val();
var date_max = $("#weight_filter_to").val();
var filter_data = {}
- if( date_min && date_max)
+ if( date_min && date_max)
{
filter_data = {'date_min': date_min,
'date_max': date_max}
+ }
- $.getJSON("/weight/api/get_weight_data/", filter_data, function(json) {
- weight_chart(json);
- });
+ $.getJSON("/weight/api/get_weight_data/", filter_data, function(json) {
+ weight_chart(json);
+ });
- // Add datepickers to the filter elements
+ // Add datepickers to the filter elements
+
+ $("#weight_filter_from").datepicker({ dateFormat: "yy-mm-dd",
+ {% if min_date %}minDate: {{ min_date }}{% endif %}
+ });
+ $("#weight_filter_to").datepicker({ dateFormat: "yy-mm-dd",
+ {% if max_date %}maxDate: {{max_date}}{% endif %}
+ });
+
+ // Process the filter
+ $("#weight_diagram_refresh").click(function(e) {
- $("#weight_filter_from").datepicker({ dateFormat: "yy-mm-dd",
- {% if min_date %}minDate: {{ min_date }}{% endif %}
- });
- $("#weight_filter_to").datepicker({ dateFormat: "yy-mm-dd",
- {% if max_date %}maxDate: {{max_date}}{% endif %}
- });
+ e.preventDefault();
- // Process the filter
- $("#weight_diagram_refresh").click(function(e) {
-
- e.preventDefault();
-
- var date_min = $("#weight_filter_from").val();
- var date_max = $("#weight_filter_to").val();
-
- $.getJSON("/weight/api/get_weight_data/",
- {'date_min': date_min,
- 'date_max': date_max},
- function(json) {
- weight_chart(json);
- });
-
-
- });
- }
+ var date_min = $("#weight_filter_from").val();
+ var date_max = $("#weight_filter_to").val();
+
+ $.getJSON("/weight/api/get_weight_data/",
+ {'date_min': date_min,
+ 'date_max': date_max},
+ function(json) {
+ weight_chart(json);
+ });
+ });
+
// Init the modal dialog
form_modal_dialog();