object_list.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {% extends 'layout.html' %}
  2. {% load buttons %}
  3. {% load helpers %}
  4. {% load static %}
  5. {% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}
  6. {% block controls %}
  7. <div class="container mb-2 mx-0">
  8. <div class="d-flex flex-wrap justify-content-end">
  9. {% if permissions.add and 'add' in action_buttons %}
  10. {% add_button content_type.model_class|validated_viewname:"add" %}
  11. {% endif %}
  12. {% if permissions.add and 'import' in action_buttons %}
  13. {% import_button content_type.model_class|validated_viewname:"import" %}
  14. {% endif %}
  15. {% if 'export' in action_buttons %}
  16. {% export_button content_type %}
  17. {% endif %}
  18. <div class="d-flex flex-shrink-1">
  19. {% if request.user.is_authenticated and table_config_form %}
  20. <button
  21. type="button"
  22. class="btn btn-sm btn-outline-secondary m-1"
  23. data-toggle="modal" data-target="#ObjectTable_config"
  24. title="Configure table"
  25. >
  26. <i class="bi bi-sliders"></i>
  27. </button>
  28. {% endif %}
  29. </div>
  30. </div>
  31. </div>
  32. {% endblock %}
  33. {% block content %}
  34. <div class="row mb-3">
  35. <div class="col-9">
  36. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  37. {% if permissions.change or permissions.delete %}
  38. <form method="post" class="form form-horizontal">
  39. {% csrf_token %}
  40. <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  41. {% if table.paginator.num_pages > 1 %}
  42. <div id="select_all_box" class="hidden panel panel-default noprint">
  43. <div class="panel-body">
  44. <div class="checkbox-inline">
  45. <label for="select_all">
  46. <input type="checkbox" id="select_all" name="_all" />
  47. Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> matching query
  48. </label>
  49. </div>
  50. <div class="pull-right">
  51. {% if bulk_edit_url and permissions.change %}
  52. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm" disabled="disabled">
  53. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit All
  54. </button>
  55. {% endif %}
  56. {% if bulk_delete_url and permissions.delete %}
  57. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm" disabled="disabled">
  58. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete All
  59. </button>
  60. {% endif %}
  61. </div>
  62. </div>
  63. </div>
  64. {% endif %}
  65. {% include table_template|default:'responsive_table.html' %}
  66. <div class="noprint bulk-buttons">
  67. {% block bulk_buttons %}{% endblock %}
  68. {% if bulk_edit_url and permissions.change %}
  69. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
  70. <i class="bi bi-pencil-fill" aria-hidden="true"></i> Edit Selected
  71. </button>
  72. {% endif %}
  73. {% if bulk_delete_url and permissions.delete %}
  74. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
  75. <i class="bi bi-trash-fill" aria-hidden="true"></i> Delete Selected
  76. </button>
  77. {% endif %}
  78. </div>
  79. </form>
  80. {% else %}
  81. {% include table_template|default:'responsive_table.html' %}
  82. {% endif %}
  83. {% endwith %}
  84. {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
  85. <div class="clearfix"></div>
  86. </div>
  87. {% if filter_form %}
  88. <div class="col-3 noprint">
  89. {% block sidebar %}{% endblock %}
  90. {% include 'inc/search_panel.html' %}
  91. </div>
  92. {% endif %}
  93. </div>
  94. {% table_config_form table table_name="ObjectTable" %}
  95. {% endblock %}
  96. {% block javascript %}
  97. <script src="{% static 'js/tableconfig.js' %}"></script>
  98. {% endblock %}