{% extends "cfp/event/base.html" %}
{% load bootstrap4 %}
{% load formset_tags %}
{% load i18n %}
{% load staticfiles %}
{% block title %}{% trans "Your submission" %} :: {{ request.event }}{% endblock %}
{% block content %}
    <script type="text/javascript" src="{% static "js/jquery.formset.js" %}"></script>
    <h2>{% trans "Your submission:" %} {{ submission.title }}</h2>
    <p>
        {% trans "Current state of your submission:" %}
        {% include "cfp/event/fragment_state.html" with state=submission.state %}
    </p>
    <h5>
        <form class="add-speaker" action="{{ submission.urls.invite }}">
            {% csrf_token %}
            <div class="form-group form-inline">
                {% blocktrans trimmed count count=submission.speakers.count %}
                    Speaker:
                    {% plural %}
                    Speakers:
                {% endblocktrans %}
                {{ submission.display_speaker_names }},
                <div class="input-group">
                    <input name="email" class="form-control form-control-sm" placeholder="another.speaker@mail.org">
                    <span class="input-group-btn">
                        <button class="btn btn-primary btn-sm">
                            <span class="fa fa-plus"></span>
                        </button>
                    </span>
                </div>
            </div>
        </form>
    </h5>
    <form action="" method="post" enctype="multipart/form-data">
        {% csrf_token %}
        {% bootstrap_form form layout='event' %}
        {% bootstrap_form qform layout='event' %}
            <div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}">
                {{ formset.management_form }}
                {% bootstrap_formset_errors formset %}
                <div class="col-md-3">{% trans "Resources" %}</div>
                <div class="alert alert-info col-md-9 ml-auto">
                    {% trans "Resources will be publicly visible. Please try to keep your uploads below 16MB." %}
                </div>
                <div data-formset-body>
                    {% for form in formset %}
                        <div data-formset-form>
                            <div class="sr-only">
                                {{ form.id }}
                                {% bootstrap_field form.DELETE form_group_class="" layout="inline" %}
                            </div>
                            <div class="resource-option-row ml-auto col-md-9">
                                <div class="resource-option-input{% if action == 'view' %} disabled{% endif %}">
                                    {% bootstrap_form_errors form %}
                                    {% bootstrap_field form.description layout='inline' %}
                                    {% bootstrap_field form.resource layout='inline'  %}
                                </div>
                                {% if action != 'view' %}
                                <div class="resource-option-delete">
                                    <button type="button" class="btn btn-danger" data-formset-delete-button>
                                        <i class="fa fa-trash"></i></button>
                                </div>
                                {% endif %}
                            </div>
                        </div>
                    {% endfor %}
                </div>
                <script type="form-template" data-formset-empty-form>
                    {% escapescript %}
                        <div data-formset-form>
                            <div class="sr-only">
                                {{ formset.empty_form.id }}
                                {% bootstrap_field formset.empty_form.DELETE form_group_class="" layout="inline" %}
                            </div>
                            <div class="resource-option-row ml-auto col-md-9">
                                <div class="resource-option-input">
                                    {% bootstrap_field formset.empty_form.description layout='inline' %}
                                    {% bootstrap_field formset.empty_form.resource layout='inline'  %}
                                </div>
                                <div class="resource-option-delete">
                                    <button type="button" class="btn btn-danger" data-formset-delete-button>
                                        <i class="fa fa-trash"></i></button>
                                </div>
                            </div>
                        </div>
                    {% endescapescript %}
                </script>
                {% if action != 'view' %}
                <div class="col-md-9 ml-auto">
                    <button type="button" class="btn btn-info" data-formset-add>
                        <i class="fa fa-plus"></i> {% trans "Add a new option" %}</button>
                </div>
                {% endif %}
            </div>
                <script>jQuery(function($) {
                    $(".formset").formset({
                        animateForms: true
                    });
                    });</script>
        {% if can_edit %}
            <div class="row">
                <div class="col-md-3 ml-auto">
                    <button type="submit" class="btn btn-block btn-success btn-lg">
                        {% trans "Save" %}
                    </button>
                </div>
            </div>
        {% endif %}
    </form>
    {% if submission.state == "submitted" %}
        <h3>{% trans "Withdraw submission" %}</h3>
        <p>
            {% blocktrans trimmed %}
                You can click here to withdraw your submission from the selection process. You cannot undo this - if you are
                just uncertain if you can or should hold your talk, please contact the organizer instead.
            {% endblocktrans %}
        </p>
        <div class="row">
            <div class="col-md-3 ml-auto">
                <a href="{{ submission.urls.withdraw }}"
                   class="btn pull-right btn-danger btn-block">
                    {% trans "Withdraw" %}
                </a>
            </div>
        </div>
    {% elif submission.state == "accepted" or submission.state == "confirmed" %}
        <h3>{% trans "Cancel submission" %}</h3>
        <p>
            {% blocktrans trimmed %}
                As your submission has been accepted already, please contact the event's organizing team to cancel
                it. The best way to reach out would be an answer to your acceptance mail.
            {% endblocktrans %}
        </p>
    {% endif %}

    <div class="user-logs">
        {% include "common/logs.html" with obj=submission hide_orga="true" %}
    </div>
{% endblock %}
