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

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

{% load i18n %}
{% load render_table from django_tables2 %}
{% load review_score %}
{% load rules %}
{% load static %}

{% block scripts %}
    <script defer src="{% static "vendored/rslider/rSlider.min.js" %}"></script>
    <script defer src="{% static "orga/js/ui/review.js" %}"></script>
{% endblock scripts %}

{% block stylesheets %}
    <link rel="stylesheet" type="text/css" href="{% static "vendored/rslider/rSlider.min.css" %}" />
    <link rel="stylesheet" href="{% static "common/css/ui/tooltip.css" %}" />
    <link rel="stylesheet" href="{% static "orga/css/ui/reviews.css" %}" />
{% endblock stylesheets %}

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

{% block content %}
    {% has_perm "submission.create_review" request.user request.event as can_review %}
    {% has_perm "person.reviewer_list_speakerprofile" request.user request.event as can_view_speakers %}
    <div class="alert alert-info">
        <div>
            {% if can_review and next_submission %}
                {% blocktranslate trimmed count count=missing_reviews %}
                    {{ count }} proposal is waiting for your review.
                {% plural %}
                    {{ count }} proposals are waiting for your review.
                {% endblocktranslate %}
                <a href="{{ next_submission.orga_urls.reviews }}">{% translate "Click here to get started!" %}</a>
                <br>
                <small><a href="{{ request.event.orga_urls.reviews }}bulk/">{% translate "Or review all proposals at once." %}</a></small>
            {% elif can_review %}
                {% translate "You’ve got no proposals left to review!" %}
            {% else %}
                {% if not reviews_open %}
                    {% translate "Reviews are currently closed." %}
                {% else %}
                    {% translate "You don’t have reviewer permissions for this event." %}
                {% endif %}
            {% endif %}
        </div>
    </div>

    <div class="ml-auto mb-2 d-flex">
        {% if can_change_submissions %}
            <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 %}">
                    {% if request.event.tags.exists %}
                        <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>
                    {% endif %}
                    <a class="dropdown-item" href="{{ request.event.orga_urls.reviews }}regenerate" role="menuitem" tabindex="-1">
                        <i class="fa fa-link"></i> {% translate "Regenerate decision emails" %}
                    </a>
                    <a class="dropdown-item" href="{{ request.event.orga_urls.apply_pending }}{% querystring next=request.path|urlencode %}" role="menuitem" tabindex="-1">
                        <i class="fa fa-link"></i> {% translate "Apply pending changes" %}
                    </a>
                </div>
            </details>
        {% endif %}
    </div>

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

    <div class="review-table">
        {% render_table table "orga/tables/review_table.html" %}
    </div>
{% endblock content %}
