Skip to content

Commit

Permalink
Merge pull request #1794 from MTG/mod_messages_in_assigned
Browse files Browse the repository at this point in the history
Show ticket messages in assigned
  • Loading branch information
ffont authored Nov 15, 2024
2 parents 4b5b709 + a7cfd3e commit 836e974
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
10 changes: 10 additions & 0 deletions freesound/static/bw-frontend/src/pages/moderation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 22 additions & 0 deletions templates/moderation/assigned.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ <h5>No sound tickets in your queue... &#128522</h5>
<br>You can do shift+click on a row to select all the rows since the last previously selected row
</div>
</div>
<div id="ticket-comments-section">
{% for ticket in page.object_list %}
<div class="ticket-comments" data-ticket-id="{{ ticket.id }}" class="v-spacing-4 display-none">
{% with ticket.messages.all as ticket_messages %}
{% if ticket_messages.count > 0 %}
<h4 class="v-spacing-2 text-grey">Messages for ticket #{{ ticket.id }}</h4>
{% for message in ticket_messages reversed %}
{% if not message.moderator_only or can_view_moderator_only_messages %}
<div class="v-spacing-2">
<div>
{% if message.sender %} <a href="{% url "account" message.sender.username %}">{{ message.sender.username }}</a> {% else %} Anonymous {% endif %}<span class="h-spacing-left-1 h-spacing-1 text-grey">·</span><span class="text-grey">{{ message.created }}</span>
{% if message.moderator_only %}<span title="This message is only visible to other moderators" class="text-blue">{% bw_icon 'notification' 'rotate180' %}</span>{% endif %}
</div>
<div class="{% if message.moderator_only %}text-blue{%endif%} overflow-hidden">{{ message.text|safe|linebreaksbr }}</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endwith %}
</div>
{%endfor%}
</div>
{% endif %}
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion tickets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'})
Expand Down

0 comments on commit 836e974

Please sign in to comment.