{% extends 'wagtailadmin/reports/base_report.html' %}
{% load i18n wagtailadmin_tags %}

{% block actions %}
    <div class="addbutton">
        <a href="{% url 'wagtailadmin_reports:workflow' %}" class="button">{% trans 'By Workflow' %}</a>
    </div>
    {{ block.super }}
{% endblock %}

{% block results %}
    {% if object_list %}
        <table class="listing">
            <thead>
                <tr>
                    <th>
                        {% trans 'Task' %}
                    </th>
                    <th>
                        {% trans 'Page' %}
                    </th>
                    <th>
                        {% trans 'Status' %}
                    </th>
                    <th>
                        {% trans 'Started at' %}
                    </th>
                    <th>
                        {% trans 'Completed at' %}
                    </th>
                </tr>
            </thead>
            <tbody>
                {% for task_state in object_list %}
                    <tr>
                        <td>
                            <b>{{ task_state.task }}</b>
                        </td>
                        <td>
                            {% with task_state.workflow_state.page as page %}
                                <a href="{% url 'wagtailadmin_pages:edit' page.id %}">
                                    {{ page.specific_deferred.get_admin_display_title }}
                                </a>
                                {% i18n_enabled as show_locale_labels %}
                                {% if show_locale_labels %}
                                    {% locale_label_from_id page.locale_id as locale_label %}
                                    <span class="status-tag status-tag--label">{{ locale_label }}</span>
                                {% endif %}
                            {% endwith %}
                        </td>
                        <td>
                            <div class="status-tag primary">
                                {{ task_state.get_status_display }}
                            </div>
                        </td>
                        <td>{{ task_state.started_at }}</td>
                        <td>{{ task_state.finished_at }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>{% blocktrans trimmed %}No pages have been submitted for moderation yet{% endblocktrans %}</p>
    {% endif %}
{% endblock %}
