This is an automated email from the git hooks/post-receive script. New commit to branch feature/multi-ui in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 09223b66db1acd55eb8d502452c955ba61756316 Author: jcouteau <couteau@codelutin.com> Date: Mon Aug 26 17:48:56 2019 +0200 Multi-questions : Results \o/ --- pollen-ui-riot-js/src/main/web/i18n/en.json | 2 + pollen-ui-riot-js/src/main/web/i18n/fr.json | 2 + .../src/main/web/tag/poll/Result.tag.html | 28 ++++++++++--- .../src/main/web/tag/poll/Results.tag.html | 48 ++++++++++++++++++++-- 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/i18n/en.json b/pollen-ui-riot-js/src/main/web/i18n/en.json index 97f2d0d6..0fce252c 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/en.json +++ b/pollen-ui-riot-js/src/main/web/i18n/en.json @@ -121,6 +121,8 @@ "poll_results_majorityJudgment_title": "Histogram Cumulative of votes by choice.", "poll_results_majorityJudgment_oneVote": "vote", "poll_results_majorityJudgment_manyVotes": "votes", + "poll_results_previousQuestion": "Question précédente", + "poll_results_nextQuestion": "Question suivante", "poll_comments_one": "Comment", "poll_comments_many": "Comments", "poll_comments_noComment": "No comment.", diff --git a/pollen-ui-riot-js/src/main/web/i18n/fr.json b/pollen-ui-riot-js/src/main/web/i18n/fr.json index 2b1a1976..ae65c8d6 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/fr.json +++ b/pollen-ui-riot-js/src/main/web/i18n/fr.json @@ -121,6 +121,8 @@ "poll_results_majorityJudgment_title": "Histogramme Cumulé des votes par choix.", "poll_results_majorityJudgment_oneVote": "vote", "poll_results_majorityJudgment_manyVotes": "votes", + "poll_results_previousQuestion": "Question précédente", + "poll_results_nextQuestion": "Question suivante", "poll_comments_one": "Commentaire", "poll_comments_many": "Commentaires", "poll_comments_noComment": "Pas de commentaire.", diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Result.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Result.tag.html index 45b6ae43..e13b7c4b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Result.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Result.tag.html @@ -92,11 +92,15 @@ import "../voteCountingType/MajorityJudgmentDetailResult.tag.html"; this.onPollChange = poll2 => { //reload question var _this = this; - poll2.questions.forEach(function(question) { - if (_this.question.id === question.id) { - _this.question = question; - } - }); + if (_this.question) { + poll2.questions.forEach(function(question) { + if (_this.question.id === question.id) { + _this.question = question; + } + }); + } else { + _this.question = poll2.questions[0]; + } this.loaded = !this.question.resultIsVisible || this.question.results !== undefined; this.resultsLoaded = this.question.results !== undefined; @@ -109,8 +113,22 @@ import "../voteCountingType/MajorityJudgmentDetailResult.tag.html"; this.update(); }; + this.onQuestionChange = question2 => { + this.question=question2; + this.loaded = !this.question.resultIsVisible || this.question.results !== undefined; + this.resultsLoaded = this.question.results !== undefined; + if (!this.resultsLoaded) { + this.poll.loadResults(this.question.id).then(() => { + }); + } + this.question.pollTypeRound = this.question.voteCountingType && (this.question.voteCountingType === 7 || this.question.voteCountingType === 6); + this.update(); + }; + this.listen("poll", this.onPollChange); + this.listen("question", this.onQuestionChange); + this.listen("user", (user, oldUser) => { if (user !== oldUser && this.question) { this.poll.loadResults(this.question.id); 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 c346e808..2dc42be1 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 @@ -26,7 +26,26 @@ import "../voteCountingType/InstantRunoffDetailResult.tag.html"; import "../voteCountingType/CoombsDetailResult.tag.html"; import "../voteCountingType/MajorityJudgmentDetailResult.tag.html"; <Results> - <Result each={question in poll.questions} /> + + <button if={questionToVote > 0} + type="button" + class="c-button c-button--info" + tabindex="1" + onclick={previousQuestion}> + <i class="fa fa-chevron-left " aria-hidden="true"></i> + {_t.previousQuestion} + </button> + + <button if={questionToVote < poll.questions.length - 1} + type="button" + class="c-button c-button--info" + tabindex="1" + onclick={nextQuestion}> + {_t.nextQuestion} + <i class="fa fa-chevron-right " aria-hidden="true"></i> + </button> + + <Result question={question}/> <script type="es6"> import session from "../../js/Session"; @@ -36,14 +55,23 @@ import "../voteCountingType/MajorityJudgmentDetailResult.tag.html"; this.installBundle(session, "poll_results"); this.poll = poll; - if (this.poll.questions[0]) { - this.poll.loadResults(this.poll.questions[0].id); + + this.questionToVote = 0; + + this.question = this.poll.questions[this.questionToVote]; + + if (this.question) { + this.poll.loadResults(this.question.id); } this.onPollChange = poll2 => { this.loaded = !poll2.questions[0].resultIsVisible || poll2.questions[0].results !== undefined; this.resultsLoaded = poll2.questions[0].results !== undefined; this.poll = poll2; + this.question = this.poll.questions[this.questionToVote]; + if (this.question) { + this.bus.trigger("question", this.question); + } if (!this.resultsLoaded) { this.poll.loadResults(poll2.questions[0].id).then(() => { }); @@ -61,6 +89,20 @@ import "../voteCountingType/MajorityJudgmentDetailResult.tag.html"; } }); + this.nextQuestion = () => { + this.questionToVote = this.questionToVote + 1; + this.question = this.poll.questions[this.questionToVote]; + this.bus.trigger("question", this.question); + this.update(); + }; + + this.previousQuestion = (e) => { + this.questionToVote = this.questionToVote - 1; + this.question = this.poll.questions[this.questionToVote]; + this.bus.trigger("question", this.question); + this.update(); + }; + </script> <style> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.