Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Group weight/reps entries together, this takes less horizontal space

Roland Geider584e6707e17d
diff --git a/manager/static/css/workout-manager.css b/manager/static/css/workout-manager.css
index eefea9e4e..6bb8a147e 100644
--- a/manager/static/css/workout-manager.css
+++ b/manager/static/css/workout-manager.css
@@ -213,13 +213,23 @@ circle{
color: black;
}
+
+/*
+ * Workout log entry page needs the horizontal space
+ */
.workout-log-table .narrow-input
{
width: 3em;
+
}
.ym-form .workout-log-table div.ym-fbox-text{
- padding: 0em 0.3em;
+ padding: 0em;
+}
+
+.ym-form .workout-log-table td{
+ padding-left: 0em;
+ padding-right: 0em;
}
diff --git a/manager/templates/day/log.html b/manager/templates/day/log.html
index 7a6253399..6e29349e7 100644
--- a/manager/templates/day/log.html
+++ b/manager/templates/day/log.html
@@ -9,7 +9,7 @@
{% if language.short_name == 'de' %}
<script src="{% static 'js/jquery.ui.datepicker-de.js' %}"></script>
{% endif %}
-<script type="text/javascript" charset="utf-8">
+<script type="text/javascript">
$(document).ready(function () {
$( "#id_date" ).datepicker();
});
@@ -20,7 +20,7 @@ $(document).ready(function () {
{% block content %}
<h2>{% trans "New weight log" %} – {{day.description}}</h2>
-<form action="{{form_action}}" method="POST" class="ym-form">
+<form action="{{form_action}}" method="POST" class="ym-form" style="overflow-x: auto;">
{% csrf_token %}
{{formset.management_form}}
@@ -29,7 +29,7 @@ $(document).ready(function () {
<td>
{{dateform.date.label}}
</td>
- <td colspan="{{max_sets}}">
+ <td >
<div class= "ym-fbox-text {% if dateform.date.errors %}ym-error{% endif %}">
{{dateform.date}}
</div>
@@ -43,19 +43,18 @@ $(document).ready(function () {
<h3>{% trans "Exercises" %}</h3>
<table class="workout-log-table">
-<tr>
{% for key, value in exercises.items %}
<tr>
- <td style="width:25%;">
+ <td style="max-width: 5em; padding-right:0.4em;">
{{value.obj.name}}
</td>
- {% for form in value.forms %}
- <td>
+ {% for form in value.forms %}
+ <td class="narrow-input">
<div class= "ym-fbox-text narrow-input {% if form.reps.errors %}ym-error{% endif %}">
{{form.reps}}
</div>
- <div class="ym-fbox-text {% if form.reps.errors %}ym-error{% endif %}">
+ <div class="ym-fbox-text narrow-input {% if form.reps.errors %}ym-error{% endif %}">
<span class="ym-message">{% trans "Reps" %}</span>
</div>
</td>
@@ -64,13 +63,16 @@ $(document).ready(function () {
{{form.weight}}
</div>
- <div class="ym-fbox-text {% if form.weight.errors %}ym-error{% endif %}">
+ <div class="ym-fbox-text narrow-input {% if form.weight.errors %}ym-error{% endif %}" >
<span class="ym-message">kg.</span>
</div>
</td>
{% endfor %}
+
</tr>
{% empty %}
+<tr>
+ <td>
<div class="box warning" id="weight-box-warning">
{% trans "Add exercises to this training day before adding a log." %}
@@ -79,11 +81,15 @@ $(document).ready(function () {
</a>
</div>
+ </td>
+</tr>
{% endfor %}
+</table>
+<table>
<tr>
- <td colspan="{{max_sets}}">
- <input type="submit" value="{% trans 'Save' %}" id="form-save">
+ <td style="text-align:center;">
+ <input type="submit" value="{% trans 'Save' %}" id="form-save" style="width: 95%;">
</td>
</tr>
</table>
diff --git a/manager/views.py b/manager/views.py
index 42e0d3355..542c2034f 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -980,7 +980,6 @@ def workout_log_add(request, pk):
# exercise: the entries for weight and repetitions have no indicator to which
# exercise they belong besides the form-ID, from Django's formset
counter = 0
- max_sets = 0
total_sets = 0
exercise_list = {}
form_to_exercise = {}
@@ -990,10 +989,6 @@ def workout_log_add(request, pk):
# Maximum possible values
total_sets = total_sets + int(exercise_set.sets)
-
- # Needed to calculate the colspan in the template
- if total_sets > max_sets:
- max_sets = total_sets
counter_before = counter
counter = counter + int(exercise_set.sets) - 1
form_id_range = range(counter_before, counter +1)
@@ -1062,7 +1057,6 @@ def workout_log_add(request, pk):
exercise_list[exercise]['forms'] = formset[form_id_from:form_id_to +1]
template_data['day'] = day
- template_data['max_sets'] = max_sets
template_data['exercises'] = exercise_list
template_data['formset'] = formset
template_data['dateform'] = dateform