Skip to content

Commit

Permalink
Fixes in assigned sounds page
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Oct 30, 2023
1 parent 493003f commit 0a31379
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ collapsableToggles.forEach(element => {
element.addEventListener('click', handleCollapsable);
});

export {toggleCollapse};


27 changes: 26 additions & 1 deletion freesound/static/bw-frontend/src/pages/moderation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { stopAllPlayers } from '../components/player/utils'
import { toggleCollapse } from '../components/collapsableBlock'
import { getCookie, setCookie } from "../utils/cookies";

const selectAllButton = document.getElementById('select-all');
Expand All @@ -20,6 +21,23 @@ const soundInfoElementsPool = document.getElementById('sound-info-elements');
const selectedSoundsInfoPanel = document.getElementById('selected-sounds-info');


const closeCollapsableBlocks = (soundElement) => {
const collapsableToggleElement = soundElement.getElementsByClassName('collapsable-toggle')[0];
const collapsableContainer = document.getElementById(collapsableToggleElement.dataset.target)
if (collapsableContainer.className.indexOf('-close') === -1) {
toggleCollapse(collapsableToggleElement);
}
}

const openCollapsableBlocks = (soundElement) => {
const collapsableToggleElement = soundElement.getElementsByClassName('collapsable-toggle')[0];
const collapsableContainer = document.getElementById(collapsableToggleElement.dataset.target)
if (collapsableContainer.className.indexOf('-close') !== -1) {
toggleCollapse(collapsableToggleElement);
}
}


const postTicketsSelected = () => {
// Do things that need to be done after some tickets have been selected such as
// showing sound information, etc.
Expand Down Expand Up @@ -58,13 +76,20 @@ const postTicketsSelected = () => {

// Show information about the selected sounds
// First move all selected sound info elements to the main pool
// Also "hide" the "show more info" collapsable block (if any)
while (selectedSoundsInfoPanel.childNodes.length > 0) {
soundInfoElementsPool.appendChild(selectedSoundsInfoPanel.childNodes[0]);
const selectedSoundElement = selectedSoundsInfoPanel.childNodes[0];
closeCollapsableBlocks(selectedSoundElement);
soundInfoElementsPool.appendChild(selectedSoundElement);
}

// Then move the selected ones to the selected panel
// If only one sound is selected, then open the "show more info" collapsable block
selectedTicketsData.forEach(ticketData => {
const soundInfoElement = document.querySelector(`.sound-info-element[data-sound-id="${ticketData['soundId']}"]`);
if (selectedTicketsData.length === 1) {
openCollapsableBlocks(soundInfoElement);
}
selectedSoundsInfoPanel.appendChild(soundInfoElement);
});

Expand Down
4 changes: 2 additions & 2 deletions templates_bw/sounds/display_sound.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ <h5 class="ellipsis">
</div>
</div>
<div class="text-center v-spacing-top-1 v-spacing-2">
<span data-target="collapsable-sound-info-{{ sound.id }}-{{ random_number }}" data-show-text="Show more info" data-hide-text="Show less info" data-max-height-when-closed="150" data-hide-on-load class="collapsable-toggle"></span>
<span data-target="collapsable-sound-info-{{ sound.id }}-{{ random_number }}" data-show-text="Show more info" data-hide-text="Show less info" data-max-height-when-closed="150" {% if show_less_info_on_load %} data-hide-on-load{% endif %} class="collapsable-toggle"></span>
</div>
{% if not is_explicit %}
{% if is_explicit %}
<div class="v-spacing-top-1">
<div class="text-grey">
{% bw_icon "notification" %} Marked as explicit
Expand Down

0 comments on commit 0a31379

Please sign in to comment.