{% extends "orga/base.html" %}

{% load compress %}
{% load i18n %}
{% load static %}

{% block extra_title %}{{ request.event.rooms.count }} {% blocktranslate trimmed count count=request.event.rooms.count context "Number of rooms" %}Room{% plural %}Rooms{% endblocktranslate %} :: {% endblock extra_title %}

{% block stylesheets %}
    {% compress css %}
        <link rel="stylesheet" href="{% static "orga/css/dragsort.css" %}">
    {% endcompress %}
{% endblock stylesheets %}

{% block scripts %}
    {% compress js %}
        <script defer src="{% static "orga/js/dragsort.js" %}"></script>
    {% endcompress %}
{% endblock scripts %}

{% block content %}
    <div>
        <h2>
            {{ request.event.rooms.count }}
            {% blocktranslate trimmed count count=request.event.rooms.count context "Number of rooms" %}
                Room
            {% plural %}
                Rooms
            {% endblocktranslate %}
        </h2>

        <div class="table-responsive-sm">
            <table class="table table-sm table-hover table-flip table-sticky">
                <thead>
                    <tr>
                        <th>{% translate "Name" %}</th>
                        <th class="numeric">{% translate "Capacity" %}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody dragsort-url="{{ request.event.orga_urls.room_settings }}">
                    {% for room in request.event.rooms.all %}
                        <tr dragsort-id="{{ room.pk }}">
                            <td>
                                <a href="{{ room.urls.settings_base }}">{{ room.name }}</a>
                            </td>
                            <td class="numeric">
                                {% if room.capacity %}{{ room.capacity }}{% endif %}
                            </td>
                            <td class="text-right">
                                <button draggable="true" class="btn btn-sm btn-primary mr-1 dragsort-button" title="{% translate "Move item" %}">
                                    <i class="fa fa-arrows"></i>
                                </button>

                                <a href="{{ room.urls.edit }}" class="btn btn-sm btn-info">
                                    <i class="fa fa-edit"></i>
                                </a>
                                <a href="{{ room.urls.delete }}" class="btn btn-sm btn-danger">
                                    <i class="fa fa-trash"></i>
                                </a>
                            </td>
                        </tr>
                    {% empty %}
                        <tr>
                            <td>{% translate "Please add at least one place in which sessions can take place." %}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>

        <div class="submit-group"><span></span>
            <a class="btn btn-lg btn-success" href="{{ request.event.orga_urls.new_room }}">
                <i class="fa fa-plus"></i>
                {% translate "New room" %}
            </a>
        </div>
    </div>
{% endblock content %}
