{% extends "orga/cfp/base.html" %}
{% load bootstrap4 %}
{% load i18n %}
{% load rules %}
{% load url_replace %}

{% block content %}
{% has_perm 'orga.create_submission' request.user request.event as can_create_submission %}
    <legend>
        <span>
            {{ page_obj.paginator.count }}
            {% blocktrans trimmed count count=page_obj.paginator.count %}
            submission
            {% plural %}
            submissions
            {% endblocktrans %}
        </span>
    </legend>
    <div class="submit-group">
        <form class="search-form">
            {% bootstrap_form search_form %}
            {% bootstrap_form filter_form %}
            <button class="btn btn-success" type="submit">{% trans "Search" %}</button>
        </form>
        <p class="legend-buttons">
            {% if can_create_submission %}
            <a href="{{ request.event.orga_urls.new_submission }}" class="btn btn-success">
                <i class="fa fa-plus"></i> {% trans "Add new submission" %}
            </a>
            {% endif %}
            <a href="{{ request.event.orga_urls.submission_cards }}" class="btn btn-info">
                <i class="fa fa-print"></i> {% trans "Print cards" %}
            </a>
        </p>
    </div>

    <table class="table table-sm table-hover table-responsive-md">
        <thead>
            <tr>
                <th>
                    {% trans "Title" %}
                    <a href="?{% url_replace request 'sort' '-title' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'title' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th>{% trans "Speakers" %}</th>
                <th>
                    {% trans "Type" %}
                </th>
                <th>
                    {% trans "State" %}
                    <a href="?{% url_replace request 'sort' '-state' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'state' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th>
                    {% trans "Sneak peek" %}
                    <a href="?{% url_replace request 'sort' '-is_featured' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'is_featured' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for submission in submissions %}
                <tr>
                    <td>
                        <a href="{{ submission.orga_urls.base }}">
                            {{ submission.title }}
                        </a>
                    </td>
                    <td>
                        {% for speaker in submission.speakers.all %}
                            <a href="{% url "orga:speakers.view" event=request.event.slug pk=speaker.id %}">
                                {{ speaker.get_display_name }}
                            </a><br>
                        {% endfor %}
                    </td>
                    <td>
                        {{ submission.submission_type.name }}
                    </td>
                    <td>
                        {% include "orga/submission/state_dropdown.html" with submission=submission %}
                    </td>
                    <td class="submission_featured">
                        <div class="checkbox" title="{% trans 'Show this submission in the public sneak peek.' %}" style="display: inline-block">
                            <input
                                type="checkbox"
                                id="featured_{{ submission.code }}"
                                data-id="{{ submission.code }}"
                                class="submission_featured"
                                {% if submission.is_featured %}checked{% endif %}
                            >
                            <label for="featured_{{ submission.code }}"></label>
                        </div>
                        <i class="working fa fa-spinner fa-spin d-none"></i>
                        <i class="done fa fa-check d-none"></i>
                        <i class="fail fa fa-times d-none"></i>
                    </td>
                    <td class="text-right">
                        <a href="{{ submission.orga_urls.edit }}"
                            title="{% trans "edit" %}"
                            class="btn btn-sm btn-info">
                            <i class="fa fa-edit"></i>
                        </a>
                        <a href="{{ submission.orga_urls.delete }}?from=list"
                            title="{% trans "delete" %}"
                            class="btn btn-sm btn-danger">
                            <i class="fa fa-trash"></i>
                        </a>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>

    {% include "orga/pagination.html" %}


{% endblock %}
