branch develop updated (63f86703 -> 4c2c30a2)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from 63f86703 verification du statut admin avant d'accéder aux tiers de connexion new 032a3006 fixes #145 Impossible de réouvrir un sondage ou de le cloner new 4c2c30a2 erreur quand on recharge une page réservée à l'admin The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 4c2c30a25e614409819790b0e9ed4d1ee0a1a01a Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 19 17:37:54 2017 +0200 erreur quand on recharge une page réservée à l'admin commit 032a30061885678abc13c451502730fc67834520 Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 19 17:13:41 2017 +0200 fixes #145 Impossible de réouvrir un sondage ou de le cloner Summary of changes: .../org/chorem/pollen/rest/api/v1/PollApi.java | 6 ++-- .../pollen/services/service/PollService.java | 3 +- pollen-ui-riot-js/src/main/web/js/Poll.js | 24 ---------------- pollen-ui-riot-js/src/main/web/js/PollForm.js | 23 ++++++++++++++++ pollen-ui-riot-js/src/main/web/js/Session.js | 20 ++++++++++++-- pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 32 +++++++++++----------- .../src/main/web/tag/poll/EditPoll.tag.html | 6 +++- .../src/main/web/tag/poll/Summary.tag.html | 4 +-- 8 files changed, 69 insertions(+), 49 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 032a30061885678abc13c451502730fc67834520 Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 19 17:13:41 2017 +0200 fixes #145 Impossible de réouvrir un sondage ou de le cloner --- .../org/chorem/pollen/rest/api/v1/PollApi.java | 6 +++--- .../pollen/services/service/PollService.java | 3 ++- pollen-ui-riot-js/src/main/web/js/Poll.js | 24 ---------------------- pollen-ui-riot-js/src/main/web/js/PollForm.js | 23 +++++++++++++++++++++ .../src/main/web/tag/poll/EditPoll.tag.html | 6 +++++- .../src/main/web/tag/poll/Summary.tag.html | 4 ++-- 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java index dcdc700f..1a28d9f5 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollApi.java @@ -49,6 +49,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.Date; import java.util.List; /** @@ -162,11 +163,10 @@ public class PollApi { @Path("/polls/{pollId}/close") @PUT - public void closePoll(@Context PollService pollService, + public Date closePoll(@Context PollService pollService, @PathParam("pollId") PollenEntityId<Poll> pollId) { - pollService.closePoll(pollId.getEntityId()); - + return pollService.closePoll(pollId.getEntityId()); } @Path("/polls/{pollId}/reopen") diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index abb5d74d..31c02bfc 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -322,7 +322,7 @@ public class PollService extends PollenServiceSupport { } - public void closePoll(String pollId) { + public Date closePoll(String pollId) { checkNotNull(pollId); checkPermission(PermissionVerb.closePoll, pollId); @@ -339,6 +339,7 @@ public class PollService extends PollenServiceSupport { getNotificationService().onPollClosed(poll); getFeedService().onPollClosed(poll); + return poll.getEndDate(); } public void reopenPoll(String pollId) { 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 6500acbb..3e84096c 100644 --- a/pollen-ui-riot-js/src/main/web/js/Poll.js +++ b/pollen-ui-riot-js/src/main/web/js/Poll.js @@ -267,30 +267,6 @@ class Poll { return Promise.reject("Init poll after load comments"); } - close() { - if (this.id) { - return pollService.closePoll(this.id, this.permission).then(() => { - this.closed = true; - this.canVote = false; - bus.trigger("poll", this); - return Promise.resolve(this); - }); - } - return Promise.reject("Init poll after close"); - } - - reopen() { - if (this.id) { - return pollService.reopenPoll(this.id, this.permission).then(() => { - this.closed = false; - this.canVote = true; - bus.trigger("poll", this); - return Promise.resolve(this); - }); - } - return Promise.reject("Init poll after reopen"); - } - addVote(vote) { if (this.id) { return voteService.addVote(this.id, vote, this.votePermission || this.permission).then((result) => { 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 b02734f0..ef2a2fda 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -299,6 +299,29 @@ class PollForm { }); } + close() { + if (this.model.id) { + return pollService.closePoll(this.model.id, this.permission).then((result) => { + this.model.closed = true; + this.model.canVote = false; + this.model.endDate = result; + return Promise.resolve(this); + }); + } + return Promise.reject("Init poll after close"); + } + + reopen() { + if (this.model.id) { + return pollService.reopenPoll(this.model.id, this.permission).then(() => { + this.model.closed = false; + this.model.canVote = true; + this.model.endDate = null; + return Promise.resolve(this); + }); + } + return Promise.reject("Init poll after reopen"); + } } 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 4a7f2142..f8654b33 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 @@ -45,7 +45,7 @@ require("../components/HumanInput.tag.html"); {getStepLabel(step)} </span> </div> - <div if="{showSummary}" class="tab selected"> + <div if="{showSummary || form.model.closed}" class="tab {selected: showSummary}" onclick="{doShowSummary}"> <button type="submit" class="cursor-pointer"> {__.summaryTab} </button> @@ -156,6 +156,10 @@ require("../components/HumanInput.tag.html"); this.callAfterSubmit = () => this.form.nextStep(); }; + this.doShowSummary = () => { + this.showSummary = true; + }; + this.savePoll = () => { this.callAfterSubmit = () => { let errorFn = errors => { diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html index 4efb8d97..8eb8048b 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Summary.tag.html @@ -117,7 +117,7 @@ require("../components/MultiLineLabel.tag.html"); this.closePoll = (e) => { e.preventDefault(); e.stopPropagation(); - this.opts.form.model.close().then(() => { + this.opts.form.close().then(() => { this.update(); }); }; @@ -125,7 +125,7 @@ require("../components/MultiLineLabel.tag.html"); this.reopenPoll = (e) => { e.preventDefault(); e.stopPropagation(); - this.opts.form.model.reopen().then(() => { + this.opts.form.reopen().then(() => { this.update(); }); }; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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 4c2c30a25e614409819790b0e9ed4d1ee0a1a01a Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 19 17:37:54 2017 +0200 erreur quand on recharge une page réservée à l'admin --- pollen-ui-riot-js/src/main/web/js/Session.js | 20 ++++++++++++-- pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 32 +++++++++++----------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/js/Session.js b/pollen-ui-riot-js/src/main/web/js/Session.js index 3524ec10..251dcd1c 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -127,8 +127,24 @@ class Session { return document.cookie.indexOf("pollen-connected=true") !== -1; } - isAdminConnected() { - return this.isConnected() && this.getUser().administrator; + isAdminConnected(callback, fallback) { + let userConnectedCallback = (user) => { + if (user.administrator) { + callback(); + } else { + fallback(); + } + bus.off("user", this); + }; + if (this.isConnected()) { + if (this.user) { + userConnectedCallback(this.user); + } else { + bus.on("user", userConnectedCallback); + } + } else { + fallback(); + } } connect() { 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 cf0c4fc5..b3ff983d 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 @@ -141,30 +141,30 @@ require("./popup/GtuChangeModal.tag.html"); }); route("/poll", () => { - if (!session.isAdminConnected()) { - route("/signin?url=/poll"); - } else { + session.isAdminConnected(() => { this.bus.trigger("pageChanged", "admin_polls"); riot.mount(this.refs.content, "polls", {method: "polls", session: session}); - } + }, () => { + route("/signin?url=/poll"); + }); }); route("/user", () => { - if (!session.isAdminConnected()) { - route("/signin?url=/user"); - } else { + session.isAdminConnected(() => { this.bus.trigger("pageChanged", "admin_users"); riot.mount(this.refs.content, "users", {session: session}); - } + }, () => { + route("/signin?url=/user"); + }); }); route("/gtu", () => { - if (!session.isAdminConnected()) { - route("/signin?url=/user"); - } else { + session.isAdminConnected(() => { this.bus.trigger("pageChanged", "admin_gtus"); riot.mount(this.refs.content, "gtus", {session: session}); - } + }, () => { + route("/signin?url=/user"); + }); }); route("/poll/*/choice", (pollId) => { @@ -241,12 +241,12 @@ require("./popup/GtuChangeModal.tag.html"); }); route("/loginProviders", () => { - if (!session.isAdminConnected()) { - route("/signin?url=/loginProviders"); - } else { + session.isAdminConnected(() => { this.bus.trigger("pageChanged", "loginProviders"); riot.mount(this.refs.content, "loginproviders"); - } + }, () => { + route("/signin?url=/loginProviders"); + }); }); route("/privacy", () => { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm