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

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

{% load event_tags %}
{% load i18n %}
{% load static %}

{% block extra_title %}{% translate "Assign reviewers" %} :: {% endblock extra_title %}

{% block content %}
    {{ review_mapping|json_script:"review-mapping" }}
    <h2>{% translate "Assign reviewers" %}</h2>

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

    <section role="tabpanel" id="tabpanel-group" aria-labelledby="tab-group" tabindex="0" aria-hidden="false">
        <p>
            {% blocktranslate trimmed %}
                Reviewers can be assigned to tracks by way of review teams. If you require more
                granular assignments, you can also assign reviewers to proposals individually.
            {% endblocktranslate %}
        </p>
        <div class="alert alert-info">
            {% blocktranslate trimmed %}
                As teams can belong to multiple events, teams are managed in your organiser settings.
            {% endblocktranslate %}
        </div>
        <div class="d-flex justify-content-end mb-2">
            <a href="{{ request.event.organiser.orga_urls.new_team }}" class="btn btn-info">
                <i class="fa fa-plus"></i> {% translate "New team" %}
            </a>
        </div>
        <table class="table table-sm table-flip">
            <thead>
                <tr>
                    <th class="col col-md-4">{% translate "Team" %}</th>
                    <th class="col col-md-3">{% translate "Members" %}</th>
                    {% if request.event|get_feature_flag:"use_tracks" %}
                        <th class="col col-md-3">{% translate "Limited to tracks" %}</th>
                    {% endif %}
                    <th></th>
                </tr>
            </thead>
            <tbody>
                {% for team in review_teams %}
                    <tr>
                        <td>
                            <a href="{{ team.orga_urls.base }}{% querystring next=request.path|urlencode %}">
                                {{ team.name }}
                                {% if request.user in team.members.all %}
                                    <i class="fa fa-star text-warning" title="{% translate "You are a member of this team" %}"></i>
                                {% endif %}
                            </a>
                        </td>
                        <td>
                            {% if team.members.count %}
                                <details>
                                    <summary>{{ team.members.count }}</summary>
                                    <ul>
                                        {% for member in team.members.all %}
                                            <li>{% include "orga/includes/user_name.html" with user=member lightbox=True %}</li>
                                        {% endfor %}
                                    </ul>
                                </details>
                            {% else %}
                                -
                            {% endif %}
                        </td>
                        {% if request.event|get_feature_flag:"use_tracks" %}
                            <td>
                                {% for track in team.limit_tracks.all %}
                                    <span class="badge color-secondary">{{ track.name }}</span>
                                {% empty %}
                                    -
                                {% endfor %}
                            </td>
                        {% endif %}
                        <td class="text-right">
                            <a href="{{ team.orga_urls.base }}{% querystring next=request.path|urlencode %}" class="btn btn-sm btn-info" title="{{ phrases.base.edit }}">
                                <i class="fa fa-edit"></i>
                            </a>
                            <a href="{{ team.orga_urls.delete }}{% querystring next=request.path|urlencode %}" class="btn btn-sm btn-danger" title="{{ phrases.base.delete_button }}">
                                <i class="fa fa-trash"></i>
                            </a>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </section>
    <section role="tabpanel" id="tabpanel-individual" aria-labelledby="tab-individual" tabindex="0" aria-hidden="false">

        <div class="alert alert-info"><p>
            {% if request.event.active_review_phase.proposal_visibility == "assigned" %}
                {% blocktranslate trimmed with href=request.event.orga_urls.review_settings %}
                    Reviewers will be able to see and review <strong>only their assigned</strong> proposals.
                    You can change this in your <a href="{{ href }}">review settings</a>.
                {% endblocktranslate %}
            {% else %}
                {% blocktranslate trimmed with href=request.event.orga_urls.review_settings %}
                    Reviewers will be able to see and review <strong>all proposals</strong>,
                    but their assigned reviews will appear highlighted, and they
                    will be directed to them first. You can change this in your <a
                        href="{{ href }}">review settings</a>.
                {% endblocktranslate %}
            {% endif %}
        </p></div>
        <p>
            {% blocktranslate trimmed %}
                This is where you can assign reviewers to specific proposals! Please use this drop-down to
                switch between the two assignment modes (assigning reviewers to proposals or proposals to reviewers).
            {% endblocktranslate %}
            {% blocktranslate trimmed %}
                You can also use the Actions menu above to import your assignments from a prepared file.
            {% endblocktranslate %}
        </p>
        <div class="float-right">
            <details class="dropdown" aria-haspopup="menu" role="menu">
                <summary class="btn btn-info" id="review-actions">
                    {% translate "Actions" %} <i class="fa fa-caret-down"></i>
                </summary>

                <div class="dropdown-content dropdown-front dropdown-content-s{% if rtl %}e{% else %}w{% endif %}">
                    <a class="dropdown-item" href="{{ request.path }}import" target="_blank" rel="noopener" role="menuitem" tabindex="-1">
                        <i class="fa fa-upload"></i> {% translate "Import assignments" %}
                    </a>
                </div>
            </details>
        </div>
        <div class="ml-auto mr-auto col-md-4">
            <form id="direction">
                {{ direction_form }}
            </form>
        </div>

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

    </section>
{% endblock content %}

