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

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

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

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li>
            <a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a>
            <span class="divider">/</span>
        </li>
        <li class="active">{% trans "Pages" %}</li>
    </ul>
{% endblock %}

{% block header %}
    <div class="page-header">
        <a href="{% url 'dashboard:page-create' %}" class="btn btn-primary btn-large pull-right"><i class="icon-plus"></i> {% trans "Create new page" %}</a>
        <h1>{% trans "Page Management" %}</h1>
    </div>
{% endblock header %}

{% block dashboard_content %}
    <div class="table-header">
        <h3><i class="icon-search icon-large"></i>{% trans "Search" %}</h3>
    </div>
    <div class="well">
        <form action="." method="get" class="form-inline">
            {% include "partials/form_fields_inline.html" with form=form %}
            <button type="submit" class="btn btn-primary">{% trans "Search" %}</button>
            <a href="{% url 'dashboard:page-list' %}" class="btn">{% trans "Reset" %}</a>
        </form>
    </div>

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


    {% if flatpage_list %}
        <form action="." method="post">
            {% csrf_token %}
            <table class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th>{% trans "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="btn-group">
                                        <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                                            {% trans "Actions" %}
                                            <span class="caret"></span>
                                        </a>
                                        <ul class="dropdown-menu pull-right">
                                            <li><a href="{{ page.get_absolute_url }}">{% trans "View" %}</a></li>
                                            <li><a id="edit_page_{{ page.id }}" href="{% url 'dashboard:page-update' pk=page.id %}">{% trans "Edit" %}</a></li>
                                            <li><a id="delete_page_{{ page.id }}" href="{% url 'dashboard:page-delete' pk=page.id %}">{% trans "Delete" %}</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% include "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 %}

{% block onbodyload %}
    {{ block.super }}
    oscar.dashboard.search.init();
{% endblock onbodyload %}
