object_list.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {% extends 'generic/_base.html' %}
  2. {% load buttons %}
  3. {% load helpers %}
  4. {% load plugins %}
  5. {% load render_table from django_tables2 %}
  6. {% load static %}
  7. {% load i18n %}
  8. {% comment %}
  9. Blocks:
  10. - title: Page title
  11. - controls: Control elements displayed between the header and content
  12. - extra_controls: Any additional action buttons to display
  13. - tabs: Page tabs
  14. - content: Primary page content
  15. - bulk_buttons: Additional bulk action buttons to display beneath the objects list
  16. - modals: Any pre-loaded modals
  17. Context:
  18. - model: The model class being listed
  19. - table: The table class used for rendering the list of objects
  20. - actions: A list of buttons to display. This template checks for add, import, export,
  21. bulk_edit, and bulk_delete.
  22. - filter_form: The bound filterset form for filtering the objects list (optional)
  23. - return_url: Return URL to use for bulk actions (optional)
  24. {% endcomment %}
  25. {% block title %}{{ model|meta:"verbose_name_plural"|bettertitle }}{% endblock %}
  26. {% block controls %}
  27. <div class="btn-list">
  28. {% plugin_list_buttons model %}
  29. {% block extra_controls %}{% endblock %}
  30. {% action_buttons actions model %}
  31. </div>
  32. {% endblock controls %}
  33. {% block tabs %}
  34. <ul class="nav nav-tabs" role="tablist">
  35. <li class="nav-item" role="presentation">
  36. <a class="nav-link active" id="object-list-tab" data-bs-toggle="tab" data-bs-target="#object-list" type="button" role="tab" aria-controls="edit-form" aria-selected="true">
  37. {% trans "Results" %}
  38. <span class="badge text-bg-secondary total-object-count">{% if table.page.paginator.count %}{{ table.page.paginator.count }}{% else %}{{ total_count|default:"0" }}{% endif %}</span>
  39. </a>
  40. </li>
  41. {% if filter_form %}
  42. <li class="nav-item" role="presentation">
  43. <button class="nav-link" id="filters-form-tab" data-bs-toggle="tab" data-bs-target="#filters-form" type="button" role="tab" aria-controls="object-list" aria-selected="false">
  44. {% trans "Filters" %}
  45. {% if filter_form %}{% badge filter_form.changed_data|length bg_color="primary" %}{% endif %}
  46. </button>
  47. </li>
  48. {% endif %}
  49. </ul>
  50. {% endblock tabs %}
  51. {% block content %}
  52. {# Object list tab #}
  53. <div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
  54. {# Applied filters #}
  55. {% if filter_form %}
  56. {% applied_filters model filter_form request.GET %}
  57. {% endif %}
  58. {# Object table controls #}
  59. {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %}
  60. <form method="post" class="form form-horizontal">
  61. {% csrf_token %}
  62. {# "Select all" form #}
  63. {% if table.paginator.num_pages > 1 %}
  64. <div id="select-all-box" class="d-none card d-print-none">
  65. <div class="form col-md-12">
  66. <div class="card-body d-flex justify-content-between">
  67. <div class="form-check">
  68. <input type="checkbox" id="select-all" name="_all" class="form-check-input" />
  69. <label for="select-all" class="form-check-label">
  70. {% blocktrans trimmed with count=table.page.paginator.count object_type_plural=table.data.verbose_name_plural %}
  71. Select <strong>all <span class="total-object-count">{{ count }}</span> {{ object_type_plural }}</strong> matching query
  72. {% endblocktrans %}
  73. </label>
  74. </div>
  75. <div class="btn-list bulk-action-buttons">
  76. {% action_buttons actions model multi=True %}
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. {% endif %}
  82. <div class="form form-horizontal">
  83. <input type="hidden" id="object-list-return-url" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  84. {# Warn of any missing prerequisite objects #}
  85. {% if prerequisite_model %}
  86. {% include 'inc/missing_prerequisites.html' %}
  87. {% endif %}
  88. {# Objects table #}
  89. <div class="card">
  90. <div class="htmx-container table-responsive" id="object_list">
  91. {% include 'htmx/table.html' %}
  92. </div>
  93. </div>
  94. {# /Objects table #}
  95. {# Form buttons #}
  96. <div class="card btn-list sticky-actions d-print-none" data-sticky-position="right" data-sticky-when="selection">
  97. {% block bulk_buttons %}
  98. <div class="btn-list bulk-action-buttons">
  99. {% action_buttons actions model multi=True %}
  100. </div>
  101. {% endblock %}
  102. </div>
  103. {# /Form buttons #}
  104. </div>
  105. </form>
  106. </div>
  107. {# /Object list tab #}
  108. {# Filters tab #}
  109. {% if filter_form %}
  110. <div class="tab-pane show" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab">
  111. {% include 'inc/filter_list.html' %}
  112. </div>
  113. {% endif %}
  114. {# /Filters tab #}
  115. {% endblock content %}
  116. {% block modals %}
  117. {% table_config_form table table_name="ObjectTable" %}
  118. {% endblock modals %}