{% extends "base.html" %}
{% load mptt_tags autobreadcrumb documents_admin %}

{% block head_title %}{% current_title_from_breadcrumbs %}{% endblock %}
{% block head_more_links %}
    <link rel="stylesheet" href="{{ STATIC_URL }}documents/css/content.css" type="text/css" />
{% endblock %}

{% comment %}{% block head_more_js %}
    <script language="JavaScript" type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {
//         $(".container").click(function(event) {
//             console.log( "currentTarget: " + $(event.currentTarget).attr('class') );
//             return false;
//         });
    });
    //]]>
    </script>
{% endblock %}{% endcomment %}

{% block content %}
<h2>{% current_title_from_breadcrumbs %}</h2>

<div class="module changelist">
    <ul class="actions flat_bulletlist">
        <li class="icon add-page"><a href="{% url documents-page-add %}">Nouvelle page</a></li>
    </ul>
    <h3>Pages</h3>
    <div class="cale"></div>
    
    <ul class="list-tree-alt">{% recursetree page_list %}
        <li>
            <div class="container {% if not node.visible %}hidden{% endif %}">
                <div class="item-infos">
                    <h4><a href="{% url documents-page-edit node.slug %}">{{ node.title }}</a></h4>
                    <div class="panel">
                        <p class="tile visibility-{% if node.visible %}on{% else %}off{% endif %}"><strong>{{ node.get_visible_display }}</strong></p>
                        <p class="tile published">Publié le {{ node.modified|date:"d/m/Y H:i" }}</p>
                        {% comment %}<p class="tile template">{{ node.get_template_display }}</p>{% endcomment %}
                    </div>
                    <div class="cale"></div>
                </div>
                <div class="menu">
                    <p class="tile add-child"><a href="{% url documents-page-add-child node.slug %}" title="Créer une nouvelle page parente de celle-ci">Sous-page</a></p>
                    <p class="tile delete"><a href="{% url documents-page-delete node.slug %}" title="Supprimer définitivement cette page et sous-pages">Supprimer</a></p>
                </div>
                {% comment %}<div class="menu">
                    <p class="tile toggle-visibility-to-{% if not node.visible %}on{% else %}off{% endif %}"><a href="{% url documents-page-delete node.slug %}" title="Visibilité">Visibilité</a></p>
                    <p class="tile move-to"><a href="" title="Déplacer cette page (et ses sous pages) dans l'arborescence">Déplacer</a></p>
                </div>{% endcomment %}
                <div class="cale"></div>
            </div>
            {% if not node.is_leaf_node %}<ul class="children">{{ children }}</ul>{% endif %}
        </li>
    {% endrecursetree %}</ul>
</div>


<div class="module changelist">
    <ul class="actions flat_bulletlist">
        <li class="icon add-page"><a href="{% url documents-insert-add %}">Nouveau document insérable</a></li>
    </ul>
    <h3>Documents insérables</h3>
    <div class="cale"></div>
    
    <table>
        <thead>
            <tr>
                <th class="title-cell col-odd">Titre</th>
                <th class="slug-cell col-even">Raccourci</th>
                <th class="visible-cell col-odd">Visible</th>
                <th class="modified-cell col-even">Dernière modification</th>
                <th class="actions-cell col-odd">#</th>
            </tr>
        </thead>
        <tbody>
    {% for item in insert_list %}
            <tr id="insert-row-{{ item.id }}">
                <th class="title-cell col-odd"><a href="{% url documents-insert-edit item.slug %}">{{ item.title }}</a></th>
                <td class="slug-cell col-even">{{ item.slug }}</td>
                <td class="visible-cell col-odd">{{ item.visible }}</td>
                <td class="modified-cell col-even">{{ item.modified|date:"l d F Y à H:i"|title }}</td>
                <td class="actions-cell col-odd"><a href="{% url documents-insert-delete item.slug %}">Supprimer</a></td>
            </tr>
        </tr>
    {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}
