Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add mobile version of calendar template

Roland Geidere04874066c6e
diff --git a/wger/manager/static/css/workout-manager-common.css b/wger/manager/static/css/workout-manager-common.css
index 0c0a0a7c2..0875dd062 100644
--- a/wger/manager/static/css/workout-manager-common.css
+++ b/wger/manager/static/css/workout-manager-common.css
@@ -344,6 +344,10 @@ table.month td{
table.month th{
text-align: center;
}
+table.month th {
+ height: 2em;
+}
+
table.month td {
height: 4em;
width: 14.2857%;
diff --git a/wger/manager/templates/mobile/navigation.html b/wger/manager/templates/mobile/navigation.html
index 173451985..eedfc2974 100644
--- a/wger/manager/templates/mobile/navigation.html
+++ b/wger/manager/templates/mobile/navigation.html
@@ -43,7 +43,7 @@
<h3>{% trans "Workouts" %}</h3>
<ul data-role="listview">
<li><a href="{% url 'wger.manager.views.workout.overview' %}" rel="nofollow">{% trans "Workouts" %}</a></li>
- <li><a href="{% url 'workout-calendar' %}" rel="nofollow">{% trans "Calendar" %}</a></li>
+ <li><a href="{% url 'workout-calendar' %}" rel="nofollow" data-ajax="false">{% trans "Calendar" %}</a></li>
<li><a href="{% url 'schedule-overview' %}" rel="nofollow">{% trans "Workouts schedules" %}</a></li>
</ul>
</div>
diff --git a/wger/manager/templates/mobile/workout/calendar.html b/wger/manager/templates/mobile/workout/calendar.html
new file mode 100644
index 000000000..078ff82ed
--- /dev/null
+++ b/wger/manager/templates/mobile/workout/calendar.html
@@ -0,0 +1,93 @@
+{% extends "base.html" %}
+{% load url from future %}
+{% load i18n %}
+{% load staticfiles %}
+{% load wger_extras %}
+
+{% block title %}{% trans "Workout log calendar" %}{% endblock %}
+
+{% block header %}
+<script>
+$(document).ready(function() {
+ $('table.month td.filled a').click(function(e){
+ e.preventDefault();
+ $('.calendar-log-data').hide();
+ $('#' + $(this).data('log')).toggle();
+ $('html, body').animate({
+ scrollTop: $('#' + $(this).data('log')).offset().top
+ }, 500);
+ });
+ });
+</script>
+{% endblock %}
+
+{% block content %}
+{{calendar|safe}}
+
+{% for date in logs %}
+<div id="log-{{date|date:'Y-m-d'}}" class="calendar-log-data">
+ <h3>{{date}}</h3>
+
+ {% regroup logs|get_item:date by exercise as grouped_logs %}
+
+ {# TODO: what if some of the entries don't belong to a workout? #}
+ {% with tmp=grouped_logs|first %}
+ {% with first_log=tmp.list|first %}
+ <div class="ui-grid-a">
+ <div class="ui-block-a">
+ <a href="{{first_log.workout.get_absolute_url}}" data-role="button">{% trans "Workout" %}</a>
+ </div>
+ <div class="ui-block-b">
+ <a href="{% url 'workout-log' first_log.workout.id %}" data-role="button">{% trans "Log overview" %}</a>
+ </div>
+ </div>
+ {% endwith %}
+ {% endwith %}
+ <ul class="grouper-list">
+ {% for i in grouped_logs %}
+ <li>{{i.grouper}}
+ <ul>
+ {% for log in i.list %}
+ <li>{{log.reps}} × {{log.weight}}</li>
+ {% endfor %}
+ </ul>
+ </li>
+ {% endfor %}
+ </ul>
+</div>
+{% endfor %}
+{% endblock %}
+
+
+
+{% block sidebar %}
+<h3>{% trans 'Info' %}</h3>
+<p>{% blocktrans %}The coloured days in the calendar have weight logs,
+you can click on them to see the details.{% endblocktrans %}</p>
+
+<h3>{% trans 'Log' %}</h3>
+<p>
+ <a href="{% url 'workout-calendar' %}" data-role="button" data-ajax="false">
+ <img src="{% static 'images/icons/calendar.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Go to current month' %}"
+ >
+ {% trans "Go to current month" %}</a>
+</p>
+<div class="timeline-log">
+<ul data-role="listview" data-inset="true">
+{% for date in month_list %}
+ {% ifchanged date.year %}
+ <li data-role="list-divider">{{ date|date:"Y" }}</li>
+ {% endifchanged %}
+ {% if current_month = date.month and current_year = date.year %}
+ <li>{{date|date:"F"}}</li>
+ {% else %}
+ <li><a href="{% url 'workout-calendar' date.year date.month %}" data-ajax="false">{{date|date:"F"}}</a></li>
+ {% endif %}
+{% endfor %}
+</ul>
+</div>
+
+{% endblock %}
\ No newline at end of file
diff --git a/wger/manager/templates/workout/calendar.html b/wger/manager/templates/workout/calendar.html
index 36cb11247..3b3de07cb 100644
--- a/wger/manager/templates/workout/calendar.html
+++ b/wger/manager/templates/workout/calendar.html
@@ -9,7 +9,7 @@
{% block header %}
<script>
$(document).ready(function() {
- $('.filled a').click(function(e){
+ $('table.month td.filled a').click(function(e){
e.preventDefault();
$('.calendar-log-data').hide();
$('#' + $(this).data('log')).toggle();
@@ -47,7 +47,6 @@ $(document).ready(function() {
</li>
{% endfor %}
</ul>
-
</div>
{% endfor %}
{% endblock %}
@@ -57,8 +56,7 @@ $(document).ready(function() {
{% block sidebar %}
<h3>{% trans 'Info' %}</h3>
<p>{% blocktrans %}The coloured days in the calendar have weight logs,
-you can click on them to see the details. Click on an empty day to
-add a log.{% endblocktrans %}</p>
+you can click on them to see the details.{% endblocktrans %}</p>
<h3>{% trans 'Log' %}</h3>
<p>