paginator_htmx.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {% load helpers %}
  2. {% load i18n %}
  3. <div class="row">
  4. <div class="col col-md-6 mb-0">
  5. {# Page number carousel #}
  6. {% if paginator.num_pages > 1 %}
  7. <div class="btn-group btn-group-sm" role="group" aria-label="Pages">
  8. {% if page.has_previous %}
  9. <a href="#"
  10. hx-get="{{ table.htmx_url }}{% querystring request page=page.previous_page_number %}"
  11. hx-target="closest .htmx-container"
  12. {% if not table.embedded %}hx-push-url="true"{% endif %}
  13. class="btn btn-outline-secondary"
  14. >
  15. <i class="mdi mdi-chevron-double-left"></i>
  16. </a>
  17. {% endif %}
  18. {% for p in page.smart_pages %}
  19. {% if p %}
  20. <a href="#"
  21. hx-get="{{ table.htmx_url }}{% querystring request page=p %}"
  22. hx-target="closest .htmx-container"
  23. {% if not table.embedded %}hx-push-url="true"{% endif %}
  24. class="btn btn-outline-secondary{% if page.number == p %} active{% endif %}"
  25. >
  26. {{ p }}
  27. </a>
  28. {% else %}
  29. <button type="button" class="btn btn-outline-secondary" disabled>
  30. <span>&hellip;</span>
  31. </button>
  32. {% endif %}
  33. {% endfor %}
  34. {% if page.has_next %}
  35. <a href="#"
  36. hx-get="{{ table.htmx_url }}{% querystring request page=page.next_page_number %}"
  37. hx-target="closest .htmx-container"
  38. {% if not table.embedded %}hx-push-url="true"{% endif %}
  39. class="btn btn-outline-secondary"
  40. >
  41. <i class="mdi mdi-chevron-double-right"></i>
  42. </a>
  43. {% endif %}
  44. </div>
  45. {% endif %}
  46. </div>
  47. <div class="col col-md-6 mb-0 text-end">
  48. {# Per-page count selector #}
  49. {% if page %}
  50. <div class="dropdown dropup">
  51. <button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown">
  52. {% trans "Per Page" %}
  53. </button>
  54. <ul class="dropdown-menu">
  55. {% for n in page.paginator.get_page_lengths %}
  56. <li>
  57. <a href="#"
  58. hx-get="{{ table.htmx_url }}{% querystring request per_page=n %}"
  59. hx-target="closest .htmx-container"
  60. {% if not table.embedded %}hx-push-url="true"{% endif %}
  61. class="dropdown-item"
  62. >{{ n }}</a>
  63. </li>
  64. {% endfor %}
  65. </ul>
  66. </div>
  67. <small class="text-end text-muted">
  68. {% blocktrans with start=page.start_index end=page.end_index total=page.paginator.count %}
  69. Showing {{ start }}-{{ end }} of {{ total }}
  70. {% endblocktrans %}
  71. </small>
  72. {% endif %}
  73. </div>
  74. </div>