{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load wger_extras %}

{% block title %}{% trans "Weight log for workout" %}{% endblock %}


{% block header %}{% endblock %}


{% block scripts %}
<script type="text/javascript">
$(document).on('pageinit', function(){
    // Init the data toggle for the weight log tables
    toggle_weight_log_table();
});
</script>
{% endblock %}


{% block content %}
{% if workout.comment %}
<p>
    <strong>{% trans "Goal" %}:</strong> {{workout.comment}}
</p>
{% endif %}


{% for day in workout.canonical_representation.day_list %}
<ul data-role="listview"
    style="margin-top: 3em;"
    data-icon="plus">
    <li data-theme="b">
        <a href="{% url 'day-log' day.obj.id %}">
        <h3>{{ day.obj.description }}</h3>
        </a>
    </li>
</ul>

    {% for set in day.set_list %}
    {% for exercise in set.exercise_list %}

        {% with day_list=workout_log|get_item:day.obj.id %}
        {% with exercise_list=day_list|get_item:exercise.obj.id %}

        <ul data-role="listview"
            style="margin-top: 3em;">
            <li>
                <a href="{{ exercise.obj.get_absolute_url }}">{{ exercise.obj.name }}</a>
            </li>
        </ul>

        {% if exercise_list.log_by_date %}
            {% with list=exercise_list.log_by_date %}
                {% render_weight_log list exercise_list.div_uuid %}

                <script>
                $(document).ready(function() {
                weight_log_chart({{exercise_list.chart_data|safe}},
                                 "{{exercise_list.div_uuid}}",
                                 "{{reps}}",
                                 $('#content').width() * 0.95)
                });
                </script>
            {% endwith %}
        {% else %}
        <p><em>{% trans "No weight entries here." %}</em></p>
        {% endif %}

        {% endwith %}
        {% endwith %}

    {% empty%}
    <p>
        <em>{% trans "No exercises for this day." %}</em>
    </p>
    {% endfor %}
    {% endfor %}
{% endfor %}


{% endblock %}



<!--
        Side bar
-->
{% block sidebar %}
<h3>{% trans "Options" %}</h3>
<p>
<a href="{% url 'workout-view' workout.id %}"
   data-role="button">
    <img src="{% static 'images/icons/list.svg' %}"
         width="32"
         height="32"
         alt="{% trans 'Back to workout' %}">
    {% trans "Back to workout" %}
</a>
</p>

<h3>{% trans "Notes" %}</h3>
<p>{% blocktrans %}This page shows the weight logs belonging to this workout
only. Click on an exercise to see all the historical data for
it.{% endblocktrans %}</p>

<p>{% blocktrans %}Click on a value on a chart to edit the log
entry.{% endblocktrans %}</p>

<p>{% blocktrans %}If on a single day there is more than one entry with the
same number of repetitions, but different weights, only the entry with the
higher weight is shown in the diagram.{% endblocktrans %}</p>
{% endblock %}
