{% extends 'events/abstracts/management/_base.html' if management else 'events/abstracts/display/_base.html' %}

{% from 'events/abstracts/reviewing/judgment.html' import render_reviewed_for_tracks_box, render_review_summary_box %}
{% from 'events/abstracts/reviewing/public.html' import render_abstract_info, render_abstract_judgment,
                                                        render_submission_info %}
{% from 'events/abstracts/reviewing/timeline.html' import render_multiple_review_group_text %}
{% from 'events/reviews/timeline.html' import render_timeline %}
{% from 'events/reviews/_common.html' import render_decision_box %}

{% block back_button_url -%}
    {% if management -%}
        {{ url_for('.manage_abstract_list', abstract.event) }}
    {%- endif %}
{%- endblock %}

{% block back_button_title -%}
    {% if management %}
        {%- trans %}Back to list of abstracts{% endtrans -%}
    {% endif %}
{% endblock %}

{% block content %}
    {{ render_abstract_info(abstract) }}

    {% call(block, __) render_timeline(abstract, comment_form, review_form) %}
        {% if block == 'multiple-review-group-text' %}
            {{ render_multiple_review_group_text(abstract) }}
        {% endif %}
        {% if block == 'revision-info' %}
            {{ render_submission_info(abstract, field_values) }}
        {% endif %}
    {% endcall %}

    <div class="i-timeline">
        {% if abstract.can_change_tracks(session.user, check_state=true) and abstract.event.tracks %}
            {{ render_reviewed_for_tracks_box(abstract, review_track_list_form) }}
        {% endif %}

        {% if abstract.can_see_reviews(session.user) and visible_tracks %}
            <div class="i-timeline-item review-summary-box">
                {{ render_review_summary_box(abstract, session.user, visible_tracks) }}
            </div>
        {% endif %}

        {% if not abstract.event.is_locked and abstract.can_judge(session.user, check_state=true) %}
            <div id="proposal-decision-box" class="i-timeline-item">
                {{ render_decision_box(abstract, judgment_form, session.user) }}
            </div>
        {% endif %}

        {% if abstract.state.name not in ('submitted', 'withdrawn', 'invited') %}
            {{ render_abstract_judgment(abstract) }}
        {% endif %}
    </div>

    {% if abstract.email_logs and abstract.can_judge(session.user, check_state=false) %}
        <a class="open-review-notification-log"
           data-href="{{ url_for('.notification_log', abstract) }}"
           data-title="{% trans %}Sent notifications{% endtrans %}"
           data-subtitle="{% trans %}Log of notifications sent to submitter and authors of this abstract{% endtrans %}"
           data-ajax-dialog>
            {% trans count=abstract.email_logs|length -%}
                1 notification sent
            {%- pluralize -%}
                {{ count }} notifications sent
            {%- endtrans %}
        </a>
    {% endif %}

    {% if not no_javascript|default(false) %}
        <script>
            setupReviewingPage();
            setupAbstractJudgment({
                trackSessionMap: {{ track_session_map|tojson }}
            });
        </script>
    {% endif %}
{% endblock %}
