{% extends "admin/change_list.html" %}
{% load admin_list %}
{% load i18n %}
{% load treenode_admin %}
{% load static %}

{% block content %}

  {% block object-tools %}
    {% if has_add_permission %}
      <ul class="object-tools">
        {% block object-tools-items %}
          {{ block.super }}
          <li><a href="import/" class="button">Import</a></li>
          <li><a href="export/" class="button">Export</a></li>
        {% endblock %}
      </ul>
    {% endif %}
  {% endblock %}
  
  <div id="changelist" class="module filtered">
    <div class="changelist-form-container">

      {# Search bar + expand/collapse buttons #}
      {% block search %}
        <div id="toolbar">
          <form id="changelist-search" method="get" role="search">
            <label for="searchbar">
              <img src="{% static 'admin/img/search.svg' %}" alt="{% translate 'Search' %}">
            </label>
            <input type="text" size="40" name="q" value="{{ cl.query }}" id="searchbar">
            <input type="submit" value="{% translate 'Search' %}">
            <button type="button" class="button treenode-button treenode-expand-all">
              {% trans "Expand All" %}
            </button>
            <button type="button" class="button treenode-button treenode-collapse-all">
              {% trans "Collapse All" %}
            </button>
          </form>
        </div>
      {% endblock %}

      {# Form with list and actions #}
      <form id="changelist-form" method="post" {% if cl.formset or action_form %} enctype="multipart/form-data"{% endif %}>
        {% csrf_token %}

        {% if action_form and actions_on_top and cl.show_admin_actions %}
          {% admin_actions %}
        {% endif %}

        {% block result_list %}
          {% tree_result_list cl %}
        {% endblock %}

        {% if action_form and actions_on_bottom and cl.show_admin_actions %}
          {% admin_actions %}
        {% endif %}

        {% block pagination %}
          {{ block.super }}
        {% endblock %}
      </form>
    </div>

    {# 📎 Боковая панель фильтров #}
    {% block filters %}
      {{ block.super }}
    {% endblock %}
  </div>
{% endblock %}

