object_list.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. {% extends 'base/layout.html' %}
  2. {% load buttons %}
  3. {% load helpers %}
  4. {% load render_table from django_tables2 %}
  5. {% load static %}
  6. {% comment %}
  7. Blocks:
  8. extra_controls: Additional action buttons
  9. bulk_buttons: Additional bulk action buttons to display beneath the objects
  10. list
  11. Context:
  12. model: The model class being listed
  13. table: The table class used for rendering the list of objects
  14. actions: A list of buttons to display. This template checks for add, import,
  15. export, bulk_edit, and bulk_delete.
  16. filter_form: The bound filterset form for filtering the objects list (optional)
  17. return_url: Return URL to use for bulk actions (optional)
  18. {% endcomment %}
  19. {% block title %}{{ model|meta:"verbose_name_plural"|bettertitle }}{% endblock %}
  20. {% block controls %}
  21. <div class="controls">
  22. <div class="control-group">
  23. {% block extra_controls %}{% endblock %}
  24. {% if 'add' in actions %}
  25. {% add_button model %}
  26. {% endif %}
  27. {% if 'import' in actions %}
  28. {% import_button model %}
  29. {% endif %}
  30. {% if 'export' in actions %}
  31. {% export_button model %}
  32. {% endif %}
  33. </div>
  34. </div>
  35. {% endblock controls %}
  36. {% block tabs %}
  37. <ul class="nav nav-tabs px-3">
  38. <li class="nav-item" role="presentation">
  39. <button 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">
  40. Results {% badge table.page.paginator.count %}
  41. </button>
  42. </li>
  43. {% if filter_form %}
  44. <li class="nav-item" role="presentation">
  45. <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">
  46. Filters
  47. {% if filter_form %}{% badge filter_form.changed_data|length bg_color="primary" %}{% endif %}
  48. </button>
  49. </li>
  50. {% endif %}
  51. </ul>
  52. {% endblock tabs %}
  53. {% block content-wrapper %}
  54. <div class="tab-content">
  55. {# Object list #}
  56. <div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
  57. {# Applied filters #}
  58. {% if filter_form %}
  59. {% applied_filters filter_form request.GET %}
  60. {% endif %}
  61. <form method="post" class="form form-horizontal">
  62. {% csrf_token %}
  63. {# "Select all" form #}
  64. {% if table.paginator.num_pages > 1 %}
  65. <div id="select-all-box" class="d-none card noprint">
  66. <div class="form col-md-12">
  67. <div class="card-body">
  68. <div class="float-end">
  69. {% if 'bulk_edit' in actions %}
  70. {% bulk_edit_button model query_params=request.GET %}
  71. {% endif %}
  72. {% if 'bulk_delete' in actions %}
  73. {% bulk_delete_button model query_params=request.GET %}
  74. {% endif %}
  75. </div>
  76. <div class="form-check">
  77. <input type="checkbox" id="select-all" name="_all" class="form-check-input" />
  78. <label for="select-all" class="form-check-label">
  79. Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> matching query
  80. </label>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. {% endif %}
  86. {# Object table controls #}
  87. {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %}
  88. <div class="form form-horizontal">
  89. {% csrf_token %}
  90. <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  91. {# Object table #}
  92. {% if prerequisite_model %}
  93. {% include 'inc/missing_prerequisites.html' %}
  94. {% endif %}
  95. <div class="card">
  96. <div class="card-body" id="object_list">
  97. {% include 'htmx/table.html' %}
  98. </div>
  99. </div>
  100. {# Form buttons #}
  101. <div class="noprint bulk-buttons">
  102. <div class="bulk-button-group">
  103. {% block bulk_buttons %}
  104. {% if 'bulk_edit' in actions %}
  105. {% bulk_edit_button model query_params=request.GET %}
  106. {% endif %}
  107. {% if 'bulk_delete' in actions %}
  108. {% bulk_delete_button model query_params=request.GET %}
  109. {% endif %}
  110. {% endblock %}
  111. </div>
  112. </div>
  113. </div>
  114. </form>
  115. </div>
  116. {# Filter form #}
  117. {% if filter_form %}
  118. <div class="tab-pane show" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab">
  119. {% include 'inc/filter_list.html' %}
  120. </div>
  121. {% endif %}
  122. </div>
  123. {% endblock content-wrapper %}
  124. {% block modals %}
  125. {% table_config_form table table_name="ObjectTable" %}
  126. {% endblock modals %}