object_list.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. {% extends '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 %}
  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 class="row mb-3">
  27. <form method="post" class="form col-md-12">
  28. {% csrf_token %}
  29. <div id="select-all-box" class="d-none card noprint">
  30. <div class="card-body d-inline-flex justify-content-between align-items-center">
  31. <div class="form-check">
  32. <input type="checkbox" id="select-all" name="_all" class="form-check-input" />
  33. <label for="select-all" class="form-check-label">
  34. Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> Matching Query
  35. </label>
  36. </div>
  37. <div class="float-end">
  38. {% if bulk_edit_url and permissions.change %}
  39. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm" disabled>
  40. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit All
  41. </button>
  42. {% endif %}
  43. {% if bulk_delete_url and permissions.delete %}
  44. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm" disabled>
  45. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete All
  46. </button>
  47. {% endif %}
  48. </div>
  49. </div>
  50. </div>
  51. </form>
  52. </div>
  53. {% endwith %}
  54. {% endif %}
  55. <div class="row mb-3">
  56. <div class="{% if filter_form %}col-9{% else %}col-12{% endif %}">
  57. <div class="card">
  58. <div class="card-header">
  59. <div class="float-end col-md-2 noprint table-controls">
  60. <div class="input-group input-group-sm">
  61. <input type="text" class="form-control object-filter" placeholder="Filter" title="Filter text (regular expressions supported)" />
  62. {% if request.user.is_authenticated and table_config_form %}
  63. <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#ObjectTable_config" title="Configure Table">
  64. <i class="mdi mdi-table-eye"></i>
  65. </button>
  66. {% endif %}
  67. </div>
  68. </div>
  69. </div>
  70. <div class="card-body">
  71. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  72. {% if permissions.change or permissions.delete %}
  73. <form method="post" class="form form-horizontal">
  74. {% csrf_token %}
  75. <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  76. {% include table_template|default:'responsive_table.html' %}
  77. <div class="float-start noprint bulk-buttons">
  78. {% block bulk_buttons %}{% endblock %}
  79. {% if bulk_edit_url and permissions.change %}
  80. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
  81. <i class="mdi mdi-pencil" aria-hidden="true"></i> Edit Selected
  82. </button>
  83. {% endif %}
  84. {% if bulk_delete_url and permissions.delete %}
  85. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
  86. <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete Selected
  87. </button>
  88. {% endif %}
  89. </div>
  90. </form>
  91. {% else %}
  92. {% include table_template|default:'responsive_table.html' %}
  93. {% endif %}
  94. {% endwith %}
  95. {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
  96. </div>
  97. </div>
  98. </div>
  99. {% if filter_form %}
  100. <div class="col-3 noprint">
  101. {% block sidebar %}{% endblock %}
  102. {% include 'inc/search_panel.html' %}
  103. </div>
  104. {% endif %}
  105. </div>
  106. {% table_config_form table table_name="ObjectTable" %}
  107. {% endblock %}