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

{% block title %}{{ page_type_label_plural }} - Admin - {{ site_name() }}{% endblock %}

{% block admin_content %}
<div class="sk-admin-header">
    <hgroup>
        <h1>{{ page_type_label_plural }}</h1>
        <p>Manage {{ page_type_plural }}</p>
    </hgroup>
    <a href="{{ admin_type_base }}/new" role="button">New {{ page_type_label }}</a>
</div>

<table class="sk-admin-table">
    <thead>
        <tr>
            <th>Order</th>
            <th>Title</th>
            <th>Slug</th>
            <th>Status</th>
            <th>Created</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        {% for page in pages %}
        <tr>
            <td class="sk-text-muted">{{ page.order }}</td>
            <td>
                <a href="/{{ page.slug }}">{{ page.title }}</a>
            </td>
            <td class="sk-text-muted">/{{ page.slug }}</td>
            <td>
                {% if page.is_published %}
                    {% if page.publish_at and page.publish_at > now() %}
                        <span class="sk-status-badge sk-status-scheduled">Scheduled</span>
                        <small class="sk-text-muted">{{ page.publish_at.strftime('%b %d, %Y %H:%M') }}</small>
                    {% else %}
                        <span class="sk-status-badge sk-status-published">Published</span>
                    {% endif %}
                {% else %}
                    <span class="sk-status-badge sk-status-draft">Draft</span>
                {% endif %}
            </td>
            <td>{{ page.created_at.strftime('%Y-%m-%d') }}</td>
            <td class="sk-actions-cell">
                <a href="{{ admin_type_base }}/{{ page.id }}/edit" role="button" class="sk-btn-outline sk-btn-small">Edit</a>
                {% if page.is_published %}
                <form method="post" action="{{ admin_type_base }}/{{ page.id }}/unpublish" class="sk-inline-form">
                    <button type="submit" class="sk-btn-outline sk-btn-small">Unpublish</button>
                </form>
                {% else %}
                <form method="post" action="{{ admin_type_base }}/{{ page.id }}/publish" class="sk-inline-form">
                    <button type="submit" class="sk-btn-outline sk-btn-small">Publish</button>
                </form>
                {% endif %}
                <form method="post" action="{{ admin_type_base }}/{{ page.id }}/delete" class="sk-inline-form" onsubmit="return confirm('Are you sure you want to delete this {{ page_type_name }}?');">
                    <button type="submit" class="sk-btn-outline sk-btn-small sk-btn-danger">Delete</button>
                </form>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>

{% if not pages %}
<p class="sk-no-items">No {{ page_type_plural }} found.</p>
{% endif %}
{% endblock %}
