{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% load staticfiles %}
{% load manager_extras %}

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

{% block header %}
<script src="{% static 'js/d3.js' %}"></script>

<script type="text/javascript">
// Initialise the datepicker for the modal dialog
function custom_modal_init()
{
    init_weight_log_datepicker();
}
</script>
{% endblock %}

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

{% for day, exercise_log in workout_log.items %}
<h3>{{ day.description }}</h3>

<p>
<a href="{% url 'day-log' day.id %}"
   title="{% trans 'Add weight log to this day' %}">
       <img src="{% static 'images/icons/statistics.svg' %}"
            width="32"
            height="32"
            alt="{% trans 'Add weight log to this day' %}">
    {% trans 'Add weight log to this day' %}
</a>
</p>

    {% for exercise, date_list in exercise_log.items %}
    <div class="alert alert-info" style="text-align: center;margin-top:1em;">
        <a href="{{ exercise.get_absolute_url }}">{{ exercise.name }}</a>
    </div>

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

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

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


{% endblock %}



<!--
        Side bar
-->
{% block sidebar %}
<h3>{% trans "Options" %}</h3>
<p>
<a href="{% url 'workout-view' workout.id %}">
    <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 %}
