diff --git a/freesound/static/bw-frontend/src/pages/moderation.js b/freesound/static/bw-frontend/src/pages/moderation.js index 077b375be..8b9de517e 100644 --- a/freesound/static/bw-frontend/src/pages/moderation.js +++ b/freesound/static/bw-frontend/src/pages/moderation.js @@ -19,6 +19,7 @@ const messageTextArea = document.getElementsByName('message')[0]; const ticketIdsInput = document.getElementsByName('ticket')[0]; const soundInfoElementsPool = document.getElementById('sound-info-elements'); const selectedSoundsInfoPanel = document.getElementById('selected-sounds-info'); +const ticketCommentsSection = document.getElementById('ticket-comments-section'); const closeCollapsableBlocks = (soundElement) => { @@ -70,6 +71,15 @@ const postTicketsSelected = () => { } } + // Make ticket comments visible if only one ticket is selected + ticketCommentsSection.children.forEach(commentElement => { + commentElement.classList.add('display-none'); + }); + if (selectedTicketsData.length === 1) { + const commentElement = ticketCommentsSection.querySelector(`.ticket-comments[data-ticket-id="${selectedTicketsData[0]['ticketId']}"]`); + commentElement.classList.remove('display-none'); + } + // Set "ticket" field in moderation form with the ticket ids of the selected tickets const ticketIdsSerialized = selectedTicketsData.map(ticketData => ticketData['ticketId']).join('|'); ticketIdsInput.value = ticketIdsSerialized; diff --git a/templates/moderation/assigned.html b/templates/moderation/assigned.html index b9a170b20..a215fe4fe 100644 --- a/templates/moderation/assigned.html +++ b/templates/moderation/assigned.html @@ -75,6 +75,28 @@
No sound tickets in your queue... 😊

You can do shift+click on a row to select all the rows since the last previously selected row +
+ {% for ticket in page.object_list %} +
+ {% with ticket.messages.all as ticket_messages %} + {% if ticket_messages.count > 0 %} +

Messages for ticket #{{ ticket.id }}

+ {% for message in ticket_messages reversed %} + {% if not message.moderator_only or can_view_moderator_only_messages %} +
+
+ {% if message.sender %} {{ message.sender.username }} {% else %} Anonymous {% endif %}ยท{{ message.created }} + {% if message.moderator_only %}{% bw_icon 'notification' 'rotate180' %}{% endif %} +
+
{{ message.text|safe|linebreaksbr }}
+
+ {% endif %} + {% endfor %} + {% endif %} + {% endwith %} +
+ {%endfor%} +
{% endif %} diff --git a/tickets/views.py b/tickets/views.py index 54cf4a637..cbb1864d6 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -636,7 +636,8 @@ def moderation_assigned(request, user_id): "current_page": pagination_response['current_page'], "show_pagination": show_pagination, "mod_sound_form": mod_sound_form, - "msg_form": msg_form + "msg_form": msg_form, + "can_view_moderator_only_messages": _can_view_mod_msg(request) } _add_sound_objects_to_tickets(tvars['page'].object_list) tvars.update({'section': 'assigned'})