{% extends 'lib/base.html' %}
{% load static %}
{% block body %}
<style>
    #id_date {
        max-width: 23ch;
    }
</style>
    <title>Edit {{ activity }} | Workoutizer</title>
    <h3>Edit Activity: {{ activity }}</h3>
    <hr>
    <br>
    <div class="container">
        <form action="/activity/{{ activity.id }}/edit/" method="post" accept-charset="utf-8"
              enctype="multipart/form-data">
            {% csrf_token %}
            {% include "lib/form_errors.html" %}
            {% include "lib/messages.html" %}
            <div class="form-group row">
                <div class="col-sm-3">{{ form.name.label }}</div>
                <div class="col-sm-9">{{ form.name }}</div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">{{ form.sport.label }}</div>
                <div class="col-sm-9">{{ form.sport }}</div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">{{ form.date.label }}:</div>
                <div class="col-sm-9">{{ form.date }}</div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">{{ form.duration.label }}</div>
                <div class="col-sm-9">{{ form.duration }}&nbsp;&nbsp;min</div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">{{ form.distance.label }}</div>
                <div class="col-sm-9">{{ form.distance }}&nbsp;&nbsp;km</div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">{{ form.description.label }}</div>
                <div class="col-sm-9">{{ form.description }}</div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">{{ form.evaluates_for_awards.label }}</div>
                <div class="col-sm-9">{{ form.evaluates_for_awards }}&nbsp;&nbsp;
                    <i class="fas fa-question" data-toggle="tooltip" data-placement="right"
                       title="Disable to exclude this activity from awards. Note this option needs to be enabled for both this activity and its sport to consider it for awards."></i>
                </div>
            </div>
            <br>
            {% if has_laps %}
                <a href="#edit_laps" id="edit-lap-data" class="h4" style="color: black;" data-toggle="collapse">Lap Data <i
                        class="fas fa-angle-down"></i></a>
                <div id="edit_laps" class="collapse">
                    <br>
                    {{ formset.management_form }}
                    {% for lap_form in formset %}
                        {% if forloop.counter < formset|length %}
                            {% comment %} always skip last entry {% endcomment %}
                            {{ lap_form.id }}
                            <div class="form-group row">
                                <div class="col-sm-3">{{ forloop.counter }}. Lap:</div>
                                <div class="col-sm-9">{{ lap_form.label }}</div>
                            </div>
                        {% endif %}
                    {% endfor %}
                </div>
                <br>
                <br>
            {% endif %}
            <button id="submit-button" class="float-left btn btn-warning btn-space" type="submit" name="action"><i
                    class="fas fa-check"></i>&nbsp;&nbsp;Save
            </button>
            <a href="/activity/{{ activity.id }}" id="cancel-button" class="float-left btn btn-outline-secondary">Cancel</a>
            <a href="/activity/{{ activity.id }}/delete/" class="float-right btn btn-danger"><i
                    class="fas fa-trash-alt"></i>&nbsp;&nbsp;Delete</a>
            <div class="clearfix"></div>
        </form>
    </div>
{% endblock %}