This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit b647a862d46108985dcd197cb674cc18130debf3 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 22 16:59:29 2017 +0100 ajout du composant podium --- pollen-ui-riot-js/src/main/web/js/Poll.js | 21 ++++++ .../src/main/web/tag/poll/Podium.tag.html | 78 ++++++++++++++++++++++ .../src/main/web/tag/poll/Results.tag.html | 2 + .../src/main/web/tag/poll/Votes.tag.html | 3 + 4 files changed, 104 insertions(+) diff --git a/pollen-ui-riot-js/src/main/web/js/Poll.js b/pollen-ui-riot-js/src/main/web/js/Poll.js index dc91f8c..9998bde 100644 --- a/pollen-ui-riot-js/src/main/web/js/Poll.js +++ b/pollen-ui-riot-js/src/main/web/js/Poll.js @@ -164,6 +164,27 @@ class Poll { return Promise.reject("Init poll after load results"); } + getPodium() { + let podium = {}; + if (this.id && this.resultIsVisible && this.results) { + podium = []; + let choiceCount = 0; + let index = 0; + + let getChoicesByScoreOrder = (order) => this.results.scores + .filter(score => score.scoreOrder === order) + .map(score => this.choices.find(choice => choice.id === score.choiceId)); + + while (choiceCount < 3) { + let choices = getChoicesByScoreOrder(index); + podium["step" + (choiceCount + 1)] = choices; + index++; + choiceCount += choices.length; + } + } + return podium; + } + loadComments() { if (this._initPromise) { return this._initPromise.then(() => { diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Podium.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Podium.tag.html new file mode 100644 index 0000000..d5c60c1 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Podium.tag.html @@ -0,0 +1,78 @@ +require("./ChoiceView.tag.html"); +<Podium> + <div class="podium"> + <div if={podium.step2} class="step second-step"> + <div class="step-score">2</div> + <div class="choices"> + <ChoiceView each={choice in podium.step2} choice={choice}/> + </div> + </div> + <div if={podium.step3} class="step first-step"> + <div class="step-score">1</div> + <div class="choices"> + <ChoiceView each={choice in podium.step1} choice={choice}/> + </div> + </div> + <div if={podium.step3} class="step third-step"> + <div class="step-score">3</div> + <div class="choices"> + <ChoiceView each={choice in podium.step3} choice={choice}/> + </div> + </div> + </div> + + <script type="es6"> + this.loaded = false; + this.podium = require("../../js/Poll.js").getPodium(); + this.onPollChange = poll => { + this.podium = poll.getPodium(); + this.update(); + }; + + this.bus.on("poll", this.onPollChange); + + this.on("before-unmount", () => { + this.bus.off("poll", this.onPollChange); + }); + + </script> + + + <style> + + .podium { + display: flex; + justify-content: center; + margin-bottom: 15px; + } + + .step { + display: flex; + flex-direction: column-reverse; + } + + .step-score { + background-color: #13a2ff; + color : #ffffff; + font-size: 2em; + text-align: center; + height: 1em; + } + + .second-step .step-score { + height: 1.5em; + } + + .first-step .step-score { + height: 2em; + } + + .step .choices { + display: flex; + font-size: 2em; + } + + + </style> + +</Podium> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html index cda48a7..541889a 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Results.tag.html @@ -1,10 +1,12 @@ require("./ChoiceView.tag.html"); +require("./Podium.tag.html"); <Results> <div class="container" show="{loaded}"> <div if="{!poll.resultIsVisible}"> {__.noResult} </div> <div if="{poll.resultIsVisible && poll.results}" class="result-body" > + <Podium/> <div class="result-content" each="{result in poll.results.scores}"> <div class="result"> {result.scoreOrder + 1} ({result.scoreValue} {result.scoreValue > 1 ? parent.__.votes : parent.__.vote}) : diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html index c8e07e4..05f4518 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html @@ -1,11 +1,14 @@ require("./Choice.tag.html"); require("./ChoiceView.tag.html"); +require("./Podium.tag.html"); <Votes> <div class="container"> <div show="{loaded}"> <div if="{!voting}">{__.voteNotOpen}</div> + <Podium if={poll.resultIsVisible}/> + <div if="{voting}" class="voters"> <form ref="formAddVote" onsubmit="{addVote}" class="fix"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.