01/01: ref #225 : Erreur à la création d'un sondage avec un seul choix
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 651ca75403068cb2e8830811f629cf9527919c1b Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Fri Sep 7 15:24:45 2018 +0200 ref #225 : Erreur à la création d'un sondage avec un seul choix --- .../src/main/web/tag/poll/Choices.tag.html | 18 ++++++++++----- .../src/main/web/tag/poll/EditVoteOrder.tag.html | 26 +++++++++++++--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html index 65fae3ef..0dd56b94 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Choices.tag.html @@ -82,6 +82,12 @@ this.placeChoices(true); }); + this.getChoicesDragTab = () => { + return Array.isArray(this.refs.choicesDrag) ? this.refs.choicesDrag : ( + this.refs.choicesDrag ? [this.refs.choicesDrag] : [] + ); + } + this.placeChoices = noAnim => { if (!this.refs.choicesDrag) { return; @@ -92,7 +98,7 @@ let currentY = this.refs.choicesList.offsetTop; - let choicesDrag = this.refs.choicesDrag + let choicesDrag = this.getChoicesDragTab() .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)); for (let index = 0, l = choicesDrag.length; index < l; index++) { @@ -117,7 +123,7 @@ this.compatChoiceOrders = () => { let index = 0; - this.refs.choicesDrag + this.getChoicesDragTab() .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)) .forEach(choice1 => { choice1.choice.choiceOrder = index; @@ -127,7 +133,7 @@ this.dropChoice = (choiceElt, x, y) => { - let choicesDrag = this.refs.choicesDrag + let choicesDrag = this.getChoicesDragTab() .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)); choicesDrag.forEach(c => { @@ -153,7 +159,7 @@ this.submit(); this.form.choices.sort((c1, c2) => Math.sign(c1.choiceOrder - c2.choiceOrder)); this.update(); - (this.refs.choicesDrag || []) + this.getChoicesDragTab() .map(cd => cd.refs.choice) .forEach(choice => { choice.updateChoice(); @@ -167,7 +173,7 @@ this.form.addNewChoice(); this.update(); this.placeChoices(true); - let choices = (this.refs.choicesDrag || []) + let choices = this.getChoicesDragTab() .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)) .map(c => c.refs.choice); choices[choices.length - 1] && choices[choices.length - 1].focus(); @@ -184,7 +190,7 @@ }; this.submit = () => { - (this.refs.choicesDrag || []) + this.getChoicesDragTab() .map(cd => cd.refs.choice) .forEach(choice => { choice.submit(); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/EditVoteOrder.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/EditVoteOrder.tag.html index 7e108c81..7a65d2d3 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/EditVoteOrder.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/EditVoteOrder.tag.html @@ -147,6 +147,12 @@ } }); + this.getChoicesTab = () => { + return Array.isArray(this.refs.choices) ? this.refs.choices : ( + this.refs.choices ? [this.refs.choices] : [] + ); + } + this.placeChoices = noAnim => { if (!this.refs.choices) { return; @@ -160,7 +166,7 @@ let scaleCenterX = scale.offsetLeft + scale.offsetWidth / 2; - let choicesSelected = this.refs.choices + let choicesSelected = this.getChoicesTab() .filter(choice1 => choice1.voteOrder !== undefined) .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)); @@ -198,7 +204,7 @@ // on place les choix en attent sur la pile const dockOffset = 3; const dockChoiceVisibleMax = 3; - let nbDock = this.refs.choices + let nbDock = this.getChoicesTab() .filter(choice1 => choice1.voteOrder === undefined && !choice1.stashed) .length; let dockChoiceVisible = Math.min(dockChoiceVisibleMax, nbDock); @@ -210,7 +216,7 @@ this.orderedAllChoices = true; - this.refs.choices + this.getChoicesTab() .filter(choice => choice.voteOrder === undefined && !choice.stashed) .forEach(choice => { let offset = Math.min(0, (nbDock - dockChoiceVisible) - dockIndex) * dockOffset; @@ -230,7 +236,7 @@ let stashCenterX = stash.offsetLeft + stash.offsetWidth / 2; let stashHeight = 0; currentY = stash.offsetTop; - this.refs.choices + this.getChoicesTab() .filter(choice => choice.stashed) .sort((c1, c2) => Math.sign(c1.choice.choiceOrder - c2.choice.choiceOrder)) .forEach((choice) => { @@ -257,7 +263,7 @@ let yMax = scale.offsetTop + scale.offsetHeight - choiceElt.root.offsetHeight / 2; choiceElt.voteOrder = undefined; - let curentChoices = this.refs.choices + let curentChoices = this.getChoicesTab() .filter(choice1 => choice1.voteOrder !== undefined && choice1 !== choiceElt) .sort((c1, c2) => Math.sign(c1.getY() - c2.getY())); @@ -300,7 +306,7 @@ // on recompacte la liste pour ne plus avoir de trous dans les index; let newIndex = -1; let currentIndex = -1; - this.refs.choices + this.getChoicesTab() .filter(choice1 => choice1.voteOrder !== undefined) .sort((c1, c2) => Math.sign(c1.voteOrder - c2.voteOrder)) .forEach(choice1 => { @@ -315,7 +321,7 @@ this.resetVoteForm = () => { if (this.poll.canVote) { this.refs.voterName.value = null; - this.refs.choices.forEach(choice => { + this.getChoicesTab().forEach(choice => { choice.voteOrder = undefined; choice.stashed = false; }); @@ -334,7 +340,7 @@ } this.update(); this.refs.voterName.value = vote.voterName; - this.refs.choices.forEach(choiceElt => { + this.getChoicesTab().forEach(choiceElt => { let choice = vote.choice.find(c => c.choiceId === choiceElt.choice.id); if (!choice.voteValue) { choiceElt.voteOrder = undefined; @@ -356,7 +362,7 @@ vote = Object.assign({}, this.voteInEdition); // don't modify original vote vote.voterName = this.refs.voterName.value; - this.refs.choices.forEach(c => { + this.getChoicesTab().forEach(c => { let voteChoice = this.poll.getVoteChoice(vote, c.choice); if (!voteChoice) { voteChoice = { @@ -373,7 +379,7 @@ choice: [] }; - this.refs.choices.forEach(c => { + this.getChoicesTab().forEach(c => { vote.choice.push({ choiceId: c.choice.id, voteValue: c.voteOrder + 1 -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm