Self hosted FLOSS fitness/workout, nutrition and weight tracker
Allow the user to select options for the workout PDF
Roland Geider102d952a7adf
diff --git a/wger/core/static/js/workout-manager.js b/wger/core/static/js/workout-manager.jsindex 68f44f3e5..bd61d852f 100644--- a/wger/core/static/js/workout-manager.js+++ b/wger/core/static/js/workout-manager.js@@ -663,4 +663,32 @@ function prefetch_images(imageArray) {});}});-}\ No newline at end of file+}++/*+ * Handle the workout PDF download options+ */+$(document).ready(function() {+ $('#download-pdf-button').click(function (e) {+ e.preventDefault();++ var downloadInfo = $('#pdf-download-info');+ var downloadType = $('input[name="pdf_type"]:checked').val();+ var downloadImages = $('#id_images').is(':checked') ? 1 : 0;+ var downloadComments = $('#id_comments').is(':checked') ? 1 : 0;++ var workoutId = downloadInfo.data('workoutId');+ var uid = downloadInfo.data('uid');+ var token = downloadInfo.data('token');++ // Put together and redirect+ var targetUrl = '/' + get_current_language() ++ '/workout/' + workoutId + '/pdf' ++ '/' + downloadType ++ '/' + downloadImages ++ '/' + downloadComments ++ '/' + uid ++ '/' + token;+ window.location.href = targetUrl;+ });+});\ No newline at end of filediff --git a/wger/manager/templates/workout/view.html b/wger/manager/templates/workout/view.htmlindex fb7af4fc0..dafbaa5d9 100644--- a/wger/manager/templates/workout/view.html+++ b/wger/manager/templates/workout/view.html@@ -124,15 +124,14 @@ $(document).ready(function() {<h4>{% trans "Options" %}</h4><p>+ <a data-toggle="modal" data-target="#download-pdf-popup"><img src="{% static 'images/icons/save.svg' %}"width="32"height="32"alt="{% trans 'Download as PDF' %}"title="{% trans 'Download as PDF' %}">- {% trans "Download as PDF" %}:- <a href="{% url 'manager:workout:pdf-log' workout.id uid token %}">{% trans "Log" %}</a>- |- <a href="{% url 'manager:workout:pdf-table' workout.id uid token %}">{% trans "Table" %}</a>+ {% trans "Download as PDF" %}+ </a></p><p>@@ -222,4 +221,68 @@ an appointment for each training day with the appropriate exercises.{% endblockt</div></div></div>++<div class="modal fade" id="download-pdf-popup">+ <div class="modal-dialog">+ <div class="modal-content">+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>+ <h4 class="modal-title">{% trans "Download as PDF" %}</h4>+ </div>+ <div class="modal-body">+ <form class="form-horizontal">+ <div id="pdf-download-info" data-workout-id="{{ workout.id }}" data-uid="{{ uid }}" data-token="{{ token }}"></div>+ <div class="form-group">+ <div>+ <label for="id_images" class="col-md-3 control-label">+ {% trans "Type" %}+ </label>+ </div>+ <div class="col-md-9" style="padding-left: 35px;">+ <div class="radio">+ <input type="radio" name="pdf_type" id="id_type_log" value="log" checked>+ {% trans "Log" %}+ </div>+ <div class="radio">+ <input type="radio" name="pdf_type" id="id_type_table" value="table">+ {% trans "Table" %}+ </div>+ </div>+ </div>+ <div class="form-group">+ <div>+ <label for="id_images" class="col-md-3 control-label">+ {% trans "with images" %}+ </label>+ </div>+ <div class="col-md-9">+ <input type="checkbox" class="checkbox" name="images" id="id_images" checked>+ </div>+ </div>+ <div class="form-group">+ <div>+ <label for="id_comments" class="col-md-3 control-label">+ {% trans "with comments" %}+ </label>+ </div>+ <div class="col-md-9">+ <input type="checkbox" class="checkbox" name="comments" id="id_comments" checked>+ </div>+ </div>+ </form>++ <p>+ <a href="" class="btn btn-block btn-default" id="download-pdf-button">+ <img src="{% static 'images/icons/save.svg' %}"+ width="32"+ height="32"+ alt="{% trans 'Download' %}"+ title="{% trans 'Download' %}">+ {% trans "Download" %}+ </a>+ </p>+ </div>+ </div>+ </div>+</div>{% endblock %}diff --git a/wger/manager/urls.py b/wger/manager/urls.pyindex e62ae1aa0..0cd898b62 100644--- a/wger/manager/urls.py+++ b/wger/manager/urls.py@@ -90,7 +90,7 @@ patterns_workout = [name='ical'),url(r'^(?P<id>\d+)/pdf/log/(?P<images>[01]+)/(?P<comments>[01]+)/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})$',pdf.workout_log,- name='pdf-log'),+ name='pdf-log'), #JS!url(r'^(?P<id>\d+)/pdf/log/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})$',pdf.workout_log,name='pdf-log'),@@ -102,7 +102,7 @@ patterns_workout = [name='pdf-log'),url(r'^(?P<id>\d+)/pdf/table/(?P<images>[01]+)/(?P<comments>[01]+)/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})$',pdf.workout_view,- name='pdf-table'),+ name='pdf-table'), #JS!url(r'^(?P<id>\d+)/pdf/table/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})$',pdf.workout_view,name='pdf-table'),