{% load i18n cms_admin admin_urls %}

{# INFO: columns are defined in base.html options #}
{% spaceless %}
<li class="cms-tree-node {{ css_class }}
    {% if page.pk in open_nodes %} jstree-open{% elif children %} jstree-closed{% endif %}
    {% if page.reverse_id == 'page_types' %} cms-tree-node-pagetype{% endif %}
    {% if page.level == 0 %} cms-tree-node-top{% endif %}
    {% if filtered %} cms-tree-node-filtered{% endif %}
    {% if has_add_permission %} cms-tree-node-root-allow-children{% endif %}
    "
    {% if is_popup %}onclick="opener.dismissRelatedLookupPopup(window, {{ page.id }}); return false;"{% endif %}
    data-id="{{ page.pk }}"
    data-slug="{{ page.get_slug }}"
    data-move-permission="{{ has_move_page_permission|yesno:"true,false" }}"
    data-add-permission="{{ has_add_page_permission|yesno:"true,false" }}"
    data-colview='
        <div class="cms-tree-col">
            <div class="cms-tree-item-wrapper">
                {% if page.is_home %}
                    <div class="cms-tree-item cms-tree-item-icons">
                        <div class="cms-tree-item-inner">
                            <div class="cms-hover-tooltip cms-hover-tooltip-left cms-hover-tooltip-delay"
                                data-cms-tooltip="{% filter escapejs %}{% trans 'Home' %}{% endfilter %}">
                                <span class="cms-icon cms-icon-home"></span>
                            </div>
                        </div>
                    </div>
                {% endif %}
                {% if page.soft_root %}
                    <div class="cms-tree-item cms-tree-item-icons">
                        <div class="cms-tree-item-inner">
                            <div class="cms-hover-tooltip cms-hover-tooltip-left cms-hover-tooltip-delay"
                                data-cms-tooltip="{% filter escapejs %}{% trans 'Softroot' %}{% endfilter %}">
                                <a href="{% url 'admin:cms_page_advanced' page.id %}">
                                    <span class="cms-icon cms-icon-sitemap"></span>
                                </a>
                            </div>
                        </div>
                    </div>
                {% endif %}
                {% if page.application_urls %}
                    <div class="cms-tree-item cms-tree-item-icons">
                        <div class="cms-tree-item-inner">
                            <div class="cms-hover-tooltip cms-hover-tooltip-left cms-hover-tooltip-delay"
                                data-cms-tooltip="{% filter escapejs %}{% blocktrans with page.application_urls as apphook%}Application: {{ apphook }}{% endblocktrans %}{% endfilter %}">
                                <a href="{% url 'admin:cms_page_advanced' page.id %}">
                                    <span class="cms-icon cms-icon-puzzle"></span>
                                </a>
                            </div>
                        </div>
                    </div>
                {% endif %}
            </div>
        </div>
    '
    data-colpreview='
        <div class="cms-tree-col">
            <div class="cms-tree-item cms-tree-item-preview

            </div>
        </div>
    '

    data-coloptions='
        <div class="cms-tree-col cms-tree-col-padding-sm">
            <div class="cms-tree-item-wrapper">


                <div class="js-cms-pagetree-actions-dropdown cms-tree-item cms-tree-item-button cms-pagetree-dropdown js-cms-pagetree-dropdown" data-lazy-url="{% url 'admin:cms_page_actions_menu' page.id %}">
                    <a data-id="{{ page.pk }}" href="#" class="js-cms-pagetree-dropdown-trigger js-cms-pagetree-options cms-pagetree-dropdown-trigger cms-btn cms-btn-default cms-btn-no-border cms-icon cms-icon-menu">
                        <span class="sr-only">{% filter escapejs %}{% trans "Options" %}{% endfilter %}</span>
                    </a>

                    <div class="js-cms-pagetree-dropdown-menu cms-pagetree-dropdown-menu cms-pagetree-dropdown-menu-arrow-right-top">
                        <div class="js-cms-pagetree-dropdown-loader cms-pagetree-dropdown-loader">
                        </div>

                        <ul class="cms-pagetree-dropdown-menu-inner">
                            <li>
                                <a class="cms-pagetree-dropdown-item-disabled" href="#" title="{% filter escapejs %}{% trans 'Delete' %}{% endfilter %}">
                                    <span class="cms-icon cms-icon-bin"></span>
                                    <span>{% filter escapejs %}{% trans 'Delete' %}...{% endfilter %}</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    '
    >

    <span class="cms-icon cms-icon-bin"></span>

    {% language LANGUAGE_CODE %}
        {{ page.get_admin_tree_title }}
    {% endlanguage %}

    {# INFO render children #}
    {% if page.pk in open_nodes and children %}
        <ul>
            {% show_admin_menu_for_pages children %}
        </ul>
    {% endif %}
</li>
{% endspaceless %}
