From 3ae234d4f3ad88bcecf01805f9e49f0ac0731cdd Mon Sep 17 00:00:00 2001 From: Alexis POYEN <apoyen@grandlyon.com> Date: Fri, 12 Jun 2020 14:57:09 +0200 Subject: [PATCH] Resolve "Display the round" --- data/test.db | Bin 69632 -> 69632 bytes web/components/management/candidate-lists.js | 22 ++++++- web/components/management/round-desks.js | 21 +++--- web/components/management/round.js | 6 +- web/components/management/rounds-card.js | 66 +++++++++++++------ web/style.css | 26 +++++--- 6 files changed, 98 insertions(+), 43 deletions(-) diff --git a/data/test.db b/data/test.db index 04150ffcc3b3ba1f7d353fbfafed5b5e9bf1005a..e9c2917732374424b4ed0679bdf3eb24f951af23 100644 GIT binary patch delta 2186 zcmai#TWs4@7{`5loQu=iC#9>9D5%~AmD0sKzF)d2Q_C1aXkF>cm=Il-IIY(#sq6&Q zhmrwLePYE@g~WPc(u5|SwmhSO`hwVanS@}KrU@Y)c&N&>A%S?|B&AK#7!f70Z2jb) zzyJBp=PT>Xm38K7f6q8YQ9b0h`{`Xes-(s#G5vsx=~NQjrO*-nF~7!r*S*>GYvQj2 z9e)yk8QhILpzlYHFc0CQTT5w>_>k#}Jv%%MK1v5CW4|3ZDjdpqPG-u@9TMDP*_n2{ zq1t^q$1ue6v}VV?ed)P8l|T~!Jx0HvpHK~bgO<^Cw1_6qe62^&(5YS)4ufo_m~(TP zvNKh1{jwiL-&4Kp-bJ6B9^e!3V3YHsU2)hC<}zN{b$l2sr;o)@&hck`Ex4B+>O$Gf zT)E;oo-f@#32+~Io(Qi|=mvV7-{zNjjbk{b)|33bn+BiUT1o+WDiTB&E&wK&UN{F} z@b$uZKnMNrzg4?Yz4|<ixNMMI83^XDalv~Z_mSfuK|jA%ASl0biJ<c<KY~awu{ukx zf3-Rb;Uzk_vpNu5UgLvvYsXpI1qo_$l464oR{DY;)}9Ie{H%u@k0l_#Nuf1#g5M+$ zbdRrQV5|-f_RCntDXga?S&&p)GHuBaEppAomLUye*~aALf040L(RaLeNw^iyKa8=F z%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HTWcX_wlCkvH<OP$HNrQKH0o3fst+UjJgO$*2y31q8M2w`_xCOS2J-k z1P2FmN;7d785kMp8kp)DStuA9TN#*J8C&R?Selv|7@HYQF02>h#Sp2turf8%Gc+?X zG%+)^Fw-_LvNAC6sm#w)FiK_31_pw8a4-YVXihYvEvyWU^b9Nvjm=FhEiEA0;7Y2Q zVJ;%5ZE|tEAin{sX_E`$MdW~DrWSgJMwZ5wW=00aNDebe<;dE+w0?pNGkYfIWP!Qz zlPl-&PA=~k1=8xk@L4z~2N*tlbF+ZqQ#toKBm3mQdD%emz4Nk}S+kfX@1G|>Id?wa z<cRq;oGh7)T)@C%;GEnzS9J2#`9hO_%oYUF`iogE2q5FlEEoRpGjeTayud5~W&;2^ CWSs{9 diff --git a/web/components/management/candidate-lists.js b/web/components/management/candidate-lists.js index 1b0dd46..81fbfd7 100644 --- a/web/components/management/candidate-lists.js +++ b/web/components/management/candidate-lists.js @@ -34,7 +34,7 @@ class CandidateList { const mountpoint = where; document.getElementById(mountpoint).innerHTML = /* HTML */ ` <header class="card-header"> - <p class="card-header-title"> + <p id="candidate-list-title" class="card-header-title"> Liste des candidats par circonscription </p> <button id="candidate-list-new" class="button is-success" disabled> @@ -359,10 +359,13 @@ class CandidateList { document .getElementById(`areas-area-${area.ID}`) .addEventListener("click", async function () { + candidateListHandler.emptyCandidateList(); await candidateListHandler.activateArea(area); await candidateListHandler.displayCandidateLists(); }); }); + + this.emptyCandidateList(); } async updateAreas() { @@ -396,8 +399,11 @@ class CandidateList { .classList.remove("active-card"); }); document - .getElementById(`candidateLists-candidateList-${candidateListToActivate.ID}`) + .getElementById( + `candidateLists-candidateList-${candidateListToActivate.ID}` + ) .classList.add("active-card"); + this.displayCandidates(); } async displayCandidateLists() { @@ -440,7 +446,10 @@ class CandidateList { let candidateListHandler = this; let candidateLists = await this.CandidateListModel.getCandidateLists(); return candidateLists.filter(function (candidateList) { - return candidateList.AreaID == candidateListHandler.area.ID; + return ( + candidateList.AreaID == candidateListHandler.area.ID && + candidateList.RoundID == candidateListHandler.round.ID + ); }); } @@ -539,4 +548,11 @@ class CandidateList { await this.CandidateModel.deleteCandidate(candidate.ID); await this.displayCandidates(); } + + emptyCandidateList() { + this.area = null; + document.getElementById("candidate-lists-list").innerHTML = ""; + this.candidateList = null; + document.getElementById("candidate-list").innerHTML = ""; + } } diff --git a/web/components/management/round-desks.js b/web/components/management/round-desks.js index cf36d2b..b365d73 100644 --- a/web/components/management/round-desks.js +++ b/web/components/management/round-desks.js @@ -29,7 +29,7 @@ class RoundDesk { const mountpoint = where; document.getElementById(mountpoint).innerHTML = /* HTML */ ` <header class="card-header"> - <p class="card-header-title"> + <p id="desk-round-title" class="card-header-title"> Bureaux de votes </p> </header> @@ -40,11 +40,8 @@ class RoundDesk { <div class="column"> <div id="desk-round-details"></div> </div> - <div class="column"> - <div id="active-capturer" class="card"></div> - </div> - <div class="column"> - <div id="available-capturer" class="card"></div> + <div class="column is-half"> + <div id="vote-list" class="card"></div> </div> </div> `; @@ -54,8 +51,9 @@ class RoundDesk { handleDom() { let roundHandler = this; - document.getElementById(`round-new`).addEventListener("click", function () { - }); + document + .getElementById(`round-new`) + .addEventListener("click", function () {}); document .getElementById(`capturers-modal-close`) @@ -202,6 +200,7 @@ class RoundDesk { document.getElementById("desk-rounds").innerHTML = markup; let deskRoundHandler = this; + deskRoundHandler.emptyDesksDetails(); deskRounds.map(async (deskRound) => { let desk = await this.DeskModel.getDesk(deskRound.DeskID); document.getElementById( @@ -325,4 +324,10 @@ class RoundDesk { }); }); } + + emptyDesksDetails() { + this.desk = null; + document.getElementById("desk-round-details").innerHTML = ""; + document.getElementById("vote-list").innerHTML = ""; + } } diff --git a/web/components/management/round.js b/web/components/management/round.js index ce7429d..d6941c2 100644 --- a/web/components/management/round.js +++ b/web/components/management/round.js @@ -18,16 +18,16 @@ class Round { const mountpoint = where; document.getElementById(mountpoint).innerHTML = /* HTML */ ` <div class="columns"> - <div class="column is-one-quarter"> + <div class="column is-full"> <div id="rounds-list" class="card"> Liste des tours </div> </div> - <div class="column"> + <div class="column" style="padding-right:40px;"> <div id="round-desks" class="card card-list"> Liste des bureaux d'un tour </div> - <div id="candidate-lists" class="card card-list"> + <div id="candidate-lists" class="card card-list" "> Liste des listes de candidats d'un tour </div> </div> diff --git a/web/components/management/rounds-card.js b/web/components/management/rounds-card.js index 7793cca..35b07cf 100644 --- a/web/components/management/rounds-card.js +++ b/web/components/management/rounds-card.js @@ -169,10 +169,6 @@ class Round { .getElementById(`rounds-round-${round.ID}`) .addEventListener("click", async function () { roundHandler.activateRound(round); - roundHandler.parent.deskRoundsHandler.round = round; - await roundHandler.parent.deskRoundsHandler.displayDesks(); - roundHandler.parent.candidateListHandler.round = round; - roundHandler.parent.candidateListHandler.displayAreas(); }); }); } @@ -213,23 +209,30 @@ class Round { } async activateRound(roundToActivate) { - document - .getElementById("candidate-list-new") - .setAttribute("disabled", "true"); - let rounds = await this.RoundModel.getRounds(); - rounds.forEach((round) => { - document - .getElementById(`rounds-round-${round.ID}`) - .classList.remove("active-card"); - }); - document - .getElementById(`rounds-round-${roundToActivate.ID}`) - .classList.add("active-card"); - // TODO unselect candidateLists - document.getElementById("rounds-list").setAttribute("hidden", "true"); - document.getElementById("rounds-list").parentElement.className = "column"; - document.getElementById("candidate-lists").parentElement.className = - "column is-full"; + let election = await this.ElectionModel.getElection( + roundToActivate.ElectionID + ); + document.getElementById("candidate-list-title").innerHTML = + "Liste des candidats par circonscription (" + + election.Name + + ", tour : " + + roundToActivate.Round + + ", date : " + + new Date(roundToActivate.Date).toLocaleDateString() + + ")"; + document.getElementById("desk-round-title").innerHTML = + "Bureaux de votes (" + + election.Name + + ", tour : " + + roundToActivate.Round + + ", date : " + + new Date(roundToActivate.Date).toLocaleDateString() + + ")"; + this.parent.deskRoundsHandler.round = roundToActivate; + await this.parent.deskRoundsHandler.displayDesks(); + this.parent.candidateListHandler.round = roundToActivate; + await this.parent.candidateListHandler.displayAreas(); + this.hideRounds(); } async newRound() { @@ -281,4 +284,25 @@ class Round { .getElementById("candidate-list-new") .setAttribute("disabled", "true"); } + + hideRounds() { + let roundsHandler = this; + document.getElementById("rounds-list").innerHTML = + '<p id="display-rounds">Afficher la liste des tours</p>'; + document.getElementById("rounds-list").className = "upper-text"; + document.getElementById("rounds-list").parentElement.className = + "column upper-text"; + document.getElementById("candidate-lists").parentElement.className = + "column is-full"; + document + .getElementById("display-rounds") + .addEventListener("click", async function () { + await roundsHandler.mount("rounds-list"); + document.getElementById("rounds-list").className = "card"; + document.getElementById("rounds-list").parentElement.className = + "column is-full"; + document.getElementById("candidate-lists").parentElement.className = + "column"; + }); + } } diff --git a/web/style.css b/web/style.css index 4637e91..19ec053 100644 --- a/web/style.css +++ b/web/style.css @@ -110,22 +110,32 @@ select { flex-basis: 70%; } -#round-desks, #candidate-lists { +#round-desks, +#candidate-lists { height: 35vh; } -#round-desks .column, #candidate-lists .column { +#round-desks .column, +#candidate-lists .column { overflow-y: auto; } -#round-desks .columns, #candidate-lists .columns { +#round-desks .columns, +#candidate-lists .columns { max-height: 90%; } -.card-header-success{ - background-color: rgba(127,186,0,.95); +.card-header-success { + background-color: rgba(127, 186, 0, 0.95); } -.card-header-danger{ - background-color: rgba(242,80,34,.95); -} \ No newline at end of file +.card-header-danger { + background-color: rgba(242, 80, 34, 0.95); +} + +.upper-text { + writing-mode: sideways-lr; + background-color: rgba(55,122,195,.95); + text-orientation: sideways-right; + text-align: center; +} -- GitLab