{% extends 'oscar/dashboard/layout.html' %}
{% load dashboard_tags %}
{% load i18n %}

{% block body_class %}{{ block.super }} pages{% endblock %}

{% block title %}
    {% trans "Pages" %} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a></li>
            <li class="breadcrumb-item active" aria-current="page">{% trans "Pages" %}</li>
        </ol>
    </nav>
{% endblock %}

{% block header %}
    <div class="page-header">
        <a href="{% url 'dashboard:page-create' %}" class="btn btn-primary float-right">
            <i class="fas fa-plus-circle"></i> {% trans "Create new page" %}
        </a>
        <h1>{% trans "Pages" %}</h1>
    </div>
{% endblock header %}

{% block dashboard_content %}
    <div class="table-header">
        <h3><i class="fas fa-search"></i> {% trans "Search" %}</h3>
    </div>
    <div class="card card-body">
        <form method="get" class="form-inline">
            {% include "oscar/dashboard/partials/form_fields_inline.html" with form=form %}
            <button type="submit" class="btn btn-primary mr-2" data-loading-text="{% trans 'Searching...' %}">
                {% trans "Search" %}
            </button>
            <a href="{% url 'dashboard:page-list' %}" class="btn btn-secondary">{% trans "Reset" %}</a>
        </form>
    </div>

    <div class="table-header">
        <h2><i class="fas fa-file"></i> {{ queryset_description }}</h2>
    </div>


    {% if flatpage_list %}
        <form method="post">
            {% csrf_token %}
            <table class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th>{% trans "Title" context "Page title" %}</th>
                        <th>{% trans "URL" %}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for page in flatpage_list %}
                        <tr>
                            <td><a href="{% url 'dashboard:page-update' pk=page.id %}">{{ page.title}}</a></td>
                            <td><a title="{% trans "View on site" %}" href="{{ page.get_absolute_url }}">{{ page.url }}</a></td>
                            <td>
                                <div class="btn-toolbar">
                                    <div class="dropdown">
                                        <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                            {% trans "Actions" %}
                                        </button>
                                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
                                            <a class="dropdown-item" href="{{ page.get_absolute_url }}">{% trans "View" %}</a>
                                            <a class="dropdown-item" id="edit_page_{{ page.id }}" href="{% url 'dashboard:page-update' pk=page.id %}">{% trans "Edit" %}</a>
                                            <a class="dropdown-item" id="delete_page_{{ page.id }}" href="{% url 'dashboard:page-delete' pk=page.id %}">{% trans "Delete" %}</a>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% include "oscar/dashboard/partials/pagination.html" %}
        </form>
    {% else %}
        <table class="table table-striped table-bordered table-hover">
            <tr><td>{% trans "No pages found." %}</td></tr>
        </table>
    {% endif %}

{% endblock dashboard_content %}
