From 61803a993944fb0c1bbe33c9002c63b7874793f2 Mon Sep 17 00:00:00 2001 From: AlexisPoyen <apoyen@grandlyon.com> Date: Fri, 10 Jul 2020 09:05:31 +0200 Subject: [PATCH] Fix : load several time the same content in select menus --- web/components/vote/desk-round.js | 33 ------------------------------- web/components/vote/vote-page.js | 33 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/web/components/vote/desk-round.js b/web/components/vote/desk-round.js index 3dee00b..38a74b8 100644 --- a/web/components/vote/desk-round.js +++ b/web/components/vote/desk-round.js @@ -86,7 +86,6 @@ class DeskRoundSelector { </div> </div> `; - this.handleDom(); await this.loadElection(); } @@ -108,38 +107,6 @@ class DeskRoundSelector { </div>`; } - handleDom() { - let deskRoundHandler = this; - document.addEventListener( - "input", - function (event) { - if (event.target.id === "election-select") { - deskRoundHandler.ElectionID = event.target.value; - deskRoundHandler.clearRounds(); - deskRoundHandler.clearAreas(); - deskRoundHandler.clearSections(); - deskRoundHandler.loadRounds(); - } - if (event.target.id === "round-select") { - deskRoundHandler.RoundID = event.target.value; - deskRoundHandler.clearAreas(); - deskRoundHandler.clearSections(); - deskRoundHandler.loadAreas(); - } - if (event.target.id === "area-select") { - deskRoundHandler.AreaID = event.target.value; - deskRoundHandler.clearSections(); - deskRoundHandler.loadSections(); - } - if (event.target.id === "section-select") { - deskRoundHandler.SectionID = event.target.value; - } - deskRoundHandler.loadDesks(); - }, - false - ); - } - async loadElection() { let selectElection = document.getElementById("election-select"); let elections = await this.ElectionModel.getElections(); diff --git a/web/components/vote/vote-page.js b/web/components/vote/vote-page.js index e46f810..49424f9 100644 --- a/web/components/vote/vote-page.js +++ b/web/components/vote/vote-page.js @@ -24,7 +24,38 @@ class VotePage { this.handleDom(); } - handleDom() {} + handleDom() { + let deskRoundHandler = this.deskRoundHandler + document.addEventListener( + "input", + function (event) { + if (event.target.id === "election-select") { + deskRoundHandler.ElectionID = event.target.value; + deskRoundHandler.clearRounds(); + deskRoundHandler.clearAreas(); + deskRoundHandler.clearSections(); + deskRoundHandler.loadRounds(); + } + if (event.target.id === "round-select") { + deskRoundHandler.RoundID = event.target.value; + deskRoundHandler.clearAreas(); + deskRoundHandler.clearSections(); + deskRoundHandler.loadAreas(); + } + if (event.target.id === "area-select") { + deskRoundHandler.AreaID = event.target.value; + deskRoundHandler.clearSections(); + deskRoundHandler.loadSections(); + } + if (event.target.id === "section-select") { + deskRoundHandler.SectionID = event.target.value; + } + deskRoundHandler.loadDesks(); + }, + false + ); + } + async refreshVotes() { this.voteHandler = await Vote.mount(this); } -- GitLab