From cb4b20fb1308b9d72a2b6dafa2b5f74a6b1877d2 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Sat, 19 Jun 2021 14:15:11 +0200 Subject: [PATCH] =?UTF-8?q?On=20affiche=20le=20rang=20d'apr=C3=A8s,=20et?= =?UTF-8?q?=20on=20enl=C3=A8ve=20le=20bouton=20+=20qui=20confond?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elections/templates/elections/vote/rank.html | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/elections/templates/elections/vote/rank.html b/elections/templates/elections/vote/rank.html index 394c99b..df63311 100644 --- a/elections/templates/elections/vote/rank.html +++ b/elections/templates/elections/vote/rank.html @@ -34,17 +34,19 @@ } // 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 - if (ranks_used < nb_options) { - let $add_rank = document.getElementById('rank-add'); - $add_rank.parentElement.classList.remove('is-hidden') - } + // let $add_rank = document.getElementById('rank-add'); + // if (ranks_used < (nb_options - 1)) { + // $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++) { - if (i > ranks_used) { + if (i > (ranks_used + 1)) { rank_zones[i].parentElement.classList.add('is-hidden'); } else { rank_zones[i].parentElement.classList.remove('is-hidden'); @@ -90,11 +92,6 @@ if ($target.id == 'rank-add') { 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.parentElement.classList.remove('is-hidden'); } @@ -240,7 +237,7 @@ {% endfor %} -
+