ticket_list_detail.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. {% extends "tickets/base.html" %}
  2. {% load static %}
  3. {% block content %}
  4. {% if my_tickets %}
  5. <h1 class="fw-bold">My Tickets (in all groups)</h1>
  6. {% elif assignments %}
  7. <h1 class="fw-bold">Assignments (in all groups)</h1>
  8. {% else %}
  9. <h1>{{ ticket_list.group }} > <b>{{ ticket_list.name }}</b></h1>
  10. <div class="d-flex justify-content-between">
  11. <button type="button" data-bs-toggle="modal" data-bs-target="#ticket-create-modal" class="btn btn-primary">
  12. <i class="fa-solid fa-plus pe-1"></i>
  13. New Ticket
  14. </button>
  15. {% if user.is_staff or user.is_superuser %}
  16. <button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#ticket_list-delete-modal">
  17. <i class="fa-solid fa-trash-can"></i>
  18. </button>
  19. {% endif %}
  20. </div>
  21. {% if user.is_staff or user.is_superuser %}
  22. <!--List delete modal-->
  23. <div class="modal fade" id="ticket_list-delete-modal" tabindex="-1">
  24. <div class="modal-dialog modal-dialog-centered">
  25. <div class="modal-content">
  26. <div class="modal-header">
  27. <h1 class="modal-title fs-5">
  28. <i class="fa-solid fa-trash-can pe-1"></i>
  29. Delete List
  30. </h1>
  31. </div>
  32. <div class="modal-body">
  33. Are you sure you want to delete the list "{{ ticket_list.name }}"? All related tickets will also be deleted.
  34. </div>
  35. <div class="modal-footer">
  36. <button type="button" class="btn btn-primary" data-bs-dismiss="modal">
  37. <i class="fa-solid fa-xmark pe-1"></i>
  38. Close
  39. </button>
  40. <form action="{% url 'tickets:ticket_list_delete' ticket_list.pk %}" method="post">
  41. {% csrf_token %}
  42. <button class="btn btn-outline-danger" type="submit">
  43. <i class="fa-solid fa-check pe-1"></i>
  44. Confirm
  45. </button>
  46. </form>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. {% endif %}
  52. <!--ticket create modal-->
  53. <div class="modal fade" id="ticket-create-modal" tabindex="-1">
  54. <div class="modal-dialog modal-dialog-centered">
  55. <div class="modal-content">
  56. <div class="modal-header">
  57. <h1 class="modal-title fs-5">
  58. <i class="fa-solid fa-plus pe-1"></i>
  59. New Ticket
  60. </div>
  61. <div class="modal-body">
  62. <form id="ticket-create-form" action="{% url 'tickets:ticket_create' ticket_list.pk %}" method="post">
  63. {% include 'tickets/include/form.html' %}
  64. </form>
  65. </div>
  66. <div class="modal-footer">
  67. <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
  68. <i class="fa-solid fa-xmark pe-1"></i>
  69. Close
  70. </button>
  71. <button class="btn btn-primary" type="submit" form="ticket-create-form">
  72. <i class="fa-solid fa-check pe-1"></i>
  73. Confirm
  74. </button>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. {% endif %}
  80. <hr>
  81. {% if tickets %}
  82. <div class="d-flex flex-wrap gap-1">
  83. {% for ticket_type in ticket_types %}
  84. <input type="radio" class="btn-check ticket_type-filter" name="btnradio" id="{{ ticket_type }}-radio">
  85. <label class="btn btn-outline-secondary" for="{{ ticket_type }}-radio">
  86. {{ ticket_type }}
  87. </label>
  88. {% endfor %}
  89. </div>
  90. <hr>
  91. <div class="overflow-x-scroll">
  92. <table class="table" id="tickettable">
  93. <thead>
  94. <tr class="nodrop">
  95. <th>ID</th>
  96. <th>Title</th>
  97. <th class="text-nowrap">Created at</th>
  98. <th class="text-nowrap">Due on</th>
  99. <th>Owner</th>
  100. <th>Assigned</th>
  101. <th>Status</th>
  102. <th>Priority</th>
  103. </tr>
  104. </thead>
  105. <tbody>
  106. {% for ticket in tickets %}
  107. <tr class="ticket" id="{{ ticket.pk }}" data-ticket-type="{{ ticket.get_ticket_type_display }}">
  108. <td>
  109. {{ ticket.pk }}
  110. </td>
  111. <td>
  112. <a href="{% url 'tickets:ticket_detail' ticket.pk %}">{{ ticket.title|truncatechars:48 }}</a>
  113. </td>
  114. <td>
  115. {{ ticket.created_at }}
  116. </td>
  117. <td>
  118. {{ ticket.due_date }}
  119. </td>
  120. <td>
  121. {{ ticket.created_by_username }}
  122. </td>
  123. <td>
  124. {% if ticket.assigned_to_username %}{{ ticket.assigned_to_username }}{% else %}Anyone{% endif %}
  125. </td>
  126. <td>
  127. {{ ticket.get_status_display }}
  128. </td>
  129. <td>
  130. {{ ticket.priority }}
  131. </td>
  132. </tr>
  133. {% endfor %}
  134. </tbody>
  135. </table>
  136. </div>
  137. {% else %}
  138. <h4>There are no Tickets!</h4>
  139. {% endif %}
  140. {% endblock %}
  141. {% block extra_js %}
  142. {% if tickets %}
  143. <script>
  144. let tickets = $(".ticket");
  145. let filters = $(".ticket_type-filter");
  146. filters.on("click", function() {
  147. localStorage.setItem("checked", this.id);
  148. apply_filters();
  149. });
  150. function apply_filters() {
  151. tickets.hide();
  152. let checkedFilterId = localStorage.getItem("checked");
  153. let checkedFilterEl = document.getElementById(checkedFilterId);
  154. if (checkedFilterEl) {
  155. checkedFilterEl.checked = true;
  156. } else {
  157. filters[0].checked = true;
  158. checkedFilterId = filters[0].id;
  159. }
  160. let ticket_type = checkedFilterId.split("-")[0];
  161. let filteredtickets = tickets.filter(function() {
  162. return $(this).data("ticket-type") === ticket_type;
  163. });
  164. filteredtickets.show();
  165. }
  166. document.addEventListener("DOMContentLoaded", apply_filters);
  167. </script>
  168. {% endif %}
  169. {% endblock extra_js %}