From 5c35b671efd986db14d3ac2e42160d52cdfa9506 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 17 Jun 2021 10:15:06 +0200 Subject: [PATCH] =?UTF-8?q?On=20ne=20d=C3=A9place=20pas=20l'option=20si=20?= =?UTF-8?q?elle=20ne=20change=20pas=20de=20rang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elections/templates/elections/vote/rank.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/elections/templates/elections/vote/rank.html b/elections/templates/elections/vote/rank.html index 99dfb7b..4b21e98 100644 --- a/elections/templates/elections/vote/rank.html +++ b/elections/templates/elections/vote/rank.html @@ -99,14 +99,18 @@ $target.parentElement.classList.remove('is-hidden'); } - // On déplace l'option - var $tile = document.getElementById(data); - $target.appendChild($tile); - - // On enregistre le rang dans le formulaire const rank = $target.dataset.rank; + var $tile = document.getElementById(data); var $input = document.getElementById($tile.dataset.input); - $input.value = rank; + + // Si on ne change pas de rang, pas besoin de déplacer l'option + if ($input.value != rank) { + // On déplace l'option + $target.appendChild($tile); + + // On enregistre le rang dans le formulaire + $input.value = rank; + } collapseRanks(); }