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 859d23bd575d91569608acac087432f13b09df5a Author: Kevin Morin <morin@codelutin.com> Date: Tue Aug 8 17:07:11 2017 +0200 fixes #105 navigation au clavier + blocage des boutons pendant l'attente de la réponse du serveur --- .../src/main/web/tag/poll/Votes.tag.html | 55 ++++++++++++++++++---- 1 file changed, 47 insertions(+), 8 deletions(-) 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 d481bafb..a7c3cfb8 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 @@ -20,6 +20,7 @@ require("../components/HumanInput.tag.html"); name="voterName" required maxlength="255" + tabindex="1" placeholder={__.authorPlaceHolder} value={poll.voterName}> </div> @@ -32,7 +33,7 @@ require("../components/HumanInput.tag.html"); <strong>{__.results}</strong> </div> </div> - <div each={choice in poll.choices} class="choice separator-bottom"> + <div each={choice, index in poll.choices} class="choice separator-bottom"> <div class="choice-vote separator-right"> <div class="choice-value"> <ChoiceView choice={choice} center="true"></ChoiceView> @@ -43,7 +44,8 @@ require("../components/HumanInput.tag.html"); class="check" type="checkbox" onchange="{onVoteChanged}" - ref="{choice.id}_voteValue"> + ref="{choice.id}_voteValue" + tabindex="{10 * (index + 1)}"> <input if={!pollTypeCheckbox} class="text c-field {c-field--error: !voteInEdition && error && (error['vote.voteValue#' + choice.id] || error['vote.totalVoteValue'])}" type="number" @@ -51,7 +53,8 @@ require("../components/HumanInput.tag.html"); min="{poll.voteCountingTypeValue && poll.voteCountingTypeValue.minimumValue}" max="{poll.voteCountingTypeValue && poll.voteCountingTypeValue.maximumValue}" onchange="{onVoteChanged}" - ref="{choice.id}_voteValue"> + ref="{choice.id}_voteValue" + tabindex="{10 * (index + 1)}"> </div> </div> <div if={poll.resultIsVisible} class="score-choice"> @@ -70,19 +73,24 @@ require("../components/HumanInput.tag.html"); class="c-button c-button--brand pull-right" type="submit" name="newVote" - disabled={tooManyChoicesSelected}> + tabindex="{(poll.choices.length + 1) * 10}" + disabled={tooManyChoicesSelected || voting}> <i class="fa fa-envelope"></i> {__.toVote} </button> <button if="{voteInEdition}" class="c-button c-button--error" type="button" - onclick="{cancelEditVote}"> + tabindex="{(poll.choices.length + 2) * 10}" + onclick="{cancelEditVote}" + disabled={voting}> <i class="fa fa-remove"></i> {__.cancelEdition} </button> <button if="{voteInEdition}" class="c-button c-button--success" + tabindex="{(poll.choices.length + 1) * 10}" + disabled={tooManyChoicesSelected || voting} type="submit"> <i class="fa fa-check"></i> {__.validateEdition} @@ -125,14 +133,14 @@ require("../components/HumanInput.tag.html"); <button type="button" class="c-button c-button--rounded u-xsmall c-button--brand" if="{!poll.closed && vote.permission}" - disabled="{voteInEdition != null}" + disabled="{voteInEdition != null || voting}" onclick="{parent.onEditVote(vote)}"> <i class="fa fa-pencil-square-o"></i> </button> <button type="button" class="c-button c-button--rounded u-xsmall c-button--error" if="{poll.permission || !poll.closed && vote.permission}" - disabled="{voteInEdition != null}" + disabled="{voteInEdition != null || voting}" onclick="{parent.deleteVote(vote)}"> <i class="fa fa-trash"></i> </button> @@ -191,6 +199,7 @@ require("../components/HumanInput.tag.html"); choice: null, vote: null }; + this.voting = false; this.addingChoice = false; this.poll = require("../../js/Poll.js"); @@ -244,7 +253,7 @@ require("../components/HumanInput.tag.html"); input.checked = choice.voteValue === 1; } }); - this.refs.voterName.focus(); + this.refs[this.poll.choices[0].id + "_voteValue"].focus(); }; this.getChoiceVoteValue = ref => { @@ -292,6 +301,10 @@ require("../components/HumanInput.tag.html"); this.addVote = (e) => { e.preventDefault(); e.stopPropagation(); + + this.voting = true; + this.update(); + let vote = { id: null, voterName: this.refs.voterName.value, @@ -309,15 +322,21 @@ require("../components/HumanInput.tag.html"); this.resetPoll(); if (this.poll.resultIsVisible) { this.poll.loadResults().then(() => { + this.voting = false; this.updateShowChoiceContainer(); this.update(); + }, () => { + this.voting = false; + this.update(); }); } else { + this.voting = false; this.update(); } }, (error) => { this.error = error; + this.voting = false; this.update(); }); }; @@ -326,6 +345,9 @@ require("../components/HumanInput.tag.html"); e.preventDefault(); e.stopPropagation(); + this.voting = true; + this.update(); + let updateVote = Object.assign({}, this.voteInEdition); // don't modify original vote updateVote.voterName = this.refs.voterName.value; @@ -345,13 +367,19 @@ require("../components/HumanInput.tag.html"); this.resetPoll(); if (this.poll.resultIsVisible) { this.poll.loadResults().then(() => { + this.voting = false; + this.update(); + }, () => { + this.voting = false; this.update(); }); } else { + this.voting = false; this.update(); } }, (error) => { + this.voting = false; this.error = error; this.update(); }); @@ -360,11 +388,21 @@ require("../components/HumanInput.tag.html"); this.deleteVote = (vote) => (e) => { e.preventDefault(); e.stopPropagation(); + this.confirm(this.__.delete).then((confirm) => { if (confirm) { + this.voting = false; + this.update(); + this.poll.deleteVote(vote).then(() => { this.selectedChoiceNb = 0; this.updateShowChoiceContainer(); + this.voting = false; + this.update(); + }, + (error) => { + this.voting = false; + this.error = error; this.update(); }); } @@ -382,6 +420,7 @@ require("../components/HumanInput.tag.html"); this.poll.addChoice(this.choiceToAdd).then(() => { this.addingChoice = false; this.choiceToAdd = this.poll.initChoice(this.choiceToAdd); + this.updateShowChoiceContainer(); this.update(); }, errors => { this.addingChoice = false; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.