diff --git a/web/components/vote/desk-round.js b/web/components/vote/desk-round.js index 905513521891f9557f2687865e5ae416d84d3acc..ab56650b49d314720b3f901ae38d7ffa494a5c56 100644 --- a/web/components/vote/desk-round.js +++ b/web/components/vote/desk-round.js @@ -181,31 +181,30 @@ class DeskRoundSelector { } async loadDesks() { - let deskRoundHandler = this; - let deskRounds = await this.DeskRoundModel.getDeskRounds(); + let selectRound = document.getElementById("round-select"); - deskRounds = deskRounds.filter((deskRound) => { - return deskRound.RoundID == deskRoundHandler.RoundID; - }); - // Filter the desks to display only the one affected to capturer - if (this.DeskRoundModel.current_user.role === "CAPTURER") { - let capturer = await this.CapturerModel.getCapturerByUserID( - this.DeskRoundModel.current_user.id - ); - let deskRoundsToKeep = []; - for (let i in deskRounds) { - for (let j in capturer.DeskRounds) { - if (capturer.DeskRounds[j].ID == deskRounds[i].ID) - deskRoundsToKeep.push(deskRounds[i]); + if (selectRound.value != 0) { + let deskRoundHandler = this; + let deskRounds = await this.DeskRoundModel.getDeskRounds(); + + deskRounds = deskRounds.filter((deskRound) => { + return deskRound.RoundID == deskRoundHandler.RoundID; + }); + // Filter the desks to display only the one affected to capturer + if (this.DeskRoundModel.current_user.role === "CAPTURER") { + let capturer = await this.CapturerModel.getCapturerByUserID( + this.DeskRoundModel.current_user.id + ); + let deskRoundsToKeep = []; + for (let i in deskRounds) { + for (let j in capturer.DeskRounds) { + if (capturer.DeskRounds[j].ID == deskRounds[i].ID) + deskRoundsToKeep.push(deskRounds[i]); + } } + deskRounds = deskRoundsToKeep; } - deskRounds = deskRoundsToKeep; - } - let selectRound = document.getElementById("round-select"); - if (selectRound.value == 0) { - deskRounds = []; - } else { let deskRoundsFiltered = []; let selectArea = document.getElementById("area-select"); if (selectArea.value != 0) {