ticket_detail.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. {% extends "base.html" %}
  2. {% block content %}
  3. <div class="columns">
  4. <div class="column is-8">
  5. <div class="box">
  6. <h1 class="title">{{ ticket.title }}</h1>
  7. <div class="tags">
  8. <span class="tag is-{{ 'success' if ticket.status == 'CLOSED' else 'warning' }}">{{ ticket.status
  9. }}</span>
  10. <span class="tag is-info">Created by {{ ticket.creator.username }}</span>
  11. <span class="tag is-dark">{{ ticket.created_at.strftime('%Y-%m-%d %H:%M') }}</span>
  12. </div>
  13. <div class="content">
  14. <p>{{ ticket.description }}</p>
  15. </div>
  16. {% if ticket.status == 'CLOSED' %}
  17. <div class="notification is-warning is-light">
  18. <strong>Closed by {{ ticket.closed_by.username }}</strong><br>
  19. Reason: {{ ticket.closing_reason }}
  20. </div>
  21. {% endif %}
  22. </div>
  23. <h2 class="subtitle">Comments</h2>
  24. {% for comment in ticket.comments %}
  25. {% if not comment.is_hidden or is_admin %}
  26. <div class="box {% if comment.is_hidden %}is-hidden-comment{% endif %}"
  27. style="{% if comment.is_hidden %}background-color: #3a1a1a; border-color: #5a2a2a;{% endif %}">
  28. <article class="media">
  29. <div class="media-content">
  30. <div class="content">
  31. <p>
  32. <strong>{{ comment.user.username }}</strong> <small>{{ comment.created_at.strftime('%Y-%m-%d
  33. %H:%M') }}</small>
  34. {% if comment.is_hidden %}
  35. <span class="tag is-danger is-light ml-2">Hidden</span>
  36. {% endif %}
  37. <br>
  38. {{ comment.content }}
  39. </p>
  40. </div>
  41. </div>
  42. {% if is_admin %}
  43. <div class="media-right">
  44. <form method="POST" style="display: inline;">
  45. <input type="hidden" name="action" value="toggle_hidden">
  46. <input type="hidden" name="comment_id" value="{{ comment.id }}">
  47. <button
  48. class="button is-small is-{{ 'success' if comment.is_hidden else 'warning' }} is-outlined">
  49. {{ 'Unhide' if comment.is_hidden else 'Hide' }}
  50. </button>
  51. </form>
  52. </div>
  53. {% endif %}
  54. </article>
  55. </div>
  56. {% endif %}
  57. {% else %}
  58. <p>No comments yet.</p>
  59. {% endfor %}
  60. {% if ticket.status != 'CLOSED' %}
  61. <div class="box">
  62. <form method="POST">
  63. <input type="hidden" name="action" value="comment">
  64. <div class="field">
  65. <label class="label">Add Comment</label>
  66. <div class="control">
  67. <textarea class="textarea" name="content" placeholder="Type your comment here..."
  68. required></textarea>
  69. </div>
  70. </div>
  71. {% if is_admin %}
  72. <div class="field">
  73. <div class="control">
  74. <label class="checkbox">
  75. <input type="checkbox" name="is_hidden">
  76. Admin Comment (Hidden)
  77. </label>
  78. </div>
  79. </div>
  80. {% endif %}
  81. <div class="control">
  82. <button class="button is-link">Submit Comment</button>
  83. </div>
  84. </form>
  85. </div>
  86. {% endif %}
  87. </div>
  88. <div class="column is-4">
  89. <div class="box">
  90. <h2 class="subtitle">Actions</h2>
  91. {% if ticket.status != 'CLOSED' %}
  92. {% if is_admin or is_creator %}
  93. <button class="button is-danger is-fullwidth" id="close-btn">Close Ticket</button>
  94. {% else %}
  95. <p>Only admins or the creator can close this ticket.</p>
  96. {% endif %}
  97. {% else %}
  98. <p>This ticket is closed.</p>
  99. {% endif %}
  100. <hr>
  101. <a href="{{ url_for('main.tickets') }}" class="button is-light is-fullwidth">Back to List</a>
  102. </div>
  103. </div>
  104. </div>
  105. <!-- Close Modal -->
  106. <div class="modal" id="close-modal">
  107. <div class="modal-background"></div>
  108. <div class="modal-card">
  109. <header class="modal-card-head">
  110. <p class="modal-card-title">Close Ticket</p>
  111. <button class="delete" aria-label="close" id="modal-close-x"></button>
  112. </header>
  113. <section class="modal-card-body">
  114. <form method="POST" id="close-form">
  115. <input type="hidden" name="action" value="close">
  116. <div class="field">
  117. <label class="label">Reason for closing</label>
  118. <div class="control">
  119. <textarea class="textarea" name="reason" placeholder="Resolved, duplicate, etc."
  120. required></textarea>
  121. </div>
  122. </div>
  123. </form>
  124. </section>
  125. <footer class="modal-card-foot">
  126. <button class="button is-danger" onclick="document.getElementById('close-form').submit()">Confirm
  127. Close</button>
  128. <button class="button" id="modal-cancel">Cancel</button>
  129. </footer>
  130. </div>
  131. </div>
  132. <script>
  133. const modal = document.getElementById('close-modal');
  134. const closeBtn = document.getElementById('close-btn');
  135. const modalCloseX = document.getElementById('modal-close-x');
  136. const modalCancel = document.getElementById('modal-cancel');
  137. const modalBg = document.querySelector('.modal-background');
  138. if (closeBtn) {
  139. closeBtn.addEventListener('click', () => {
  140. modal.classList.add('is-active');
  141. });
  142. }
  143. const closeModal = () => {
  144. modal.classList.remove('is-active');
  145. };
  146. if (modalCloseX) modalCloseX.addEventListener('click', closeModal);
  147. if (modalCancel) modalCancel.addEventListener('click', closeModal);
  148. if (modalBg) modalBg.addEventListener('click', closeModal);
  149. </script>
  150. {% endblock %}