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 f6c8f9eeef9e10c3e700614c79b3938b89d64428 Author: Kevin Morin <morin@codelutin.com> Date: Thu Apr 20 17:22:50 2017 +0200 fixes #18 clone a poll --- pollen-ui-riot-js/src/main/web/i18n.json | 2 ++ pollen-ui-riot-js/src/main/web/js/PollForm.js | 35 ++++++++++++++++++---- pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 3 ++ .../src/main/web/tag/poll/EditPoll.tag.html | 2 +- .../src/main/web/tag/poll/Poll.tag.html | 4 +++ 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index 59ce4cc..0c69fd3 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -5,6 +5,7 @@ "poll_403": "Erreur : le sondage n'est pas accessible", "poll_closePoll": "Clôturer le sondage", "poll_reopenPoll": "Réouvrir le sondage", + "poll_clonePoll": "Cloner le sondage", "poll_deletePoll": "Supprimer le sondage", "poll_editPoll": "Modifier le sondage", "poll_votes": "Votes", @@ -380,6 +381,7 @@ "poll_settings": "Settings", "poll_closePoll": "Close poll", "poll_reopenPoll": "Reopen poll", + "poll_clonePoll": "Clone poll", "poll_deletePoll": "Delete poll", "poll_editPoll": "Edit poll", "poll_results": "Results", diff --git a/pollen-ui-riot-js/src/main/web/js/PollForm.js b/pollen-ui-riot-js/src/main/web/js/PollForm.js index dd00cd6..d71d181 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -58,19 +58,42 @@ class PollForm { return Promise.resolve(); } - loadPoll(pollId, permission) { + loadPoll(pollId, permission, clone) { return Promise.all([ pollService.getPoll(pollId, permission), choiceService.getChoices(pollId, permission), this._loadVoteCountingTypes() ]).then(results => { Object.assign(this.model, results[0]); - this.choices = results[1]; this.showOptions = true; - this.hasVotes = this.model.voteCount > 0; - this.model.alreadyParticipants = this.model.participants; - this.creation = false; - this.choicesToRemove = []; + this.creation = !!clone; + + if (clone) { + this.model.id = undefined; + this.model.voteCount = 0; + this.model.commentCount = 0; + this.model.createDate = undefined; + this.model.canVote = false; + this.model.isClosed = false; + this.model.alreadyParticipants = undefined; + this.model.permission = undefined; + this.model.status = undefined; + this.hasVotes = false; + + } else { + this.hasVotes = this.model.voteCount > 0; + this.model.alreadyParticipants = this.model.participants; + this.choicesToRemove = []; + } + + this.choices = results[1]; + if (clone) { + for (var i in this.choices) { + this.choices[i].id = undefined; + this.choices[i].permission = undefined; + } + } + this.step = 0; return Promise.resolve(this); }); diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html index 4c2fa0f..86db6ba 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html @@ -168,6 +168,9 @@ require("./favoriteList/FavoriteList.tag.html"); route("/poll/*/edit/*", (pollId, permission) => { riot.mount(this.refs.content, "editpoll", {pollId: pollId, permission: permission}); }); + route("/poll/*/clone/*", (pollId, permission) => { + riot.mount(this.refs.content, "editpoll", {pollId: pollId, permission: permission, clone: true}); + }); route("/poll/*", (pollId) => { riot.mount(this.refs.content, "poll", {pollId: pollId}); }); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html index e6c8b9e..57e6cd5 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html @@ -86,7 +86,7 @@ require("./Created.tag.html"); this.form = require("../../js/PollForm"); if (this.opts.pollId) { - this.form.loadPoll(this.opts.pollId, this.opts.permission).then(() => { + this.form.loadPoll(this.opts.pollId, this.opts.permission, this.opts.clone).then(() => { this.loaded = true; this.update(); }); 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 a9ddba5..c71da08 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 @@ -38,6 +38,10 @@ require("../popup/QrCodeButton.tag.html"); <a if="{poll.isClosed}" onclick="{reopenPoll}"> <i class="link fa fa-play"/> {__.reopenPoll}</a> + <a href="#/poll/{poll.id}/clone/{poll.permission}"> + <i class="link fa fa-clone"/> + {__.clonePoll} + </a> <a onclick="{deletePoll}"> <i class="link fa fa-trash"/> {__.deletePoll} -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.