advanced-table.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {% assign table-id = include.id | default: "advanced-table" %}
  2. {% assign statuses = 'Active,Inactive,Requested' | split: ',' %}
  3. {% assign per-page = '10,20,50,100' | split: "," %}
  4. {% assign categories = 'Agencies,Individual,Event,Ticket' | split: "," %}
  5. {% assign tags = 'QTA,Event,Tickets,TODO|Event,Tickets|QTA,Event|Tickets' | split: "|" %}
  6. <!--{% include "js/tabler-list.html", parameters="[ 'sort-name', 'sort-content', 'sort-status', 'sort-date', 'sort-tags', 'sort-category']" %}-->
  7. <div class="card">
  8. <div class="card-table">
  9. <div class="card-header">
  10. <div class="row w-full">
  11. <div class="col">
  12. <h3 class="card-title mb-0">
  13. Employee
  14. </h3>
  15. <p class="text-secondary m-0">
  16. Table description.
  17. </p>
  18. </div>
  19. <div class="col-md-auto col-sm-12">
  20. {% capture html %}
  21. <kbd>ctrl + K</kbd>
  22. {% endcapture %}
  23. <div class="ms-auto d-flex flex-wrap btn-list">
  24. <div class="input-group input-group-flat w-auto">
  25. <span class="input-group-text">
  26. {% include "ui/icon.html" icon="search" %}
  27. </span>
  28. <input id="{{ table-id }}-search" type="text" class="form-control" autocomplete="off">
  29. <span class="input-group-text">
  30. <kbd>ctrl + K</kbd>
  31. </span>
  32. </div>
  33. <a href="#" class="btn btn-icon" aria-label="Button">
  34. {% include "ui/icon.html" icon="dots" %}
  35. </a>
  36. {% include "ui/dropdown.html" main-btn="Download" options="Action, Another action, Third action" %}
  37. {% include "ui/button.html" %}
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div id="{{ table-id }}">
  43. <div class="table-responsive">
  44. <table class="table table-vcenter table-selectable">
  45. <thead>
  46. <tr>
  47. <th class="w-1"></th>
  48. {% assign headers = table-properties.advanced-table.headers %}
  49. {% for header in headers %}
  50. <th>
  51. <button class="table-sort d-flex justify-content-between" data-sort="{{ header.data-sort}}">
  52. {{ header.name }}
  53. </button>
  54. </th>
  55. {% endfor %}
  56. </tr>
  57. </thead>
  58. <tbody class="table-tbody">
  59. {% for person in people %}
  60. <tr>
  61. <td>
  62. <input class="form-check-input m-0 align-middle table-selectable-check" type="checkbox" aria-label="Select invoice" value="true">
  63. </td>
  64. <td class="{{ headers[0].data-sort }}">
  65. {% include "ui/avatar.html" person=person size="xs" class="me-2" %}
  66. {{ person.full_name }}
  67. </td>
  68. <td class="{{ headers[1].data-sort }}">
  69. {{ person.city }}, {{ person.country }}
  70. </td>
  71. <td class="{{ headers[2].data-sort }}">
  72. {% assign status = forloop.index | plus: 5 | random_item: statuses %}
  73. {% if status == "Active" %}
  74. <span class="badge bg-success-lt">Active</span>
  75. {% elsif status == "Inactive" %}
  76. <span class="badge bg-danger-lt">Inactive</span>
  77. {% else %}
  78. <span class="badge">Requested</span>
  79. {% endif %}
  80. </td>
  81. <td class="{{ headers[3].data-sort }}">
  82. {{ forloop.index | random_date | date: '%B %d, %Y' }}
  83. </td>
  84. <td class="{{ headers[4].data-sort }}">
  85. {% assign item-tags = forloop.index | plus: 5 | random_item: tags %}
  86. {% assign item-tags = item-tags | split: "," %}
  87. <div class="badges-list">
  88. {% for tag in item-tags %}
  89. <span class="badge">{{ tag }}</span>
  90. {% endfor %}
  91. </div>
  92. </td>
  93. <td class="{{ headers[5].data-sort }} py-0">
  94. <span class="on-unchecked">
  95. {{ forloop.index | random_item: categories }}
  96. </span>
  97. <div class="on-checked">
  98. <div class="d-flex justify-content-end">
  99. {% include "ui/button.html" icon="dots" icon-only %}
  100. </div>
  101. </div>
  102. </td>
  103. </tr>
  104. {% endfor %}
  105. </tbody>
  106. </table>
  107. </div>
  108. <div class="card-footer d-flex align-items-center">
  109. <div class="dropdown">
  110. <a class="btn dropdown-toggle" data-bs-toggle="dropdown">
  111. <span id="page-count" class="me-1">{{ per-page[1] }}</span>
  112. <span>records</span>
  113. </a>
  114. <div class="dropdown-menu">
  115. {% for record in per-page %}
  116. <a class="dropdown-item" onclick="setPageListItems(event)" data-value="{{ record }}">{{ record }} records</a>
  117. {% endfor %}
  118. </div>
  119. </div>
  120. {% include "ui/pagination.html" class="m-0 ms-auto" no-words="true" count=10 %}
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <script>
  126. const advancedTable = {{ table-properties.advanced-table | json}}
  127. const setPageListItems = e => {
  128. window.tabler_list["{{ table-id }}"].page = parseInt(e.target.dataset.value)
  129. window.tabler_list["{{ table-id }}"].update()
  130. document.querySelector("#page-count").innerHTML = e.target.dataset.value
  131. }
  132. window.tabler_list = window.tabler_list || {}
  133. document.addEventListener("DOMContentLoaded", function() {
  134. const list = window.tabler_list["{{ table-id }}"] = new List('{{ table-id }}', {
  135. sortClass: 'table-sort',
  136. listClass: 'table-tbody',
  137. page: parseInt("{{ per-page[1] }}"),
  138. pagination: {
  139. item: value => {
  140. return `<li class="page-item"><a class="page-link cursor-pointer">${value.page}</a></li>`
  141. },
  142. innerWindow: 1,
  143. outerWindow: 1,
  144. left: 0,
  145. right: 0,
  146. },
  147. valueNames: advancedTable.headers.map(header => header['data-sort'])
  148. });
  149. const searchInput = document.querySelector('#{{ table-id }}-search');
  150. if (searchInput) {
  151. searchInput.addEventListener('input', () => {
  152. list.search(searchInput.value)
  153. })
  154. }
  155. })
  156. </script>