{% extends "orga/schedule/base.html" %}
{% load compress %}
{% load i18n %}
{% load static %}

{% block scripts %}
    {% compress js %}
    <script defer src="{% static "vendored/moment-with-locales.js" %}"></script>
    <script defer src="{% static "vendored/moment-timezone-with-data-2012-2022.js" %}"></script>
    {% if debug %}
    <script defer src="{% static "vendored/vue.js" %}"></script>
    {% else %}
    <script defer src="{% static "vendored/vue.min.js" %}"></script>
    {% endif %}
    <script defer src="{% static "vendored/vue-async-computed.js" %}"></script>
    <script defer src="{% static "orga/js/schedule.js" %}"></script>
    {% endcompress %}
{% endblock %}

{% block schedule_content %}

    {% if schedule_version %}
        <div class="alert alert-warning schedule-alert">
            {% trans "You're currently viewing a released schedule version. Released versions cannot be edited directly." %}
        </div>
    {% endif %}
    <div class="schedule-header">
        <div id="schedule-choice">
            <div class="input-group">
                <form class="form-inline">
                    <div class="input-group">
                        <select name="version" id="version" class="form-control">
                            <option value="">{% trans "Current draft" %}</option>
                            {% for schedule in request.event.schedules.all %}
                                {% if schedule.version %}
                                    <option value="{{ schedule.version }}" {% if schedule.version == schedule_version %}selected{% endif %}>{{ schedule.version }}</option>
                                {% endif %}
                            {% endfor %}
                        </select>
                        <button type="submit" class="btn btn-info">{% trans "Show" %}</button>
                    </div>
                </form>
            </div>
        </div>
        {% if not schedule_version %}
            <a id="schedule-release" href="{{ request.event.orga_urls.release_schedule }}" class="btn btn-success"><i class="fa fa-plus"></i> {% trans "New release" %}</a>
        {% else %}
            <form method="post" action="{{ request.event.orga_urls.reset_schedule }}?{{ request.GET.urlencode }}">
                {% csrf_token %}
                <button type="submit" class="btn btn-info">{% trans "Reset to current version" %}</button>
            </form>
        {% endif %}
        <div class="dropdown">
          <a class="btn btn-info dropdown-toggle" href="#" role="button" id="schedule-actions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              {% trans "Actions" %}
          </a>

          <div class="dropdown-menu dropdown-menu-right" aria-labelledby="schedule-actions">
            <a class="dropdown-item" href="{{ active_schedule.urls.public }}" target="_blank" rel="noopener">
                <i class="fa fa-link"></i> {% trans "View in frontend" %}
            </a>
            {% if request.event.settings.show_schedule %}
            <a class="dropdown-item" href="{{ request.event.orga_urls.toggle_schedule }}">
                <i class="fa fa-eye"></i> {% trans "Hide schedule" %}
            </a>
            {% else %}
            <a class="dropdown-item" href="{{ request.event.orga_urls.toggle_schedule }}">
                <i class="fa fa-eye"></i> {% trans "Make schedule public" %}
            </a>
            {% endif %}
            <a href="{{ request.event.orga_urls.submission_cards }}" class="dropdown-item">
                <i class="fa fa-print"></i> {% trans "Print cards" %}
            </a>
            <a href="resend_mails" class="dropdown-item">
                <i class="fa fa-envelope"></i> {% trans "Resend speaker notifications" %}
            </a>
          </div>
        </div>
    </div>
    {% if not request.event.rooms.count %}
        <div class="alert alert-warning schedule-alert">
            <span>
            {% trans "You can start planning your schedule once you have configured some rooms for talks to take place in." %}
            <a href="{{ request.event.orga_urls.new_room }}">{% trans "Configure rooms" %}</a>
            </span>
        </div>
    {% else %}

        <div id="fahrplan">
        </div>

    {% endif %}
{% endblock %}
