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 89f78d9a8792f77cbb80c9afb3f3dc7e09335e58 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu May 24 15:40:57 2018 +0200 refs #181 : Lors d'un vote cumulatif, le "Nombre de points à distribuer" devrait être affiché à l'utilisateur --- pollen-ui-riot-js/src/main/web/i18n/en.json | 5 +++ pollen-ui-riot-js/src/main/web/i18n/fr.json | 5 +++ pollen-ui-riot-js/src/main/web/js/Poll.js | 5 --- .../src/main/web/tag/poll/EditVote.tag.html | 39 ++++++++++++++++++---- .../src/main/web/tag/poll/Votes.tag.html | 25 ++++++++------ 5 files changed, 56 insertions(+), 23 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 15f8c500..6695945c 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/en.json +++ b/pollen-ui-riot-js/src/main/web/i18n/en.json @@ -172,6 +172,11 @@ "poll_votes_voteNotOpen": "Votes are not open.", "poll_votes_voteClosed": "Votes are closed", "poll_votes_ignored": "Ignored", + "poll_votes_pointsDistribution": "Distribute {0} points among the proposed choices", + "poll_votes_remainPoints": "It remains {0} points to distribute", + "poll_votes_remainPoint": "It remains {0} point to distribute", + "poll_votes_tooManyPoints": "There are {0} points distributed too much", + "poll_votes_tooManyPoint": "There is {0} point distributed too much", "polls_createdPolls": "My polls", "polls_assignPollToMe": "Link a poll to my account", "polls_assignPollToMe_title": "Link the poll", 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 6208ddb0..1ef3059a 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/fr.json +++ b/pollen-ui-riot-js/src/main/web/i18n/fr.json @@ -172,6 +172,11 @@ "poll_votes_voteNotOpen": "Les votes ne sont pas encore ouverts.", "poll_votes_voteClosed": "Les votes sont clos.", "poll_votes_ignored": "Ignoré", + "poll_votes_pointsDistribution": "Distribuer {0} points parmis les choix proposés", + "poll_votes_remainPoints": "Il reste {0} points à distribuer", + "poll_votes_remainPoint": "Il reste {0} point à distribuer", + "poll_votes_tooManyPoints": "Il y a {0} points distribués en trop", + "poll_votes_tooManyPoint": "Il y a {0} point distribué en trop", "polls_createdPolls": "Mes sondages", "polls_assignPollToMe": "Attacher le sondage", "polls_assignPollToMe_title": "Attacher un sondage à mon compte", 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 e3114ac5..a926373a 100644 --- a/pollen-ui-riot-js/src/main/web/js/Poll.js +++ b/pollen-ui-riot-js/src/main/web/js/Poll.js @@ -411,11 +411,6 @@ class Poll { } return Promise.reject("Init poll after get invalid emails"); } - - isVoteByOrder() { - return [3, 5, 6, 7].indexOf(this.voteCountingType) >= 0; - } - } export default singleton(Poll); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/EditVote.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/EditVote.tag.html index f7f9247f..c0fb0de7 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/EditVote.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/EditVote.tag.html @@ -21,6 +21,11 @@ <EditVote> <div class="form-wrapper"> + + <h3 class="c-heading" + if={(poll.voteCountingType === 2)}> + {_l("pointsDistribution", poll.voteCountingConfig.points)} + </h3> <form id="voteForm" class="voter separator" ref="formAddVote"> <HumanInput onsubmit="{voteInEdition ? updateVote : addVote}"></HumanInput> <div class="header"> @@ -67,6 +72,7 @@ type="number" required={!poll.voteCountingConfig.maxChoiceNumber} min="{poll.voteCountingTypeValue && poll.voteCountingTypeValue.minimumValue}" + max={this.poll.voteCountingConfig.points} onchange="{onVoteChanged}" ref="{choice.id}_voteValue" tabindex="{10 * (index + 1)}"> @@ -111,7 +117,7 @@ type="submit" name="newVote" tabindex="{(poll.choices.length + 1) * 10}" - disabled={tooManyChoicesSelected || voting}> + disabled={tooManyChoicesSelected || remainPoints || voting}> <i class="fa fa-envelope"></i> {_t.toVote} </button> @@ -127,12 +133,18 @@ <button if="{voteInEdition}" class="c-button c-button--success" tabindex="{(poll.choices.length + 1) * 10}" - disabled={tooManyChoicesSelected || voting} + disabled={tooManyChoicesSelected || remainPoints || voting} type="submit"> <i class="fa fa-check"></i> {_t.validateEdition} </button> </div> + <div class="c-hint--static c-hint--info" if="{remainPoints > 0}"> + {_l(remainPoints === 1 ? "remainPoint" : "remainPoints", remainPoints)} + </div> + <div class="c-hint--static c-hint--error" if="{remainPoints < 0}"> + {_l(remainPoints === -1 ? "tooManyPoint" : "tooManyPoints", -remainPoints)} + </div> <div class="c-hint--static c-hint--error" if="{tooManyChoicesSelected}"> {_t.tooManyChoicesSelected} {poll.voteCountingConfig.maxChoiceNumber} </div> @@ -150,7 +162,6 @@ import poll from "../../js/Poll.js"; import moment from "moment"; - this.loaded = false; this.moment = moment; this.installBundle(session, "poll_votes"); this.tooManyChoicesSelected = false; @@ -211,6 +222,7 @@ } else { this.refs[this.poll.choices[0].id + "_voteValue"].focus(); } + this.onVoteChanged(); }; this.getChoiceVoteValue = ref => { @@ -228,9 +240,9 @@ }; this.onVoteChanged = () => { - if (this.loaded && this.poll.voteCountingConfig.maxChoiceNumber) { + if (this.poll.voteCountingConfig.maxChoiceNumber) { var selectedChoiceNb = 0; - this.poll.choices.forEach(c => { + this.poll.choices && this.poll.choices.forEach(c => { var choiceValue = this.getChoiceVoteValue(c.id + "_voteValue"); if (choiceValue && choiceValue !== "0") { selectedChoiceNb++; @@ -240,6 +252,19 @@ } else { this.tooManyChoicesSelected = false; } + if (this.poll.voteCountingConfig.points) { + let nbPoints = 0; + this.poll.choices && this.poll.choices.forEach(c => { + var choiceValue = this.getChoiceVoteValue(c.id + "_voteValue"); + if (choiceValue && choiceValue !== "0") { + nbPoints += parseInt(choiceValue, 10); + } + }); + this.remainPoints = this.poll.voteCountingConfig.points - nbPoints; + } else { + this.remainPoints = 0; + } + this.update(); }; this.resetVoteForm = () => { @@ -351,9 +376,9 @@ .form-wrapper { display: flex; - flex-direction: row; + flex-direction: column; justify-content: center; - align-items: stretch; + align-items: center; } .voter { 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 4d679bf0..f308b600 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 @@ -18,21 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -import "./Choice.tag.html"; -import "./ChoiceView.tag.html"; -import "./EditVote.tag.html"; -import "./EditVoteOrder.tag.html"; -import "./VotesTable.tag.html"; -import "../components/HumanInput.tag.html"; -import "../components/LazyLoad.tag.html"; -import "../components/Avatar.tag.html"; <Votes> <div class="container" show="{loaded}"> <EditVote ref="editVote" - if={!poll.isVoteByOrder()}/> + if={!isVoteByOrder}/> <EditVoteOrder ref="editVoteOrder" - if={poll.isVoteByOrder()}/> + if={isVoteByOrder}/> <!-- Form to vote --> <p class="warning-label warning" if="{loaded && !poll.canVote}"> @@ -68,6 +60,15 @@ import "../components/Avatar.tag.html"; </div> <script type="es6"> + import "./Choice.tag.html"; + import "./ChoiceView.tag.html"; + import "./EditVote.tag.html"; + import "./EditVoteOrder.tag.html"; + import "./VotesTable.tag.html"; + import "../components/HumanInput.tag.html"; + import "../components/LazyLoad.tag.html"; + import "../components/Avatar.tag.html"; + import session from "../../js/Session"; import moment from "moment"; import poll from "../../js/Poll.js"; @@ -76,6 +77,7 @@ import "../components/Avatar.tag.html"; this.moment = moment; this.installBundle(session, "poll_votes"); this.addingChoice = false; + this.isVoteByOrder = false; this.poll = poll; @@ -84,13 +86,14 @@ import "../components/Avatar.tag.html"; this.onPollChange = poll2 => { this.loaded = poll2.choices !== undefined; this.poll = poll2; + this.isVoteByOrder = [3, 5, 6, 7].indexOf(poll2.voteCountingType) >= 0; this.update(); }; this.listen("poll", this.onPollChange); this.editVote = (vote) => { - let editor = this.poll.isVoteByOrder() ? this.refs.editVoteOrder : this.refs.editVote; + let editor = this.isVoteByOrder ? this.refs.editVoteOrder : this.refs.editVote; editor.editVote(vote); }; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.