{% extends 'generic/object.html' %}
{% load render_table from django_tables2 %}
{% load helpers %}
{% load static %}

{% block content %}
  {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %}
  
  <form method="post">
    {% csrf_token %}

    <div class="card">
      <div class="card-body htmx-container table-responsive" id="object_list">
        {% include 'htmx/table.html' %}
      </div>
    </div>

    <div class="noprint bulk-buttons">
      <div class="bulk-button-group">
        {% if 'bulk_edit' in actions %}
          <div class="btn-group" role="group">
            <button type="submit" name="_edit" formaction="{% url url_bulk_edit %}?{{parent_name}}={{ object.pk }}&return_url={% url url_parent pk=object.pk %}" class="btn btn-warning btn-sm">
              <i class="mdi mdi-pencil" aria-hidden="true"></i> Edit
            </button>
          </div>
        {% endif %}
        <div class="btn-group" role="group">
          {% if 'bulk_delete' in actions %}
            <button type="submit" name="_delete" formaction="{% url url_bulk_delete %}?return_url={% url url_parent pk=object.pk %}" class="btn btn-danger btn-sm">
              <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete
            </button>
          {% endif %}
        </div>
      </div>
      {% if 'add' in actions %}
        <div class="bulk-button-group">
          <a href="{% url url_add %}?{{parent_name}}={{ object.pk }}&return_url={% url url_parent pk=object.pk %}" class="btn btn-sm btn-primary">
            <i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add
          </a>
        </div>
      {% endif %}
    </div>
  </form>
{% endblock %}

{% block modals %}
  {{ block.super }}
  {% table_config_form table table_name="ObjectTable"%}
{% endblock modals %}