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 f8849fd9da3008eaba68b8c105a4ecdd5e6f31d4 Author: jcouteau <couteau@codelutin.com> Date: Thu Oct 10 16:03:37 2019 +0200 Keep its name from one question to another --- pollen-ui-riot-js/src/main/web/js/Poll.js | 4 ++ .../src/main/web/tag/poll/EditVote.tag.html | 48 ++++------------------ .../src/main/web/tag/poll/Vote.tag.html | 6 ++- .../src/main/web/tag/poll/Votes.tag.html | 3 ++ 4 files changed, 20 insertions(+), 41 deletions(-) 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 035d77b0..5cd74842 100644 --- a/pollen-ui-riot-js/src/main/web/js/Poll.js +++ b/pollen-ui-riot-js/src/main/web/js/Poll.js @@ -35,6 +35,7 @@ class Poll { constructor() { this.questions = []; this.comments = []; + this.multi = false; } init(pollId, voteId, permission) { @@ -44,6 +45,7 @@ class Poll { delete this.voteId; delete this.votePermission; Object.assign(this, result); + this.multi = this.questions.length > 1; this.voteId = voteId; this.votePermission = permission; this.comments = undefined; @@ -63,6 +65,7 @@ class Poll { if (this.id) { return pollService.getPoll(this.id, this.getPermission()).then(result => { Object.assign(this, result); + this.multi = this.questions.length > 1; bus.trigger("poll", this); return Promise.resolve(this); }); @@ -77,6 +80,7 @@ class Poll { delete this.permission; delete this._initPromise; this.comments = []; + this.multi = false; bus.trigger("poll", this); }); } 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 35cb12a1..a3a14bda 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 @@ -193,6 +193,8 @@ this.question = opts.question; + this.multi = opts.multi; + this.poll = poll; if (this.question) { this.poll.loadForVotes(this.question.id).then(() => { @@ -200,42 +202,6 @@ }); } - this.onPollChange = poll2 => { - //reload question - var _this = this; - if (_this.question) { - poll2.questions.forEach(function(question) { - if (_this.question.id === question.id) { - _this.question = question; - } - }); - } else { - _this.question = poll2.questions[0]; - } - - this.poll = poll2; - if (this.question) { - if (!this.question.voteCountingTypeValue) { - this.poll.reloadVoteCountingTypeValue(this.question).then(() => { - this.pollTypeCheckbox = this.question.voteCountingTypeValue && this.question.voteCountingTypeValue.renderType === "checkbox"; - this.pollTypeSelect = this.question.voteCountingTypeValue && this.question.voteCountingTypeValue.renderType === "select"; - this.pollTypeCoombs = this.question.voteCountingType && this.question.voteCountingType === 7; - }); - } else { - this.pollTypeCheckbox = this.question.voteCountingTypeValue && this.question.voteCountingTypeValue.renderType === "checkbox"; - this.pollTypeSelect = this.question.voteCountingTypeValue && this.question.voteCountingTypeValue.renderType === "select"; - this.pollTypeCoombs = this.question.voteCountingType && this.question.voteCountingType === 7; - } - this.resultsLoaded = this.question.results !== undefined; - if (!this.resultsLoaded) { - this.poll.loadResults(this.question.id).then(() => { - }); - } - this.onVoteChanged(); - } - this.update(); - }; - this.onQuestionChange = question2 => { this.question = question2; if (!this.question.voteCountingTypeValue) { @@ -254,14 +220,16 @@ this.poll.loadResults(this.question.id).then(() => { }); } - this.onVoteChanged(); + this.onVoteChanged(); this.update(); }; + this.onMultiChange = multi2 => { + this.multi = multi2; + }; - - //this.listen("poll", this.onPollChange); this.listen("question", this.onQuestionChange); + this.listen("multi", this.onMultiChange); this.listen("user", (user, oldUser) => { if (user !== oldUser) { if (user && this.refs.voterName && this.refs.voterName.value !== "") { @@ -351,7 +319,9 @@ this.resetVoteForm = () => { this.voteInEdition = null; if (this.question.canVote) { + if (!this.multi) { this.refs.voterName.value = null; + } this.question.choices.forEach(choice => { let input = this.refs[choice.id + "_voteValue"]; if (this.question.voteCountingTypeValue.renderType === "text") { diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Vote.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Vote.tag.html index 70b17408..01fea47c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Vote.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Vote.tag.html @@ -39,11 +39,13 @@ <EditVote ref="editVote" show={!isVoteByOrder || !voteClickAndDrop} on-save-vote={saveVote} - question="{question}"/> + question="{question}" + multi="{poll.multi}"/> <EditVoteOrder ref="editVoteOrder" show={isVoteByOrder && voteClickAndDrop} on-save-vote={saveVote} - question="{question}"/> + question="{question}" + multi="{poll.multi}"/> <!-- Form to vote --> <p class="warning-label warning" if="{loaded && !poll.canVote}"> 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 dcb4620a..ab8db88e 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 @@ -64,6 +64,9 @@ this.onPollChange = poll2 => { this.loaded = poll2.questions[0].choices !== undefined; this.poll = poll2; + if (this.poll.questions.length > 0) { + this.bus.trigger("multi", this.poll.questions.length > 1); + } this.question = this.poll.questions[this.questionToVote]; if (this.question) { this.bus.trigger("question", this.question); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.