This is an automated email from the git hooks/post-receive script. New commit to branch feature/refonte-ui in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 347a87280a2bab916b9138ae7eee985f46de1272 Author: jcouteau <couteau@codelutin.com> Date: Tue May 12 08:59:09 2020 +0200 Hack to fix #332 : Really not clean, but working --- .../src/main/web/tag/poll/Poll.tag.html | 52 ++++++++++++++++------ 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html index 6a15b619..781a6bbc 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Poll.tag.html @@ -195,24 +195,50 @@ } }); - this.refresh = function() { - window.setInterval(function() { - if (this.poll) { - this.poll.reload(); - } - - //this.refresh(); - }, 1000); - }; - - this.refresh(); - this.refresh = () => { if (this.poll && this.poll.questions[0] && this.poll.questions[0].canVote) { + this.tempVoteValues = {}; + if(this.tags.votes) { + //Store temporary vote values + let refs = this.tags.votes.tags.editvote.refs; + this.poll.questions[0].choices.forEach(choice => { + let input = refs[choice.id + "_voteValue"]; + if (input && this.poll.questions[0].voteCountingTypeValue && this.poll.questions[0].voteCountingTypeValue.renderType === "text") { + this.tempVoteValues[choice.id] = input.value; + } else if (input && this.poll.questions[0].voteCountingTypeValue && this.poll.questions[0].voteCountingTypeValue.renderType === "select") { + if (input.find(option => option.selected)) { + this.tempVoteValues[choice.id] = input.find(option => option.selected).value; + } + } else { + this.tempVoteValues[choice.id] = input.checked; + } + }); + } + let promise = this.poll.reloadPoll(); promise.then(poll2 => { this.poll = poll2; - this.update(); + + this.poll.reloadVoteCountingTypeValue(this.poll.questions[0]).then(() => { + this.update(); + //Set back temporary stored values + if(this.tags.votes) { + let refs = this.tags.votes.tags.editvote.refs; + this.poll.questions[0].choices.forEach(choice => { + let input = refs[choice.id + "_voteValue"]; + if (input && this.poll.questions[0].voteCountingTypeValue && this.poll.questions[0].voteCountingTypeValue.renderType === "text") { + if (this.tempVoteValues[choice.id]) { + input.value = this.tempVoteValues[choice.id]; + } + } else if (input && this.poll.questions[0].voteCountingTypeValue && this.poll.questions[0].voteCountingTypeValue.renderType === "select") { + input.forEach(option => {option.selected = option.value === this.tempVoteValues[choice.id];}); + } else { + input.checked = this.tempVoteValues[choice.id]; + } + }); + } + this.tempVoteValues = {}; + }); }, () => {}); } }; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.