<!--
SPDX-FileCopyrightText: 2024-present Tobias Kunze
SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms
-->

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

{% load i18n %}
{% load review_score %}
{% load rules %}
{% load static %}

{% block extra_title %}{% translate "Reviews" %} :: {% endblock extra_title %}

{% block stylesheets %}
    <link rel="stylesheet" href="{% static "orga/css/ui/reviews.css" %}" />
{% endblock stylesheets %}

{% block content %}
    {% has_perm "person.reviewer_list_speakerprofile" request.user request.event as can_view_speakers %}
    <div class="alert alert-info">
        {% if next_submission %}
            {% blocktranslate trimmed count count=missing_reviews %}
                Or review the missing proposal here.
            {% plural %}
                Or review the missing {{ count }} proposals one-by-one.
            {% endblocktranslate %}
            <a href="{{ next_submission.orga_urls.reviews }}" class="btn btn-outline-info btn-xs ml-2">
                <i class="fa fa-arrow-right"></i>
            </a>
        {% else %}
            {% translate "You’ve got no proposals left to review!" %}
        {% endif %}
    </div>

    <div class="ml-auto mb-2 d-flex">
        {% if request.event.tags.exists %}
            <details class="dropdown flip fix-height ml-auto" role="menu">
                <summary class="btn btn-info">
                    {% translate "Actions" %} <i class="fa fa-caret-down ml-1"></i>
                </summary>
                <div class="dropdown-content dropdown-content-s{% if rtl %}e{% else %}w{% endif %}">
                    <a class="dropdown-item" href="{{ request.event.orga_urls.reviews }}bulk-tag/{% querystring page='' %}" role="menuitem" tabindex="-1">
                        <i class="fa fa-tags"></i> {% translate "Bulk tag proposals" %}
                    </a>
                </div>
            </details>
        {% endif %}
    </div>

    {% include "orga/includes/review_filter_form.html" %}

    <form method="post">
        {% csrf_token %}
        <div class="table-responsive-sm">
            <table class="table table-sm table-flip table-sticky">
                <thead>
                    <tr>
                        <th>{% translate "Title" %}</th>
                        {% if can_view_speakers %}<th>{{ phrases.schedule.speakers }}</th>{% endif %}
                        {% for category in categories %}<th>{{ category.name }}</th>{% endfor %}
                        <th>{% translate "Comment" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for row in table %}
                        <tr>
                            <td>
                                <a href="{{ row.submission.orga_urls.base }}">{{ row.submission.title }}</a>
                            </td>
                            {% if can_view_speakers %}
                                <td>
                                    {% for speaker in row.submission.speakers.all %}
                                        {% include "orga/includes/user_name.html" with user=speaker lightbox=True %}<br>
                                    {% endfor %}
                                </td>
                            {% endif %}
                            {% for score in row.score_fields %}
                                <td class="pt-2">
                                    {% if score %}
                                        {{ score.as_field_group }}
                                    {% endif %}
                                </td>
                            {% endfor %}
                            <td class="pt-2">
                                {{ row.form.text.as_field_group }}
                            </td>
                        </tr>
                    {% empty %}
                        <tr>
                            <td colspan=10>{% translate "You don’t seem to have any proposals yet." %}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <div id="submitBar">
            <button type="submit" class="btn btn-success">{{ phrases.base.save }}</button>
        </div>
    </form>
{% endblock content %}
