This is an automated email from the git hooks/post-receive script. New commit to branch feature/72_poll_creation_confirmation in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit b261cb45466c092c2efe363a731d6d80bb2520ed Author: Kevin Morin <morin@codelutin.com> Date: Mon Jun 19 17:14:05 2017 +0200 refs #72 ajout d'autres types de message (pas seulement error) dans le toaster en bas à droite + affichage d'un message de succès de création et d'enregistrement + redirection vers le résumé plutôt que vers la page de vote --- pollen-ui-riot-js/src/main/web/conf.js | 2 +- pollen-ui-riot-js/src/main/web/i18n.json | 4 ++ .../src/main/web/js/{Error.js => Message.js} | 18 +++--- pollen-ui-riot-js/src/main/web/js/Poll.js | 2 +- pollen-ui-riot-js/src/main/web/tag/Pollen.tag.html | 6 +- .../src/main/web/tag/PollenErrorManager.tag.html | 66 ---------------------- .../src/main/web/tag/PollenMessageManager.tag.html | 66 ++++++++++++++++++++++ .../web/tag/favoriteList/FavoriteList.tag.html | 12 ++-- .../web/tag/favoriteList/FavoriteLists.tag.html | 2 +- .../src/main/web/tag/poll/EditPoll.tag.html | 9 ++- .../src/main/web/tag/poll/Poll.tag.html | 4 +- .../src/main/web/tag/poll/Summary.tag.html | 4 +- .../src/main/web/tag/poll/Votes.tag.html | 2 +- .../web/tag/voterList/VoterListActions.tag.html | 2 +- 14 files changed, 106 insertions(+), 93 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/conf.js b/pollen-ui-riot-js/src/main/web/conf.js index 4c710cd8..3579cf63 100644 --- a/pollen-ui-riot-js/src/main/web/conf.js +++ b/pollen-ui-riot-js/src/main/web/conf.js @@ -2,6 +2,6 @@ window.pollenConf = { endPoint: "http://felteu:8888/pollen-rest-api", piwikUrl: "", // add the piwik url, eg: http://localhost/piwik< piwikSiteId: "", // add the site id, eg: 3 - defaultErrorTimeout: 15, + defaultMessageTimeout: 15, resourceMaxSize: 10000000 // octets => 10 Mo }; diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index 5f07ea76..266f64c7 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -37,6 +37,8 @@ "poll_clonePoll": "Cloner le sondage", "poll_deletePoll": "Supprimer le sondage", "poll_editPoll": "Modifier le sondage", + "poll_creationSuccess": "Votre sondage {0} a été créé avec succès.", + "poll_saveSuccess": "Votre sondage {0} a été enregistré avec succès.", "poll_votes": "Votes", "poll_settings": "Configuration", "poll_choices": "Choix", @@ -673,6 +675,8 @@ "header_createDatePoll": "New date poll", "home_createOtherPoll": "New standard poll", "home_createDatePoll": "New date poll", + "poll_creationSuccess": "Your poll {0} has been successfully created.", + "poll_saveSuccess": "Your poll {0} has been successfully saved.", "poll_description_cancel": "Cancel", "poll_description_next": "Next", "poll_description_title": "Title", diff --git a/pollen-ui-riot-js/src/main/web/js/Error.js b/pollen-ui-riot-js/src/main/web/js/Message.js similarity index 76% rename from pollen-ui-riot-js/src/main/web/js/Error.js rename to pollen-ui-riot-js/src/main/web/js/Message.js index b4b82f63..4f6d598d 100644 --- a/pollen-ui-riot-js/src/main/web/js/Error.js +++ b/pollen-ui-riot-js/src/main/web/js/Message.js @@ -23,21 +23,25 @@ if (!Object.values) { values.shim(); } -class Error { +class Message { - constructor(e, timeout) { - if (e instanceof Error) { - this.message = e.message; + constructor(e, type, timeout) { + if (e instanceof Message) { + this.content = e.content; + this.type = e.type; this.timeout = e.timeout; } else if (typeof e === "string" || e instanceof String) { - this.message = e; + this.content = e; } else { - this.message = Object.values(e).reduce((messages, messagesfield) => messages.concat(messagesfield), []); + this.content = Object.values(e).reduce((messages, messagesfield) => messages.concat(messagesfield), []); } if (!this.timeout) { this.timeout = timeout; } + if (!this.type) { + this.type = type; + } } } -module.exports = Error; +module.exports = Message; 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 c85ce33b..2f764188 100644 --- a/pollen-ui-riot-js/src/main/web/js/Poll.js +++ b/pollen-ui-riot-js/src/main/web/js/Poll.js @@ -9,7 +9,7 @@ let commentService = require("./CommentService"); let Pagination = require("./Pagination"); let resourceService = require("./ResourceService"); let bus = require("./PollenBus.js"); -let Error = require("./Error"); +let Message = require("./Message"); let pageTracker = require("./PageTracker"); class Poll { 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 ed5d35f6..44754127 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 @@ -21,7 +21,7 @@ require("./PollenWaiter.tag.html"); require("./PollenHeader.tag.html"); require("./PollenFooter.tag.html"); -require("./PollenErrorManager.tag.html"); +require("./PollenMessageManager.tag.html"); require("./SignIn.tag.html"); require("./SignUp.tag.html"); require("./SignCheck.tag.html"); @@ -48,7 +48,7 @@ require("./popup/InformationPopup.tag.html"); <PollenFooter/> - <PollenErrorManager/> + <PollenMessageManager/> <script type="es6"> let session = require("../js/Session"); @@ -235,7 +235,7 @@ require("./popup/InformationPopup.tag.html"); position: relative; } - pollenerrormanager { + pollenmessagemanager { position: fixed; bottom: 20px; right: 0px; diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html deleted file mode 100644 index ea29f222..00000000 --- a/pollen-ui-riot-js/src/main/web/tag/PollenErrorManager.tag.html +++ /dev/null @@ -1,66 +0,0 @@ -<PollenErrorManager> - - <div each={error in errors} class="c-alert c-alert--error pollen-error" id="{error.id}"> - <button class="c-button c-button--close" onclick={closeError(error.id)}>×</button> - <span if={!Array.isArray(error.message)}> {error.message}</span> - <ul if={Array.isArray(error.message)}> - <li each={message in error.message}>{message}</li> - </ul> - </div> - - <script type="es6"> - let Error = require("../js/Error"); - let session = require("../js/Session"); - this.installBundle(session, "error_manager"); - - this.errorIndex = 0; - this.errors = []; - - this.handleErrors = (e) => { - var error = new Error(e); - if (!error.timeout) { - error.timeout = session.configuration.defaultErrorTimeout; - } - error.id = "error-" + this.errorIndex++; - - this.errors.push(error); - this.update(); - - setTimeout(() => { - this.closeError(error.id).apply(); - }, error.timeout * 1000); - }; - - this.on("mount", () => { - this.listen("error", this.handleErrors); - }); - - this.closeError = (errorId) => (e) => { - if (e) { - e.preventDefault(); - e.stopPropagation(); - } - - var errorElement = document.getElementById(errorId); - if (errorElement) { - errorElement.addEventListener("transitionend", () => { - errorElement.parentNode.removeChild(errorElement); - }); - errorElement.style.transform = "scaleY(0)"; - } - }; - - </script> - - <style> - .pollen-error { - width: 300px; - margin-right: 20px; - transform: scaleY(1); - transform-origin: 50% 100%; - transition: transform 0.5s; - } - - </style> - -</PollenErrorManager> diff --git a/pollen-ui-riot-js/src/main/web/tag/PollenMessageManager.tag.html b/pollen-ui-riot-js/src/main/web/tag/PollenMessageManager.tag.html new file mode 100644 index 00000000..8464d4e6 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/PollenMessageManager.tag.html @@ -0,0 +1,66 @@ +<PollenMessageManager> + + <div each={message in messages} class="pollen-message c-alert c-alert--{message.type}" id="{message.id}"> + <button class="c-button c-button--close" onclick={closeMessage(message.id)}>×</button> + <span if={!Array.isArray(message.content)}> {message.content}</span> + <ul if={Array.isArray(message.content)}> + <li each={label in message.content}>{label}</li> + </ul> + </div> + + <script type="es6"> + let Message = require("../js/Message"); + let session = require("../js/Session"); + this.installBundle(session, "error_manager"); + + this.messageIndex = 0; + this.messages = []; + + this.handleMessages = (e) => { + var message = new Message(e); + if (!message.timeout) { + message.timeout = session.configuration.defaultMessageTimeout; + } + message.id = "message-" + this.messageIndex++; + + this.messages.push(message); + this.update(); + + setTimeout(() => { + this.closeMessage(message.id).apply(); + }, message.timeout * 1000); + }; + + this.on("mount", () => { + this.listen("message", this.handleMessages); + }); + + this.closeMessage = (messageId) => (e) => { + if (e) { + e.preventDefault(); + e.stopPropagation(); + } + + var messageElement = document.getElementById(messageId); + if (messageElement) { + messageElement.addEventListener("transitionend", () => { + messageElement.parentNode.removeChild(messageElement); + }); + messageElement.style.transform = "scaleY(0)"; + } + }; + + </script> + + <style> + .pollen-message { + width: 300px; + margin-right: 20px; + transform: scaleY(1); + transform-origin: 50% 100%; + transition: transform 0.5s; + } + + </style> + +</PollenMessageManager> diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html index 09956572..f038cb97 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteList.tag.html @@ -306,7 +306,7 @@ require("./ChildListCard.tag.html"); this.refresh(); }, errors => { this.errors = errors; - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); } else { @@ -314,7 +314,7 @@ require("./ChildListCard.tag.html"); route("/favoriteLists/" + result.id); }, errors => { this.errors = errors; - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); } @@ -370,7 +370,7 @@ require("./ChildListCard.tag.html"); this.refresh(); }, errors => { this.addMemberErrors = errors; - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); }; @@ -385,7 +385,7 @@ require("./ChildListCard.tag.html"); this.refresh(); }, errors => { this.csvErrors = errors; - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); }; @@ -402,7 +402,7 @@ require("./ChildListCard.tag.html"); this.refresh(); }, errors => { this.ldapErrors = errors; - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); }; @@ -422,7 +422,7 @@ require("./ChildListCard.tag.html"); this.refresh(); }, errors => { this.childListErrors = errors; - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); }; diff --git a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteLists.tag.html b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteLists.tag.html index e3ecbdcf..3060fafd 100644 --- a/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteLists.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/favoriteList/FavoriteLists.tag.html @@ -136,7 +136,7 @@ require("./FavoriteListCard.tag.html"); this.refresh(); }, errors => { this.importErrors = errors; - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); }; 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 10972d11..d7dc2ee3 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 @@ -84,6 +84,7 @@ require("./Voters.tag.html"); this.session = require("../../js/Session"); this.installBundle(this.session, "poll"); this.form = require("../../js/PollForm"); + let Message = require("../../js/Message"); if (this.opts.pollId) { this.form.loadPoll(this.opts.pollId, this.opts.permission, this.opts.clone).then(() => { @@ -127,16 +128,20 @@ require("./Voters.tag.html"); this.savePoll = () => { this.callAfterSubmit = () => { let promiseSave; + let successMessage; if (this.form.creation) { promiseSave = this.form.create(); + successMessage = this._l("creationSuccess", this.form.model.title); } else { promiseSave = this.form.save(); + successMessage = this._l("saveSuccess", this.form.model.title); } promiseSave.then(() => { + this.bus.trigger("message", new Message(successMessage, "success")); let route = require("riot-route"); - route("poll/" + this.form.model.id + "/vote/" + this.form.model.permission); + route("poll/" + this.form.model.id + "/summary/" + this.form.model.permission); }, errors => { - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); 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 1252bc14..5db2f96e 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 @@ -165,7 +165,7 @@ require("./Report.tag.html"); <script type="es6"> this.session = require("../../js/Session"); - let Error = require("../../js/Error"); + let Message = require("../../js/Message"); let route = require("riot-route"); this.installBundle(this.session, "poll"); @@ -183,7 +183,7 @@ require("./Report.tag.html"); this.listen("poll", this.onPollChange); this.poll.init(this.opts.pollId, this.opts.voteId, this.opts.permission).catch((error) => { - this.bus.trigger("error", new Error(this._l(error.status))); + this.bus.trigger("message", new Message(this._l(error.status), "error")); route("/"); }); 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 be2481b1..eeeca6ad 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 @@ -111,7 +111,7 @@ require("../popup/QrCodeButton.tag.html"); <script type="es6"> this.session = require("../../js/Session"); - let Error = require("../../js/Error"); + let Message = require("../../js/Message"); let route = require("riot-route"); this.installBundle(this.session, "summary"); @@ -130,7 +130,7 @@ require("../popup/QrCodeButton.tag.html"); this.listen("poll", this.onPollChange); this.poll.init(this.opts.pollId, this.opts.voteId, this.opts.permission).catch((error) => { - this.bus.trigger("error", new Error(this._l(error.status))); + this.bus.trigger("message", new Message(this._l(error.status), "error")); route("/"); }).then(() => { this.poll.loadChoices(); 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 507aec83..0c6083b8 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 @@ -377,7 +377,7 @@ require("./Podium.tag.html"); this.choiceToAdd = this.poll.initChoice(this.choiceToAdd); this.update(); }, errors => { - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.update(); }); }; diff --git a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html index 7e3436eb..94559847 100644 --- a/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/voterList/VoterListActions.tag.html @@ -142,7 +142,7 @@ favoriteListsService.importFromVoterList(this.opts.voterList.id).then((result) => { route("/favoriteLists/" + result.id); }, errors => { - this.bus.trigger("error", errors); + this.bus.trigger("message", errors); this.parent.update(); }); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.