{% load i18n %}
{% load wagtailadmin_tags %}
<table class="listing{% if full_width %} full-width{% endif %}{% if moving or choosing %} chooser{% endif %}">
    {% if orderable %}
        <col width="50px" />
    {% endif %}
    <col />
    {% if show_parent %}
        <col />
    {% endif %}
    <col width="12%" />
    <col width="12%" />
    <col width="12%" />
    <col width="10%" />
    <thead>
        {% if moving or choosing %}
            <tr class="table-headers">
                {% if orderable %}
                    <th></th>
                {% endif %}
                <th class="title">Title</th>
                {% if show_parent %}
                    <th class="parent">{% trans 'Parent' %}</th>
                {% endif %}
                <th class="updated">{% trans 'Updated' %}</th>
                <th class="type">{% trans 'Type' %}</th>
                <th class="status">{% trans 'Status' %}</th>
                <th></th>
            </tr>
        {% endif %}
        {% if parent_page %}
            {% page_permissions parent_page as parent_page_perms %}
            <tr class="index {% if not parent_page.live %} unpublished{% endif %} {% if moving or choosing %}{% if parent_page.can_choose %}can-disabled{% endif %}{% endif %}">
                <td class="title" {% if orderable %}colspan="2"{% endif %}>
                    {% if moving %}
                        {% include "wagtailadmin/pages/listing/_page_title_move.html" with page=parent_page %}
                    {% elif choosing %}
                        {% include "wagtailadmin/pages/listing/_page_title_choose.html" with page=parent_page %}
                    {% else %}
                        {% include "wagtailadmin/pages/listing/_parent_page_title_explore.html" %}
                    {% endif %}
                </td>
                <td class="updated" valign="bottom">{% if parent_page.latest_revision_created_at %}<div class="human-readable-date" title="{{ parent_page.latest_revision_created_at|date:"d M Y H:i" }}">{{ parent_page.latest_revision_created_at|timesince }} ago</div>{% endif %}</td>
                <td class="type" valign="bottom">{{ parent_page.content_type.model_class.get_verbose_name }}</td>
                <td class="status" valign="bottom">
                    {% if not choosing and not moving and parent_page.live and not parent_page.is_root and 'view_live' not in hide_actions|default:'' %}
                        <a href="{{ parent_page.url }}" target="_blank" class="status-tag {% if parent_page.status_string != "draft" %}primary{% endif %}">{{ parent_page.status_string|capfirst }}</a>
                    {% else %}
                        <span class="status-tag {% if parent_page.status_string != "draft" %}primary{% endif %}">{{ parent_page.status_string|capfirst }}</span>
                    {% endif %}
                </td>
                <td></td>
            </tr>
        {% endif %}
    
        {% if not moving and not choosing %}
            {% include "wagtailadmin/pages/listing/_table_headers_explore.html" %}
        {% endif %}
    </thead>
    <tbody>
        {% if pages %}
            {% for page in pages %}
                {% page_permissions page as page_perms %}
                <tr {% if ordering == "ord" %}id="page_{{ page.id }}" data-page-title="{{ page.title }}"{% endif %} class="{% if not page.live %} unpublished{% endif %}{% if moving or choosing %}{% if not page.can_choose %}disabled{% endif %}{% endif %}">
                    {% if orderable %}
                        <td class="ord">{% if ordering == "ord" %}<div class="handle icon icon-grip text-replace">{% trans 'Drag' %}</div>{% endif %}</td>
                    {% endif %}
                    <td class="title" valign="top">
                        {% if moving %}
                            {% include "wagtailadmin/pages/listing/_page_title_move.html" with page=page %}
                        {% elif choosing %}
                            {% include "wagtailadmin/pages/listing/_page_title_choose.html" with page=page %}
                        {% else %}
                            {% include "wagtailadmin/pages/listing/_page_title_explore.html" %}
                        {% endif %}
                    </td>
                    {% if show_parent %}
                        {% with page.get_parent as parent %}
                            <td class="parent" valign="top">
                                {% if parent %}
                                    <a href="{% url 'wagtailadmin_explore' parent.id %}">{{ parent.title }}</a>
                                {% endif %}
                            </td>
                        {% endwith %}
                    {% endif %}
                    <td class="updated" valign="top">{% if page.latest_revision_created_at %}<div class="human-readable-date" title="{{ page.latest_revision_created_at|date:"d M Y H:i" }}">{{ page.latest_revision_created_at|timesince }} ago</div>{% endif %}</td>
                    <td class="type" valign="top">{{ page.content_type.model_class.get_verbose_name }}</td>
                    <td class="status" valign="top">
                        {% if not choosing and not moving and page.live and 'view_live' not in hide_actions|default:'' %}
                             <a href="{{ page.url }}" target="_blank" class="status-tag {% if page.status_string != "draft" %}primary{% endif %}">{{ page.status_string }}</a>
                        {% else %}
                             <span class="status-tag {% if page.status_string != "draft" %}primary{% endif %}">{{ page.status_string }}</span>
                        {% endif %}
                    </td>
                    {% if moving %}
                        {% include "wagtailadmin/pages/listing/_navigation_move.html" %}
                    {% elif choosing %}
                        {% include "wagtailadmin/pages/listing/_navigation_choose.html" %}
                    {% else %}
                        {% include "wagtailadmin/pages/listing/_navigation_explore.html" %}
                    {% endif %}
                </tr>
            {% endfor %}
        {% else %}
            {% url 'wagtailadmin_pages_add_subpage' parent_page.id as add_page_url%}
            <tr><td colspan="3" class="no-results-message"><p>{% trans "No pages have been created." %}{% if parent_page and parent_page_perms.can_add_subpage %} {% blocktrans %}Why not <a href="{{ add_page_url }}">add one</a>?{% endblocktrans %}{% endif %}</td></tr>
        {% endif %}
    </tbody>
</table>

{% if parent_page and pages and pages.paginator %}
    <div class="pagination">
        <p>{% blocktrans with page_number=pages.number num_pages=pages.paginator.num_pages%}
            Page {{ page_number }} of {{ num_pages }}.
        {% endblocktrans %}</p>
        <ul>
            <li class="prev">
                {% if pages.has_previous %}
                    <a href="{% url 'wagtailadmin_explore' parent_page.id %}?p={{ pages.previous_page_number }}{% if ordering %}&amp;ordering={{ ordering }}{% endif %}" class="icon icon-arrow-left">{% trans "Previous" %}</a>
                {% endif %}
            </li>
            <li class="next">
                {% if pages.has_next %}
                    <a href="{% url 'wagtailadmin_explore' parent_page.id %}?p={{ pages.next_page_number }}{% if ordering %}&amp;ordering={{ ordering }}{% endif %}" class="icon icon-arrow-right-after">{% trans 'Next' %}</a>
                {% endif %}
            </li>
        </ul>
    </div>
{% endif %}
