{% extends 'lib/base.html' %}
{% load static %}
{% block body %}
<div class="row">
    <div class="col-md-10 mr-auto ml-auto">
        <div class="card">
            <div class="card-body">
                <form action="/activity/{{ activity.id }}/edit/" method="post" accept-charset="utf-8"
                    enctype="multipart/form-data" class="form-horizontal">
                    {% include "activity/activity_form_fields.html" %}
                    <div class="row">
                        <label class="col-md-4 col-form-label">{{ form.evaluates_for_awards.label }}</label>
                        <div class="col-md-8">
                            <div class="form-check form-check-inline">
                                <label class="form-check-label">
                                    {{ form.evaluates_for_awards }}
                                    <span class="form-check-sign"></span>
                                    <i class="fas fa-question-circle" 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>
                                </label>
                            </div>
                        </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="row">
                                        <label class="col-md-4 col-form-label">{{ forloop.counter }}. Lap</label>
                                        <div class="col-md-8">
                                            <div class="form-group">
                                                {{ lap_form.label }}
                                            </div>
                                        </div>
                                    </div>
                                {% endif %}
                            {% endfor %}
                        </div>
                        <br>
                        <br>
                    {% endif %}
                    <button id="submit-button" class="float-left btn btn-success 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="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>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}