{% extends "orga/base.html" %}
{% load bootstrap4 %}
{% load compress %}
{% load i18n %}
{% load staticfiles %}

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

{% block content %}
    {% if not request.event.rooms.count %}
        <div class="alert alert-warning schedule-alert">
            {% 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.room_settings }}">{% trans "Configure rooms" %}</a>
        </div>
    {% endif %}

    {% if request.event.current_schedule %}
        {% if request.event.settings.show_schedule %}
            <div class="alert alert-info schedule-alert">
                {% trans "Your schedule is currently publicly visible." %}
                <a class="btn btn-xs btn-secondary" href="{{ request.event.orga_urls.toggle_schedule }}">{% trans "Hide schedule" %}</a>
                <a
                    class="btn btn-secondary"
                    title="view publically"
                    href="{{ active_schedule.urls.public }}"
                    ><i class="fa fa-eye"></i>
                </a>
            </div>
        {% else %}
            <div class="alert alert-info schedule-alert">
                {% trans "Your schedule is currently only visible to orga members." %}
                <a class="btn btn-xs btn-secondary" href="{{ request.event.orga_urls.toggle_schedule }}">{% trans "Make schedule public" %}</a>
                <a
                    class="btn btn-secondary"
                    title="view publically"
                    href="{{ active_schedule.urls.public }}"
                    ><i class="fa fa-eye"></i> {% trans "View in frontend" %}
                </a>
            </div>
        {% endif %}
    {% else %}
        {% if request.event.settings.show_schedule %}
            <div class="alert alert-info schedule-alert">
                {% trans "Once you release your schedule, it will be publicly visible." %}
                <a class="btn btn-xs btn-secondary" href="{{ request.event.orga_urls.toggle_schedule }}">{% trans "Hide schedule" %}</a>
            </div>
        {% else %}
            <div class="alert alert-info schedule-alert">
                {% trans "Once you release your schedule, it will be only visible to orga members." %}
                <a class="btn btn-xs btn-secondary" href="{{ request.event.orga_urls.toggle_schedule }}">{% trans "Make schedule public" %}</a>
            </div>
        {% endif %}
    {% endif %}

    {% 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">
                    <label for="version">{% trans "Version:" %}&nbsp;</label>
                    <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-primary">{% trans "View" %}</button>
                </form>
            </div>
        </div>
        {% if not schedule_version %}
            <div id="schedule-release">
                <form method="post" action="{{ request.event.orga_urls.release_schedule }}">
                    {% csrf_token %}
                    <div class="input-group">
                        <input id="id_version" class="form-control" name="version" maxlength="200" placeholder="{{ phrases.orga.schedule_example_version }}" title="" type="text">
                        <button type="submit" class="btn btn-primary">{% trans "Release" %}</button>
                    </div>
                </form>
            </div>
        {% else %}
            <form method="post" action="{{ request.event.orga_urls.reset_schedule }}?{{ request.GET.urlencode }}">
                {% csrf_token %}
                <button type="submit" class="btn btn-secondary">{% trans "Reset to selected version" %}</button>
            </form>
        {% endif %}
    </div>
    <div id="fahrplan">
    </div>

    {% compress js %}
    <script type="text/javascript" src="{% static "orga/js/schedule.js" %}"></script>
    {% endcompress %}
{% endblock %}
