Skip to content

Commit

Permalink
Show ticket messages in moderation
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Nov 15, 2024
1 parent b01465f commit a7cfd3e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
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
29 changes: 18 additions & 11 deletions templates/moderation/assigned.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,26 @@ <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-sections" style="display:none;">
<div id="ticket-comments-section">
{% for ticket in page.object_list %}
{% for message in ticket.messages.all 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%}">{{ message.text|safe|linebreaksbr }}</div>
</div>
<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 %}
{% endfor %}
{% endwith %}
</div>
{%endfor%}
</div>
{% endif %}
Expand Down

0 comments on commit a7cfd3e

Please sign in to comment.