table.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. {# Render an HTMX-enabled table with paginator #}
  2. {% load helpers %}
  3. {% load buttons %}
  4. {% load render_table from django_tables2 %}
  5. <div class="htmx-container table-responsive">
  6. {% with preferences|get_key:"pagination.placement" as paginator_placement %}
  7. {% if paginator_placement == 'top' or paginator_placement == 'both' %}
  8. {% include 'inc/paginator.html' with htmx=True table=table paginator=table.paginator page=table.page placement='top' %}
  9. {% endif %}
  10. {% render_table table 'inc/table_htmx.html' %}
  11. {% if paginator_placement != 'top' %}
  12. {% include 'inc/paginator.html' with htmx=True table=table paginator=table.paginator page=table.page %}
  13. {% endif %}
  14. {% endwith %}
  15. </div>
  16. {% if request.htmx %}
  17. {# Include the updated object count for display elsewhere on the page #}
  18. {% if not table.embedded %}
  19. <div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
  20. {% endif %}
  21. {# Include the updated "save" link for the table configuration #}
  22. {% if table.config_params and not table.embedded %}
  23. <a class="dropdown-item" hx-swap-oob="outerHTML:#table_save_link" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
  24. {% endif %}
  25. {# Update the bulk action buttons with new query parameters #}
  26. {% if actions and not table.embedded %}
  27. <div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
  28. {% action_buttons actions model multi=True %}
  29. </div>
  30. {% endif %}
  31. {% endif %}