object_list.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {% extends 'base/layout.html' %}
  2. {% load buttons %}
  3. {% load helpers %}
  4. {% load render_table from django_tables2 %}
  5. {% load static %}
  6. {% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}
  7. {% block controls %}
  8. <div class="controls mb-2 mx-0">
  9. <div class="d-flex flex-wrap justify-content-end">
  10. {% block extra_controls %}{% endblock %}
  11. {% if permissions.add and 'add' in action_buttons %}
  12. {% add_button content_type.model_class|validated_viewname:"add" %}
  13. {% endif %}
  14. {% if permissions.add and 'import' in action_buttons %}
  15. {% import_button content_type.model_class|validated_viewname:"import" %}
  16. {% endif %}
  17. {% if 'export' in action_buttons %}
  18. {% export_button content_type %}
  19. {% endif %}
  20. </div>
  21. </div>
  22. {% endblock controls %}
  23. {% block content %}
  24. {% if table.paginator.num_pages > 1 %}
  25. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  26. <div id="select-all-box" class="d-none card noprint">
  27. <form method="post" class="form col-md-12">
  28. {% csrf_token %}
  29. <div class="card-body">
  30. <div class="float-end">
  31. {% if bulk_edit_url and permissions.change %}
  32. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm" disabled>
  33. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit All
  34. </button>
  35. {% endif %}
  36. {% if bulk_delete_url and permissions.delete %}
  37. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm" disabled>
  38. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete All
  39. </button>
  40. {% endif %}
  41. </div>
  42. <div class="form-check">
  43. <input type="checkbox" id="select-all" name="_all" class="form-check-input" />
  44. <label for="select-all" class="form-check-label">
  45. Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> matching query
  46. </label>
  47. </div>
  48. </div>
  49. </form>
  50. </div>
  51. {% endwith %}
  52. {% endif %}
  53. {# Object table #}
  54. <div class="row">
  55. <div class="col col-md-7 col-lg-8 col-xl-9 col-xxl-10">
  56. {# Object list filter, table config #}
  57. {% include 'inc/table_controls.html' with table_modal="ObjectTable_config" %}
  58. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  59. {% if permissions.change or permissions.delete %}
  60. <form method="post" class="form form-horizontal">
  61. {% csrf_token %}
  62. <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  63. <div class="table-responsive">
  64. {% render_table table 'inc/table.html' %}
  65. </div>
  66. <div class="noprint bulk-buttons">
  67. <div class="bulk-button-group">
  68. {% block bulk_buttons %}{% endblock %}
  69. {% if bulk_edit_url and permissions.change %}
  70. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
  71. <i class="mdi mdi-pencil" aria-hidden="true"></i> Edit Selected
  72. </button>
  73. {% endif %}
  74. {% if bulk_delete_url and permissions.delete %}
  75. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
  76. <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete Selected
  77. </button>
  78. {% endif %}
  79. </div>
  80. </div>
  81. </form>
  82. {% else %}
  83. <div class="table-responsive">
  84. {% render_table table 'inc/table.html' %}
  85. </div>
  86. {% endif %}
  87. {% endwith %}
  88. {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
  89. </div>
  90. {% if filter_form %}
  91. {% include 'inc/filter_list.html' %}
  92. {% endif %}
  93. </div>
  94. {% table_config_form table table_name="ObjectTable" %}
  95. {% endblock content %}