On affiche le rang d'après, et on enlève le bouton + qui confond

This commit is contained in:
Tom Hubrecht 2021-06-19 14:15:11 +02:00
parent 7bb2b79f4c
commit cb4b20fb13

View file

@ -34,17 +34,19 @@
} }
// On recalcule ranks_used // On recalcule ranks_used
for (ranks_used = 1; ranks_used < nb_options && rank_zones[ranks_used + 1].childElementCount > 1; ranks_used++) {} for (ranks_used = 0; ranks_used < nb_options && rank_zones[ranks_used + 1].childElementCount > 1; ranks_used++) {}
// On affiche le bouton + si besoin // On affiche le bouton + si besoin
if (ranks_used < nb_options) { // let $add_rank = document.getElementById('rank-add');
let $add_rank = document.getElementById('rank-add'); // if (ranks_used < (nb_options - 1)) {
$add_rank.parentElement.classList.remove('is-hidden') // $add_rank.parentElement.classList.remove('is-hidden')
} // } else {
// $add_rank.parentElement.classList.add('is-hidden')
// }
// On cache les zones non utilisées // On cache les zones non utilisées, sauf une
for (let i = 1; i <= nb_options; i++) { for (let i = 1; i <= nb_options; i++) {
if (i > ranks_used) { if (i > (ranks_used + 1)) {
rank_zones[i].parentElement.classList.add('is-hidden'); rank_zones[i].parentElement.classList.add('is-hidden');
} else { } else {
rank_zones[i].parentElement.classList.remove('is-hidden'); rank_zones[i].parentElement.classList.remove('is-hidden');
@ -90,11 +92,6 @@
if ($target.id == 'rank-add') { if ($target.id == 'rank-add') {
ranks_used += 1; ranks_used += 1;
// Si on a autant de rangs que d'option, on cache le bouton +
if (ranks_used == nb_options) {
$target.parentElement.classList.add('is-hidden');
}
$target = rank_zones[ranks_used]; $target = rank_zones[ranks_used];
$target.parentElement.classList.remove('is-hidden'); $target.parentElement.classList.remove('is-hidden');
} }
@ -240,7 +237,7 @@
</div> </div>
{% endfor %} {% endfor %}
<div class="tile is-parent is-flex-grow-0"> <div class="tile is-parent is-flex-grow-0 is-hidden">
<div id="rank-add" class="tile is-child notification has-text-centered drop-zone"> <div id="rank-add" class="tile is-child notification has-text-centered drop-zone">
<span class="icon-text subtitle has-text-primary"> <span class="icon-text subtitle has-text-primary">
<span class="icon"> <span class="icon">