object_list.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {% extends 'base/layout.html' %}
  2. {% load buttons %}
  3. {% load helpers %}
  4. {% load render_table from django_tables2 %}
  5. {% load static %}
  6. {% block controls %}
  7. <div class="controls">
  8. <div class="control-group">
  9. {% block extra_controls %}{% endblock %}
  10. {% if permissions.add and 'add' in action_buttons %}
  11. {% add_button content_type.model_class|validated_viewname:"add" %}
  12. {% endif %}
  13. {% if permissions.add and 'import' in action_buttons %}
  14. {% import_button content_type.model_class|validated_viewname:"import" %}
  15. {% endif %}
  16. {% if 'export' in action_buttons %}
  17. {% export_button content_type %}
  18. {% endif %}
  19. </div>
  20. </div>
  21. {% endblock controls %}
  22. {% block tabs %}
  23. <ul class="nav nav-tabs px-3">
  24. {% block tab_items %}
  25. <li class="nav-item" role="presentation">
  26. <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">
  27. {% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}
  28. {% badge table.page.paginator.count %}
  29. </button>
  30. </li>
  31. {% if filter_form %}
  32. <li class="nav-item" role="presentation">
  33. <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">
  34. Filters
  35. {% if filter_form %}{% badge filter_form.changed_data|length %}{% endif %}
  36. </button>
  37. </li>
  38. {% endif %}
  39. {% endblock tab_items %}
  40. </ul>
  41. {% endblock tabs %}
  42. {% block content-wrapper %}
  43. <div class="tab-content">
  44. {# Object list #}
  45. <div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
  46. {% if table.paginator.num_pages > 1 %}
  47. {# "Select all" form #}
  48. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  49. <div id="select-all-box" class="d-none card noprint">
  50. <form method="post" class="form col-md-12">
  51. {% csrf_token %}
  52. <div class="card-body">
  53. <div class="float-end">
  54. {% if bulk_edit_url and permissions.change %}
  55. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm" disabled>
  56. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit All
  57. </button>
  58. {% endif %}
  59. {% if bulk_delete_url and permissions.delete %}
  60. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm" disabled>
  61. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete All
  62. </button>
  63. {% endif %}
  64. </div>
  65. <div class="form-check">
  66. <input type="checkbox" id="select-all" name="_all" class="form-check-input" />
  67. <label for="select-all" class="form-check-label">
  68. Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> matching query
  69. </label>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. {% endwith %}
  75. {% endif %}
  76. {# Object table controls #}
  77. {% include 'inc/table_controls.html' with table_modal="ObjectTable_config" %}
  78. <form method="post" class="form form-horizontal">
  79. {% csrf_token %}
  80. <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  81. {# Object table #}
  82. <div class="card">
  83. <div class="card-body">
  84. <div class="table-responsive">
  85. {% render_table table 'inc/table.html' %}
  86. </div>
  87. </div>
  88. </div>
  89. {# Form buttons #}
  90. {% if permissions.change or permissions.delete %}
  91. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  92. <div class="noprint bulk-buttons">
  93. <div class="bulk-button-group">
  94. {% block bulk_buttons %}{% endblock %}
  95. {% if bulk_edit_url and permissions.change %}
  96. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
  97. <i class="mdi mdi-pencil" aria-hidden="true"></i> Edit Selected
  98. </button>
  99. {% endif %}
  100. {% if bulk_delete_url and permissions.delete %}
  101. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
  102. <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete Selected
  103. </button>
  104. {% endif %}
  105. </div>
  106. </div>
  107. {% endwith %}
  108. {% endif %}
  109. </form>
  110. {# Paginator #}
  111. {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
  112. </div>
  113. {# Filter form #}
  114. {% if filter_form %}
  115. <div class="tab-pane show" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab">
  116. {% include 'inc/filter_list.html' %}
  117. </div>
  118. {% endif %}
  119. </div>
  120. {# Table config form #}
  121. {% table_config_form table table_name="ObjectTable" %}
  122. {% endblock content-wrapper %}