branch feature/pollen-riot-js updated (5337f63 -> d653e81)
This is an automated email from the git hooks/post-receive script. New change to branch feature/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git from 5337f63 Add resendValidation backend + use now cookies to manage auth cache new e518f4b Can authentice via the cookie new ea74725 Use a package for poll tags + continue ui new d653e81 Suppression EmitterService (tout est dans la session), enfin on peut créer un sondage The 3 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 d653e813bc1c076567bd023b818ab3b31704139d Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 17 22:38:32 2017 +0100 Suppression EmitterService (tout est dans la session), enfin on peut créer un sondage commit ea74725be09823ead90c91e8c2afe215399d1a5d Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 17 08:56:56 2017 +0100 Use a package for poll tags + continue ui commit e518f4b9bccf11a45e11ff3284e123ba299da0b2 Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 17 08:56:35 2017 +0100 Can authentice via the cookie Summary of changes: pollen-persistence/src/main/xmi/pollen.zargo | Bin 20954 -> 21037 bytes .../rest/api/PollenRestApiRequestFilter.java | 47 +-- .../org/chorem/pollen/rest/api/v1/AuthApi.java | 54 ++- .../chorem/pollen/rest/api/v1/PollenUserApi.java | 10 +- pollen-rest-api/src/main/resources/mapping | 3 +- .../org/chorem/pollen/services/bean/PollBean.java | 17 + pollen-ui-riot-js/package.json | 4 +- pollen-ui-riot-js/src/main/web/conf.json | 3 +- pollen-ui-riot-js/src/main/web/css/main.css | 4 + pollen-ui-riot-js/src/main/web/i18n.json | 178 +++++++++- pollen-ui-riot-js/src/main/web/js/AuthService.js | 14 +- pollen-ui-riot-js/src/main/web/js/ChoiceText.js | 5 +- .../src/main/web/js/EmitterService.js | 49 --- pollen-ui-riot-js/src/main/web/js/FetchService.js | 12 +- pollen-ui-riot-js/src/main/web/js/I18nHelper.js | 18 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 75 ++-- pollen-ui-riot-js/src/main/web/js/PollService.js | 16 + pollen-ui-riot-js/src/main/web/js/Session.js | 77 +++- pollen-ui-riot-js/src/main/web/tag/CreatePoll.tag | 51 --- .../src/main/web/tag/CreatePollHeader.tag | 61 ---- pollen-ui-riot-js/src/main/web/tag/Footer.tag | 5 +- pollen-ui-riot-js/src/main/web/tag/Header.tag | 15 +- pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag | 13 +- pollen-ui-riot-js/src/main/web/tag/Home.tag | 29 +- .../src/main/web/tag/PollChoiceText.tag | 39 -- .../src/main/web/tag/PollChoiceTextGroup.tag | 14 - .../src/main/web/tag/PollDescription.tag | 53 --- .../src/main/web/tag/PollSettings.tag | 35 -- pollen-ui-riot-js/src/main/web/tag/PollVoters.tag | 46 --- pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 20 +- pollen-ui-riot-js/src/main/web/tag/SignCheck.tag | 8 +- pollen-ui-riot-js/src/main/web/tag/SignIn.tag | 11 +- pollen-ui-riot-js/src/main/web/tag/SignUp.tag | 9 +- .../src/main/web/tag/poll/CreatePoll.tag | 180 ++++++++++ .../src/main/web/tag/poll/PollChoiceText.tag | 40 +++ .../src/main/web/tag/poll/PollChoiceTextGroup.tag | 13 + .../main/web/tag/{ => poll}/PollChoicesDate.tag | 12 +- .../main/web/tag/{ => poll}/PollChoicesImage.tag | 12 +- .../main/web/tag/{ => poll}/PollChoicesText.tag | 60 ++-- .../src/main/web/tag/poll/PollCreated.tag | 40 +++ .../src/main/web/tag/poll/PollDescription.tag | 59 +++ .../src/main/web/tag/poll/PollSettings.tag | 394 +++++++++++++++++++++ .../src/main/web/tag/poll/PollVoters.tag | 185 ++++++++++ .../src/main/web/tag/popup/AccountCreated.tag | 8 +- .../src/main/web/tag/popup/NewPassword.tag | 8 +- .../src/main/web/tag/popup/ResendValidation.tag | 9 +- pollen-ui-riot-js/webpack.config.js | 5 + 47 files changed, 1431 insertions(+), 589 deletions(-) delete mode 100644 pollen-ui-riot-js/src/main/web/js/EmitterService.js create mode 100644 pollen-ui-riot-js/src/main/web/js/PollService.js delete mode 100644 pollen-ui-riot-js/src/main/web/tag/CreatePoll.tag delete mode 100644 pollen-ui-riot-js/src/main/web/tag/CreatePollHeader.tag delete mode 100644 pollen-ui-riot-js/src/main/web/tag/PollChoiceText.tag delete mode 100644 pollen-ui-riot-js/src/main/web/tag/PollChoiceTextGroup.tag delete mode 100644 pollen-ui-riot-js/src/main/web/tag/PollDescription.tag delete mode 100644 pollen-ui-riot-js/src/main/web/tag/PollSettings.tag delete mode 100644 pollen-ui-riot-js/src/main/web/tag/PollVoters.tag create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceText.tag create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceTextGroup.tag rename pollen-ui-riot-js/src/main/web/tag/{ => poll}/PollChoicesDate.tag (71%) rename pollen-ui-riot-js/src/main/web/tag/{ => poll}/PollChoicesImage.tag (71%) rename pollen-ui-riot-js/src/main/web/tag/{ => poll}/PollChoicesText.tag (52%) create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/PollCreated.tag create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag create mode 100644 pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag -- 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 feature/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit e518f4b9bccf11a45e11ff3284e123ba299da0b2 Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 17 08:56:35 2017 +0100 Can authentice via the cookie --- .../rest/api/PollenRestApiRequestFilter.java | 47 +------------------ .../org/chorem/pollen/rest/api/v1/AuthApi.java | 54 ++++++++++++++++++---- .../chorem/pollen/rest/api/v1/PollenUserApi.java | 10 +++- pollen-rest-api/src/main/resources/mapping | 1 + 4 files changed, 58 insertions(+), 54 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java index eb64c6c..39055b9 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java @@ -39,11 +39,12 @@ import org.debux.webmotion.server.call.HttpContext; import org.debux.webmotion.server.render.Render; import org.debux.webmotion.server.render.RenderStatus; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; import java.util.Locale; import java.util.Map; +import static org.chorem.pollen.rest.api.v1.AuthApi.COOKIE_POLLEN_AUTH; + /** * Inject {@link PollenRestApiRequestContext} in services. * @@ -55,10 +56,6 @@ public class PollenRestApiRequestFilter extends WebMotionFilter { private static final String HEADER_ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; private static final String HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; - private static final String COOKIE_POLLEN_AUTH = "pollen-auth"; - private static final String COOKIE_POLLEN_CONNECTED = "pollen-connected"; - private final static int COOKIE_MAX_AGE = 60 * 60 * 24 * 365; // 1 year - public static final String REQUEST_PERMISSION_PARAMETER = "permission"; public static final String REQUEST_HEADER_SESSION_TOKEN = "X-Pollen-Session-Token"; @@ -102,46 +99,6 @@ public class PollenRestApiRequestFilter extends WebMotionFilter { doProcess(); - PollenSecurityContext securityContext = pollenRestApiRequestContext.getSecurityContext(); - if (securityContext.isConnected()) { - - // add auth cookies - - SessionToken sessionToken = securityContext.getSessionToken(); - String value = pollenRestApiRequestContext.getSecurityService().encrypt( - sessionToken.getPollenUser().getTopiaId(), - sessionToken.getPollenToken().getToken() - ); - Cookie authCookie = new Cookie(COOKIE_POLLEN_AUTH, value); - authCookie.setPath("/"); - authCookie.setMaxAge(COOKIE_MAX_AGE); - response.addCookie(authCookie); - - Cookie connectedCookie = new Cookie(COOKIE_POLLEN_CONNECTED, "true"); - connectedCookie.setPath("/"); - connectedCookie.setMaxAge(COOKIE_MAX_AGE); - response.addCookie(connectedCookie); - - if (log.isDebugEnabled()) { - log.debug("Add auth cookie:: " + authCookie.getValue()); - } - - } else { - - // remove auth cookies - - Cookie authCookie = new Cookie(COOKIE_POLLEN_AUTH, ""); - authCookie.setPath("/"); - authCookie.setMaxAge(0); - response.addCookie(authCookie); - - Cookie connectedCookie = new Cookie(COOKIE_POLLEN_CONNECTED, ""); - connectedCookie.setPath("/"); - connectedCookie.setMaxAge(0); - response.addCookie(connectedCookie); - - } - } private PollenRestApiRequestContext prepareRequestContext(HttpContext context) throws PollenInvalidSessionTokenException, PollenCypherTechnicalException { diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java index 79f05c1..5f2d0c3 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/AuthApi.java @@ -25,23 +25,22 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.shiro.codec.Base64; -import org.chorem.pollen.persistence.entity.PollenToken; -import org.chorem.pollen.persistence.entity.PollenTokenImpl; import org.chorem.pollen.persistence.entity.PollenUser; import org.chorem.pollen.persistence.entity.SessionToken; -import org.chorem.pollen.persistence.entity.SessionTokenImpl; import org.chorem.pollen.rest.api.PollenRestApiRequestContext; import org.chorem.pollen.services.bean.PollenEntityRef; import org.chorem.pollen.services.service.PollenUserService; -import org.chorem.pollen.services.service.security.DefaultPollenSecurityContext; import org.chorem.pollen.services.service.security.MissingAuthenticationException; import org.chorem.pollen.services.service.security.PollenAuthenticationException; -import org.chorem.pollen.services.service.security.PollenInvalidEmailActivationTokenException; +import org.chorem.pollen.services.service.security.PollenCypherTechnicalException; import org.chorem.pollen.services.service.security.PollenInvalidSessionTokenException; import org.chorem.pollen.services.service.security.SecurityService; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.call.HttpContext; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; + /** * TODO * @@ -53,7 +52,11 @@ public class AuthApi extends WebMotionController { /** Logger */ private static final Log log = LogFactory.getLog(AuthApi.class); - public PollenEntityRef<PollenUser> login(HttpContext requestContext, SecurityService securityService) throws PollenAuthenticationException, MissingAuthenticationException, PollenInvalidSessionTokenException { + public static final String COOKIE_POLLEN_AUTH = "pollen-auth"; + private static final String COOKIE_POLLEN_CONNECTED = "pollen-connected"; + private final static int COOKIE_MAX_AGE = 60 * 60 * 24 * 365; // 1 year + + public PollenEntityRef<PollenUser> login(HttpContext requestContext, SecurityService securityService) throws PollenAuthenticationException, MissingAuthenticationException, PollenInvalidSessionTokenException, PollenCypherTechnicalException { String authHeader = requestContext.getHeader("Authorization"); @@ -72,8 +75,31 @@ public class AuthApi extends WebMotionController { // Inject the session token in security context PollenRestApiRequestContext pollenRestApiRequestContext = PollenRestApiRequestContext.getRequestContext(requestContext); - SessionToken sessionTokenByToken = securityService.getSessionTokenByToken(userPollenEntityRef.getPermission()); - pollenRestApiRequestContext.getSecurityContext().setSessionToken(sessionTokenByToken); + SessionToken sessionToken = securityService.getSessionTokenByToken(userPollenEntityRef.getPermission()); + + pollenRestApiRequestContext.getSecurityContext().setSessionToken(sessionToken); + + // add auth cookies + + String value = pollenRestApiRequestContext.getSecurityService().encrypt( + sessionToken.getPollenUser().getTopiaId(), + sessionToken.getPollenToken().getToken() + ); + HttpServletResponse response = requestContext.getResponse(); + + Cookie authCookie = new Cookie(COOKIE_POLLEN_AUTH, value); + authCookie.setPath("/"); + authCookie.setMaxAge(COOKIE_MAX_AGE); + response.addCookie(authCookie); + + Cookie connectedCookie = new Cookie(COOKIE_POLLEN_CONNECTED, "true"); + connectedCookie.setPath("/"); + connectedCookie.setMaxAge(COOKIE_MAX_AGE); + response.addCookie(connectedCookie); + + if (log.isDebugEnabled()) { + log.debug("Add auth cookie:: " + authCookie.getValue()); + } return userPollenEntityRef; } @@ -95,6 +121,18 @@ public class AuthApi extends WebMotionController { // Remove the session token from security context PollenRestApiRequestContext.getRequestContext(requestContext).getSecurityContext().setSessionToken(null); + HttpServletResponse response = requestContext.getResponse(); + + Cookie authCookie = new Cookie(COOKIE_POLLEN_AUTH, ""); + authCookie.setPath("/"); + authCookie.setMaxAge(0); + response.addCookie(authCookie); + + Cookie connectedCookie = new Cookie(COOKIE_POLLEN_CONNECTED, ""); + connectedCookie.setPath("/"); + connectedCookie.setMaxAge(0); + response.addCookie(connectedCookie); + } public void lostPassword(SecurityService securityService, String login) { diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java index 2ae88d8..3b1ac5d 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java @@ -22,16 +22,17 @@ package org.chorem.pollen.rest.api.v1; */ import org.chorem.pollen.persistence.entity.PollenUser; +import org.chorem.pollen.rest.api.PollenRestApiRequestContext; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PaginationResultBean; import org.chorem.pollen.services.bean.PollenEntityId; import org.chorem.pollen.services.bean.PollenEntityRef; import org.chorem.pollen.services.bean.PollenUserBean; import org.chorem.pollen.services.service.InvalidFormException; -import org.chorem.pollen.services.service.NotificationService; import org.chorem.pollen.services.service.PollenUserService; import org.chorem.pollen.services.service.security.PollenInvalidEmailActivationTokenException; import org.debux.webmotion.server.WebMotionController; +import org.debux.webmotion.server.call.HttpContext; /** * TODO @@ -47,6 +48,13 @@ public class PollenUserApi extends WebMotionController { } + public PollenUserBean getConnectedUser(HttpContext context, PollenUserService pollenUserService) { + PollenRestApiRequestContext pollenRestApiRequestContext = PollenRestApiRequestContext.getRequestContext(context); + PollenUser pollenUser = pollenRestApiRequestContext.getSecurityContext().getPollenUser(); + return pollenUserService.getUser(pollenUser.getTopiaId()); + + } + public PollenUserBean getUser(PollenUserService pollenUserService, PollenEntityId<PollenUser> userId) { return pollenUserService.getUser(userId.getEntityId()); diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index e68db7b..83822b2 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -132,6 +132,7 @@ GET /v1/resources/{resourceId}/{n} forward:/v1/resources/{resour # PollenUserApi GET /v1/users PollenUserApi.getUsers +GET /v1/users/connected PollenUserApi.getConnectedUser GET /v1/users/{userId} PollenUserApi.getUser POST /v1/users PollenUserApi.createUser POST /v1/users/{userId} PollenUserApi.editUser -- 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 feature/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit ea74725be09823ead90c91e8c2afe215399d1a5d Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 17 08:56:56 2017 +0100 Use a package for poll tags + continue ui --- pollen-ui-riot-js/package.json | 4 +- pollen-ui-riot-js/src/main/web/css/main.css | 4 + pollen-ui-riot-js/src/main/web/i18n.json | 16 ++ pollen-ui-riot-js/src/main/web/js/AuthService.js | 4 + pollen-ui-riot-js/src/main/web/js/I18nHelper.js | 2 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 20 +- pollen-ui-riot-js/src/main/web/js/Session.js | 18 +- pollen-ui-riot-js/src/main/web/tag/CreatePoll.tag | 51 ---- .../src/main/web/tag/CreatePollHeader.tag | 61 ---- pollen-ui-riot-js/src/main/web/tag/Home.tag | 25 +- .../src/main/web/tag/PollSettings.tag | 35 --- pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 17 +- .../src/main/web/tag/poll/CreatePoll.tag | 92 ++++++ .../src/main/web/tag/{ => poll}/PollChoiceText.tag | 0 .../web/tag/{ => poll}/PollChoiceTextGroup.tag | 0 .../main/web/tag/{ => poll}/PollChoicesDate.tag | 12 +- .../main/web/tag/{ => poll}/PollChoicesImage.tag | 12 +- .../main/web/tag/{ => poll}/PollChoicesText.tag | 44 ++- .../main/web/tag/{ => poll}/PollDescription.tag | 19 +- .../src/main/web/tag/poll/PollSettings.tag | 314 +++++++++++++++++++++ .../src/main/web/tag/{ => poll}/PollVoters.tag | 12 +- pollen-ui-riot-js/webpack.config.js | 5 + 22 files changed, 532 insertions(+), 235 deletions(-) diff --git a/pollen-ui-riot-js/package.json b/pollen-ui-riot-js/package.json index e4e68f6..359a232 100644 --- a/pollen-ui-riot-js/package.json +++ b/pollen-ui-riot-js/package.json @@ -33,8 +33,8 @@ "fsevents": "^1.0.17" }, "dependencies": { + "font-awesome": "4.6.3", "riot": "^3.0.5", - "riot-route": "^2.5.0", - "font-awesome": "4.6.3" + "riot-route": "^2.5.0" } } diff --git a/pollen-ui-riot-js/src/main/web/css/main.css b/pollen-ui-riot-js/src/main/web/css/main.css index f9fad08..5047d82 100644 --- a/pollen-ui-riot-js/src/main/web/css/main.css +++ b/pollen-ui-riot-js/src/main/web/css/main.css @@ -37,6 +37,10 @@ margin-bottom: 30px; } +a.mainColorBackground, input.mainColorBackground { + background-color: #13a2ff; +} + a { text-decoration: none; color: #13a2ff; diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index 702e428..f54d573 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -53,6 +53,14 @@ "home_createTextPoll": "Créer un sondage de type text", "home_createImagePoll": "Créer un sondage de type image", "home_createDatePoll": "Créer un sondage de type date", + "poll_settings_basic_usage":"Pour un sondage simple, vous pouvez passer cette étape.", + "poll_settings_previous":"Précédent", + "poll_settings_next":"Continuer", + "poll_settings_skip":"Passer", + "poll_header_general":"Description", + "poll_header_choices":"Choix", + "poll_header_options":"Options", + "poll_header_voters":"Participants", "": "" }, "en": { @@ -109,6 +117,14 @@ "home_createTextPoll": "Create a text poll", "home_createImagePoll": "Create a image poll", "home_createDatePoll": "Create a date poll", + "poll_settings_basic_usage":"For a basic poll, you can skip this step.", + "poll_settings_previous":"Previous", + "poll_settings_next":"Continue", + "poll_settings_skip":"Skip", + "poll_header_general":"General", + "poll_header_choices":"Choices", + "poll_header_options":"Options", + "poll_header_voters":"Voters", "": "" } } \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/js/AuthService.js b/pollen-ui-riot-js/src/main/web/js/AuthService.js index 683e499..1aca463 100644 --- a/pollen-ui-riot-js/src/main/web/js/AuthService.js +++ b/pollen-ui-riot-js/src/main/web/js/AuthService.js @@ -30,6 +30,10 @@ class AuthService extends FetchService { return this.get("/v1/users/" + auth.id); } + connectedUserPromise() { + return this.get("/v1/users/connected"); + } + validateEmail(userId, token) { return this.put("/v1/users/" + userId + "?token=" + token); } diff --git a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js index d91991b..376f117 100644 --- a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js +++ b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js @@ -25,7 +25,7 @@ module.exports = { let realKey = key.substring(value.length + 1); this.__[realKey] = bundle[key]; - console.info(realKey + " -> " + this.__[realKey]); + console.debug(realKey + " -> " + this.__[realKey]); } }); }, 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 0613862..630c8bd 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -1,24 +1,28 @@ let singleton = require("./Singleton"); let ChoiceText = require('./ChoiceText'); +let route = require("riot-route"); class PollForm { constructor() { - riot.observable(this); this.step = 0; + this.type = null; this.model = null; } previousStep() { - this._setStep(this.step - 1); + + console.info("prevousStep:: "+this.step); + this.setStep(this.step - 1); } nextStep() { - this._setStep(this.step + 1); + this.setStep(this.step + 1); } init(user) { console.info("init form"); + this.step = 0; this.model = { title: "Mon premier sondage", description: "", @@ -35,10 +39,6 @@ class PollForm { } } - onStepChanged(fn) { - this.on("stepChanged", fn); - } - fromTextChoices(form) { let choices = []; @@ -66,10 +66,10 @@ class PollForm { this.model.textChoices = choices; } - _setStep(step) { - console.info("set step:: " + step); + setStep(step) { + console.info("setStep:: " + step); this.step = step; - this.trigger("stepChanged", step); + route("poll/new/" + this.type + "/" + step, null, true); } } 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 2b25621..6ae934f 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -26,6 +26,22 @@ class Session { return document.cookie.indexOf("pollen-connected=true") !== -1; } + connect(userService) { + console.info("Connect::"); + userService.connectedUserPromise().then((user) => { + if (!user) { + console.info("Connect error"); + this.user = null; + return Promise.reject(); + } + console.info("Connect user::"); + console.info(user); + this.user = user; + emitter.emitConnected(user); + return user; + }); + } + signIn(auth, userService) { console.info("SignIn::"); console.info(auth); @@ -36,9 +52,9 @@ class Session { return Promise.reject(); } console.info("SignIn user::"); + console.info(user); this.user = user; emitter.emitConnected(user); - console.info(user); return user; }); diff --git a/pollen-ui-riot-js/src/main/web/tag/CreatePoll.tag b/pollen-ui-riot-js/src/main/web/tag/CreatePoll.tag deleted file mode 100644 index 91a4d9a..0000000 --- a/pollen-ui-riot-js/src/main/web/tag/CreatePoll.tag +++ /dev/null @@ -1,51 +0,0 @@ -let route = require("riot-route"); -let authService = require("../js/AuthService"); -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); -let form = require("../js/PollForm"); - -require("./CreatePollHeader.tag"); -require("./PollDescription.tag"); -require("./PollChoicesText.tag"); -require("./PollChoicesImage.tag"); -require("./PollChoicesDate.tag"); -require("./PollSettings.tag"); -require("./PollVoters.tag"); - -<CreatePoll> - - <div> - <CreatePollHeader/> - <div> - <PollDescription show="{step == 0}"/> - <PollChoicesText show="{step == 1 && type == 'text'}"/> - <PollChoicesImage show="{step == 1 && type == 'image'}"/> - <PollChoicesDate show="{step == 1 && type == 'date'}"/> - <PollSettings show="{step == 2}"/> - <PollVoters show="{step == 3}"/> - </div> - </div> - - <script> - this.type = this.opts.type; - this.step = form.step; - if (session.isConnected()) { - form.init(session.user); - } else { - form.init(); - } - form.onStepChanged(step => { - this.step = step; - try { - this.update() - } catch (e) { - //FIXME J'ai une erreur, mais je ne sais pas quoi en faire... - console.error("Could not update on Create poll: ", e); - } - }); - </script> - <style> - - </style> - -</CreatePoll> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/CreatePollHeader.tag b/pollen-ui-riot-js/src/main/web/tag/CreatePollHeader.tag deleted file mode 100644 index 4bfd050..0000000 --- a/pollen-ui-riot-js/src/main/web/tag/CreatePollHeader.tag +++ /dev/null @@ -1,61 +0,0 @@ -let form = require("../js/PollForm"); -<CreatePollHeader> - <div class="container"> - <div class="{step == 0 ? 'selectedTab' : ''}"> - <span class="fa-stack fa-2x"> - <i class="fa fa-circle-o fa-stack-2x"></i> - <strong class="fa-stack-1x">1</strong> - </span> - Description du sondage - </div> - <div class="{step == 1 ? 'selectedTab' : ''}"> - <span class="fa-stack fa-2x"> - <i class="fa fa-circle-o fa-stack-2x"></i> - <strong class="fa-stack-1x">2</strong> - </span> - Choix du sondage - </div> - <div class="{step == 2 ? 'selectedTab' : ''}"> - <span class="fa-stack fa-2x"> - <i class="fa fa-circle-o fa-stack-2x"></i> - <strong class="fa-stack-1x">3</strong> - </span> - Options du sondage - </div> - <div class="{step == 3 ? 'selectedTab' : ''}"> - <span class="fa-stack fa-2x"> - <i class="fa fa-circle-o fa-stack-2x"></i> - <strong class="fa-stack-1x">4</strong> - </span> - Participants au sondage - </div> - </div> - - <script> - this.step = form.step; - form.onStepChanged(step => { - this.step = step; - this.update() - }); - </script> - - <style> - .container { - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: center; - margin-bottom: 30px; - border-bottom: 1px solid #b2c7d3; - } - - .container > div { - margin-left: 12px; - margin-right: 12px; - } - - .selectedTab { - color: #13a2ff; - } - </style> -</CreatePollHeader> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/Home.tag b/pollen-ui-riot-js/src/main/web/tag/Home.tag index 4fb2fbd..836f817 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Home.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Home.tag @@ -1,29 +1,32 @@ -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); -let route = require("riot-route"); - - <Home> <div class="body-container"> <div class="split"> - <div onclick="{createText}"><a href="/poll/new/text">{__.createTextPoll}</a></div> - <div onclick="{createImage}"><a href="/poll/new/image">{__.createImagePoll}</a></div> - <div onclick="{createDate}"><a href="/poll/new/date">{__.createDatePoll}</a></div> + <div onclick="{createText}">{__.createTextPoll}</div> + <div onclick="{createImage}">{__.createImagePoll}</div> + <div onclick="{createDate}">{__.createDatePoll}</div> </div> </div> <script> + let session = require("../js/Session"); + let emitter = require("../js/EmitterService"); + let form = require("../js/PollForm"); + let route = require("riot-route"); + this.installBundle(session.locale, "home", emitter); this.createText = () => { - route("/poll/new/text"); + form.init(session.user); + route("/poll/new/text/0"); }; this.createImage = () => { - route("/poll/new/image"); + form.init(session.user); + route("/poll/new/image/0"); }; this.createDate = () => { - route("/poll/new/date"); + form.init(session.user); + route("/poll/new/date/0"); }; </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/PollSettings.tag b/pollen-ui-riot-js/src/main/web/tag/PollSettings.tag deleted file mode 100644 index d8068fa..0000000 --- a/pollen-ui-riot-js/src/main/web/tag/PollSettings.tag +++ /dev/null @@ -1,35 +0,0 @@ -let form = require("../js/PollForm"); - -<PollSettings> - <div> - Options du sondage - </div> - <div class="actions"> - <a class="button" onclick="{previousStep}">Précédent</a> - <a class="button" onclick="{nextStep}">Suivant</a> - </div> - - <script> - this.previousStep = (e) => { - form.previousStep(); - }; - this.nextStep = (e) => { - form.nextStep(); - }; - </script> - <style> - .actions { - margin-top: 50px; - margin-right: 10px; - margin-left: 10px; - margin-bottom: 10px; - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: center; - } - .actions > a { - margin: 5px; - } - </style> -</PollSettings> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag index f9100c5..19f89f0 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag @@ -4,17 +4,20 @@ require("./SignIn.tag"); require("./SignUp.tag"); require("./SignCheck.tag"); require("./Home.tag"); -require("./CreatePoll.tag"); - -let route = require("riot-route"); -let emitter = require("../js/EmitterService"); - +require("./poll/CreatePoll.tag"); <Pollen class="body-wrapper"> <Header></Header> <div class="body-content" ref="content"></div> <Footer></Footer> <script> + let emitter = require("../js/EmitterService"); + let session = require("../js/Session"); + let route = require("riot-route"); + + if (session.isConnected()) { + session.connect(require("../js/AuthService")); + } route("/poll/create", () => { riot.mount(this.refs.content, "createpoll"); @@ -46,8 +49,8 @@ let emitter = require("../js/EmitterService"); route("/user/favoriteList", () => { riot.mount(this.refs.content, "userfavoritelists"); }); - route("/poll/new/*", (type) => { - riot.mount(this.refs.content, "createpoll", {type: type}); + route("/poll/new/*/*", (type, step) => { + riot.mount(this.refs.content, "createpoll", {type: type, step:step}); }); route( () => { riot.mount(this.refs.content, "home"); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag new file mode 100644 index 0000000..76dcb10 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag @@ -0,0 +1,92 @@ +require("./PollDescription.tag"); +require("./PollChoicesText.tag"); +require("./PollChoicesImage.tag"); +require("./PollChoicesDate.tag"); +require("./PollSettings.tag"); +require("./PollVoters.tag"); + +<CreatePoll> + <div> + <div class="header-container"> + <div class="{step == 0 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">1</strong> + </span> + {__.header_general} + </div> + <div class="{step == 1 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">2</strong> + </span> + {__.header_choices} + </div> + <div class="{step == 2 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">3</strong> + </span> + {__.header_options} + </div> + <div class="{step == 3 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">4</strong> + </span> + {__.header_voters} + </div> + </div> + <div> + <PollDescription if="{step == 0}" form="{form}" session="{session}" emitter="{emitter}"/> + <PollChoicesText if="{step == 1 && type == 'text'}" form="{form}" session="{session}" emitter="{emitter}"/> + <PollChoicesImage if="{step == 1 && type == 'image'}" form="{form}" session="{session}" + emitter="{emitter}"/> + <PollChoicesDate if="{step == 1 && type == 'date'}" form="{form}" session="{session}" emitter="{emitter}"/> + <PollSettings if="{step == 2}" form="{form}" session="{session}" emitter="{emitter}"/> + <PollVoters if="{step == 3}" form="{form}" session="{session}" emitter="{emitter}"/> + </div> + </div> + + <script> + this.type = opts.type; + this.form = require("../../js/PollForm"); + this.emitter = require("../../js/EmitterService"); + this.session = require("../../js/Session"); + this.form.type = this.type; + this.installBundle(this.session.locale, "poll", this.emitter); + + if (!this.form.model) { + this.form.init(this.session.user); + this.form.setStep(0); + } else if (opts.step) { + this.form.step = parseInt(opts.step); + } + this.step = this.form.step; + console.info("Current step!!!!!! " + this.step); + + </script> + <style> + + .header-container { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + margin-bottom: 30px; + border-bottom: 1px solid #b2c7d3; + } + + .header-container > div { + margin-left: 12px; + margin-right: 12px; + width: 160px; + } + + .header-selected-tab { + color: #13a2ff; + } + + </style> + +</CreatePoll> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/PollChoiceText.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceText.tag similarity index 100% rename from pollen-ui-riot-js/src/main/web/tag/PollChoiceText.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceText.tag diff --git a/pollen-ui-riot-js/src/main/web/tag/PollChoiceTextGroup.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceTextGroup.tag similarity index 100% rename from pollen-ui-riot-js/src/main/web/tag/PollChoiceTextGroup.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceTextGroup.tag diff --git a/pollen-ui-riot-js/src/main/web/tag/PollChoicesDate.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesDate.tag similarity index 71% rename from pollen-ui-riot-js/src/main/web/tag/PollChoicesDate.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesDate.tag index 7c8ff3f..394f4b2 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollChoicesDate.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesDate.tag @@ -1,5 +1,3 @@ -let form = require("../js/PollForm"); - <PollChoicesDate> <div> Choix du sondage (type date) @@ -10,19 +8,17 @@ let form = require("../js/PollForm"); </div> <script> + this.form = opts.form; this.previousStep = (e) => { - form.previousStep(); + this.form.previousStep(); }; this.nextStep = (e) => { - form.nextStep(); + this.form.nextStep(); }; </script> <style> .actions { - margin-top: 50px; - margin-right: 10px; - margin-left: 10px; - margin-bottom: 10px; + margin: 50px 10px 10px; display: flex; flex-direction: row; justify-content: flex-start; diff --git a/pollen-ui-riot-js/src/main/web/tag/PollChoicesImage.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesImage.tag similarity index 71% rename from pollen-ui-riot-js/src/main/web/tag/PollChoicesImage.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesImage.tag index 7b57660..096e90c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollChoicesImage.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesImage.tag @@ -1,5 +1,3 @@ -let form = require("../js/PollForm"); - <PollChoicesImage> <div> Choix du sondage (type image) @@ -10,19 +8,17 @@ let form = require("../js/PollForm"); </div> <script> + this.form = opts.form; this.previousStep = (e) => { - form.previousStep(); + this.form.previousStep(); }; this.nextStep = (e) => { - form.nextStep(); + this.form.nextStep(); }; </script> <style> .actions { - margin-top: 50px; - margin-right: 10px; - margin-left: 10px; - margin-bottom: 10px; + margin: 50px 10px 10px; display: flex; flex-direction: row; justify-content: flex-start; diff --git a/pollen-ui-riot-js/src/main/web/tag/PollChoicesText.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesText.tag similarity index 64% rename from pollen-ui-riot-js/src/main/web/tag/PollChoicesText.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesText.tag index 8f07fde..b35c603 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollChoicesText.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesText.tag @@ -1,6 +1,4 @@ -let form = require("../js/PollForm"); require('./PollChoiceTextGroup.tag'); - <PollChoicesText> <form ref="choices" onsubmit="{nextStep}"> <virtual each={item in counts}> @@ -9,56 +7,54 @@ require('./PollChoiceTextGroup.tag'); <div class="actions"> <a class="button" onclick="{addMoreChoices}"> <i class="fa fa-plus"/>Plus de choix</a> <a class="button" onclick="{previousStep}">Précédent</a> - <input type="submit" class="button" value="Suivant"> + <input type="submit" class="button mainColorBackground" value="Suivant"> </div> </form> <script> - this.counts = [5]; - this.count = 5; - this.form = form; - + this.form = opts.form; this.on('mount', () => { this.choices = this.refs.choices; - }); - - form.onStepChanged(step => { - if (step == 1) { - let choices = this.form.model.textChoices; - console.info("init step1 with " + choices.length + " choices"); - console.info(choices); + let choices = this.form.model.textChoices; + console.info("init step1 with " + choices.length + " choices"); + console.info(choices); + if (choices.length == 0) { + this.counts = []; + this.count = 0; + } else { this.counts = []; this.count = 0; let i; for (i = 0; i < choices.length; i++) { if (i > 0 && i % 5 == 0) { - this._addChoices(i); + this.addChoices(i); } } if (i <= 5 || i % 5 > 0) { - this._addChoices(this.count + 5); + this.addChoices(this.count + 5); } - console.info("Final count: " + this.count); - this.update(); } + console.info("Final count: " + this.count); + this.update(); + }); this.previousStep = (e) => { - form.fromTextChoices(this.choices); - form.previousStep(); + this.form.fromTextChoices(this.choices); + this.form.previousStep(); }; this.nextStep = (e) => { e.preventDefault(); e.stopPropagation(); - form.fromTextChoices(this.choices); - form.nextStep(); + this.form.fromTextChoices(this.choices); + this.form.nextStep(); }; this.addMoreChoices = () => { - this._addChoices(this.count + 5); + this.addChoices(this.count + 5); this.update({counts: this.counts}); }; - this._addChoices = (i) => { + this.addChoices = (i) => { this.count = i; this.counts.push(i); }; diff --git a/pollen-ui-riot-js/src/main/web/tag/PollDescription.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag similarity index 73% rename from pollen-ui-riot-js/src/main/web/tag/PollDescription.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag index 82d5071..8b447dc 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollDescription.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag @@ -1,29 +1,32 @@ -let form = require("../js/PollForm"); -let route = require("riot-route"); - <PollDescription> <form onsubmit="{nextStep}"> <label for="title">Titre du sondage</label> - <input ref="title" type="text" required name="title" id="title" value="{model.title}" placeholder="Enter le titre du sondage"> + <input ref="title" type="text" required name="title" id="title" value="{model.title}" + placeholder="Enter le titre du sondage"> <label for="name">Votre nom</label> <input ref="name" type="text" required name="name" id="name" value="{model.name}" placeholder="Enter votre nom"> <label for="email">Votre courriel</label> - <input ref="email" type="email" required name="email" id="email" value="{model.email}" placeholder="Enter votre courriel"> + <input ref="email" type="email" required name="email" id="email" value="{model.email}" + placeholder="Enter votre courriel"> <div class="actions"> <a class="button" onclick="{cancel}">Annuler</a> - <input type="submit" class="button" value="Suivant"> + <input type="submit" class="button mainColorBackground" value="Suivant"> </div> </form> <script> - this.model = form.model; + this.form = opts.form; + this.emitter = opts.emitter; + this.session = opts.session; + this.model = this.form.model; + let route = require("riot-route"); this.nextStep = (e) => { e.preventDefault(); e.stopPropagation(); this.model.title = this.refs.title.value; this.model.name = this.refs.name.value; this.model.email = this.refs.email.value; - form.nextStep(); + this.form.nextStep(); }; this.cancel = () => { route("home", null, true); diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag new file mode 100644 index 0000000..86422f2 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag @@ -0,0 +1,314 @@ +<PollSettings> + + <div class="legend"> + {__.basic_usage} + <a class="button skip mainColorBackground" onclick="{nextStep}">{__.skip}</a> + </div> + + <div id="navigation"> + <nav class="bs-docs-sidebar"> + <ul id="sidebar" class="nav nav-stacked"> + <li> + <a onclick="{scrollTo}" href="#GlobalConfiguration">Poll</a> + <ul class="nav nav-stacked"> + <li><a onclick="{scrollTo}" href="#GlobalConfiguration_beginDate">Begin date</a></li> + <li><a onclick="{scrollTo}" href="#GlobalConfiguration_endDate">End date</a></li> + <li><a onclick="{scrollTo}" href="#GlobalConfiguration_resultVisibility">Result visibility</a> + </li> + <li><a onclick="{scrollTo}" href="#GlobalConfiguration_continiousVisibility">Continious + result</a></li> + </ul> + </li> + <li> + <a onclick="{scrollTo}" href="#ChoiceConfiguration">Choices</a> + <ul class="nav nav-stacked"> + <li><a onclick="{scrollTo}" href="#ChoiceConfigurationaddChoices">Add choices</a></li> + <li><a onclick="{scrollTo}" href="#ChoiceConfiguration_limitChoices">Limit choices</a></li> + </ul> + </li> + <li> + <a onclick="{scrollTo}" href="#VoteConfiguration">Votes</a> + <ul class="nav nav-stacked"> + <li><a onclick="{scrollTo}" href="#VoteConfiguration_countingType">Vote counting type</a></li> + <li><a onclick="{scrollTo}" href="#VoteConfiguration_visibility">Vote visibility</a></li> + <li><a onclick="{scrollTo}" href="#VoteConfiguration_anonymous">Anonymous vote</a></li> + </ul> + </li> + <li> + <a onclick="{scrollTo}" href="#CommentConfiguration">Comments</a> + <ul class="nav nav-stacked"> + <li><a onclick="{scrollTo}" href="#CommentConfiguration_enabled">Use comments</a></li> + <li><a onclick="{scrollTo}" href="#CommentConfiguration_visibility">Comment visibility</a></li> + </ul> + </li> + </ul> + </nav> + <div ref="content" class="content"> + <div class="config-group" id="GlobalConfiguration"> + <div class="config-header">Poll configuration</div> + <div id="GlobalConfiguration_beginDate" class="subgroup"> + <div class="config-subheader">Begin date</div> + <div class="config-description"> + When users can start to vote. + </div> + </div> + <div id="GlobalConfiguration_endDate" class="subgroup"> + <div class="config-subheader">End date</div> + <div class="config-description"> + Limit date of voting. + </div> + </div> + <div id="GlobalConfiguration_resultVisibility" class="subgroup"> + <div class="config-subheader">Result visibility</div> + <div class="config-description"> + Who can see results. + </div> + </div> + <div id="GlobalConfiguration_continiousVisibility" class="subgroup"> + <div class="config-subheader">Continious result</div> + <div class="config-description"> + Te see continious results. + </div> + </div> + </div> + + <div id="ChoiceConfiguration" class="config-group"> + <div class="config-header">Choices configuration</div> + <div id="ChoiceConfigurationaddChoices" class="subgroup"> + <div class="config-subheader">Can users add choices?</div> + <div class="config-description"> + Is users can add choices to poll? + </div> + </div> + <div id="ChoiceConfiguration_limitChoices" class="subgroup"> + <div class="config-subheader">Limit number of choices</div> + <div class="config-description"> + To limit the number of choices what user can vote on. + </div> + </div> + </div> + <div id="VoteConfiguration" class="config-group"> + <div class="config-header">Votes configuration</div> + <div id="VoteConfiguration_countingType" class="subgroup"> + <div class="config-subheader">Vote counting type</div> + <div class="config-description"> + Defines the vote counting type. + </div> + </div> + <div id="VoteConfiguration_visibility" class="subgroup"> + <div class="config-subheader">Vote visibility</div> + <div class="config-description"> + Who can see votes? + </div> + </div> + <div id="VoteConfiguration_anonymous" class="subgroup"> + <div class="config-subheader">Anonymous votes</div> + <div class="config-description"> + Anonymze votes + </div> + </div> + </div> + <div id="CommentConfiguration" class="config-group"> + <div class="config-header">Comments configuration</div> + <div id="CommentConfiguration_enabled" class="subgroup"> + <div class="config-subheader">Comment enabled?</div> + <div class="config-description"> + Can use comments on a poll? + </div> + </div> + <div id="CommentConfiguration_visibility" class="subgroup"> + <div class="config-subheader">Comment visibility</div> + <div class="config-description"> + Who can see comments. + </div> + </div> + </div> + </div> + </div> + <div class="actions"> + <a class="button" onclick="{previousStep}">{__.previous}</a> + <a class="button mainColorBackground" onclick="{nextStep}">{__.next}</a> + </div> + + <script> + this.form = opts.form; + this.installBundle(opts.session.locale, "poll_settings", opts.emitter); + this.previousStep = (e) => { + this.form.previousStep(); + }; + this.nextStep = (e) => { + this.form.nextStep(); + }; + + this.scrollTo = (e) => { + e.preventDefault(); + e.stopPropagation(); + let id = e.currentTarget.href.substring(e.currentTarget.href.indexOf('#') + 1); + if (id.indexOf('_')>-1) { + id = id.substring(0, id.indexOf('_')); + } + document.getElementById(id).scrollIntoView(); + }; + + </script> + <style> + + .config-header { + border-bottom: solid 2px #c8ccca; + font-size: 20px; + margin-bottom: 10px; + } + + .config-subheader { + border-bottom: solid 2px #c8ccca; + font-size: 18px; + margin-bottom: 10px; + } + + .config-description { + margin: 10px; + } + + .config-group { + height: 100%; + border: solid 2px #c8ccca; + padding: 10px; + border-radius: 10px; + } + + ul { + list-style: none; + } + + li { + margin-bottom: 5px; + margin-top: 5px; + } + + fieldset { + padding: 10px; + } + + .legend { + width: 100%; + height: 70px; + border-bottom: 1px solid #b2c7d3; + display: flex; + justify-content: center; + align-items: center; + margin-bottom: 30px; + font-size: 20px; + } + + .actions { + margin: 50px 10px 10px; + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + } + + .skip { + width: 100px; + } + + .actions > a, .skip { + margin: 5px; + } + + /*.fixed {*/ + /*position: fixed;*/ + /*}*/ + + /* sidebar */ + .bs-docs-sidebar { + /*padding-left: 20px;*/ + /*margin-top: 20px;*/ + /*margin-bottom: 20px;*/ + } + + /* all links */ + .bs-docs-sidebar .nav > li > a { + color: #999; + border-left: 2px solid transparent; + padding: 4px 20px; + font-size: 18px; + font-weight: 400; + } + + /* nested links */ + .bs-docs-sidebar .nav .nav > li > a { + padding-top: 5px; + padding-bottom: 5px; + padding-left: 30px; + font-size: 16px; + } + + /* active & hover links */ + .bs-docs-sidebar .nav > .active > a, + .bs-docs-sidebar .nav > li > a:hover, + .bs-docs-sidebar .nav > li > a:focus { + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left-color: #563d7c; + } + + /* all active links */ + .bs-docs-sidebar .nav > .active > a, + .bs-docs-sidebar .nav > .active:hover > a, + .bs-docs-sidebar .nav > .active:focus > a { + font-weight: 700; + } + + /* nested active links */ + .bs-docs-sidebar .nav .nav > .active > a, + .bs-docs-sidebar .nav .nav > .active:hover > a, + .bs-docs-sidebar .nav .nav > .active:focus > a { + font-weight: 500; + } + + /* hide inactive nested list */ + /*.bs-docs-sidebar .nav ul.nav {*/ + /*display: none;*/ + /*}*/ + + /* show active nested list */ + /*.bs-docs-sidebar .nav > .active > ul.nav {*/ + /*display: block;*/ + /*}*/ + + #sidebar { + height: 450px; + width: 300px; + margin-left: 10px; + } + + .content { + /*display: flex;*/ + /*flex-direction: column;*/ + /*justify-content: flex-start;*/ + /*background: white;*/ + /*border: solid 2px #c8ccca;*/ + /*padding: 45px 0;*/ + /*border-radius: 10px;*/ + /*text-align: center;*/ + /*align-items: flex-start;*/ + width: 99%; + height: 450px; + overflow-y: hidden; + padding-right: 20px; + align-self: flex-start; + flex-grow: 2; + } + + #navigation { + overflow: hidden; + width: 100%; + height: 100%; + display: flex; + flex-direction: row; + /*justify-content: space-around;*/ + } + </style> +</PollSettings> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/PollVoters.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag similarity index 77% rename from pollen-ui-riot-js/src/main/web/tag/PollVoters.tag rename to pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag index 364f742..b057aff 100644 --- a/pollen-ui-riot-js/src/main/web/tag/PollVoters.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag @@ -1,5 +1,3 @@ -let form = require("../js/PollForm"); - <PollVoters> <div> Participants au sondage @@ -11,12 +9,13 @@ let form = require("../js/PollForm"); </div> <script> + this.form = opts.form; this.previousStep = (e) => { - form.previousStep(); + this.form.previousStep(); }; this.validate = (e) => { - form.save().then(poll => { + this.form.save().then(poll => { console.info("poll saved"); console.info(poll); }).catch(errors => { @@ -27,10 +26,7 @@ let form = require("../js/PollForm"); </script> <style> .actions { - margin-top: 50px; - margin-right: 10px; - margin-left: 10px; - margin-bottom: 10px; + margin: 50px 10px 10px; display: flex; flex-direction: row; justify-content: flex-start; diff --git a/pollen-ui-riot-js/webpack.config.js b/pollen-ui-riot-js/webpack.config.js index 4082555..e5e78cc 100644 --- a/pollen-ui-riot-js/webpack.config.js +++ b/pollen-ui-riot-js/webpack.config.js @@ -38,6 +38,11 @@ module.exports = { {from: "src/main/web/css", to: "css"}, {from: "./node_modules/font-awesome/css", to: "css"}, {from: "./node_modules/font-awesome/fonts", to: "fonts"}, + {from: "./node_modules/bootstrap/dist/css", to: "css"}, + {from: "./node_modules/bootstrap/dist/fonts", to: "fonts"}, + {from: "./node_modules/scrollspy-js/js/scrollspy.js", to: "js"}, + {from: "./node_modules/bootstrap/dist/js/bootstrap.js", to: "js"}, + {from: "./node_modules/jquery/dist/js/jquery.js", to: "js"}, ]) ], -- 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 feature/pollen-riot-js in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit d653e813bc1c076567bd023b818ab3b31704139d Author: Tony CHEMIT <dev@tchemit.fr> Date: Tue Jan 17 22:38:32 2017 +0100 Suppression EmitterService (tout est dans la session), enfin on peut créer un sondage --- pollen-persistence/src/main/xmi/pollen.zargo | Bin 20954 -> 21037 bytes pollen-rest-api/src/main/resources/mapping | 2 +- .../org/chorem/pollen/services/bean/PollBean.java | 17 ++ pollen-ui-riot-js/src/main/web/conf.json | 3 +- pollen-ui-riot-js/src/main/web/i18n.json | 194 ++++++++++++++--- pollen-ui-riot-js/src/main/web/js/AuthService.js | 10 +- pollen-ui-riot-js/src/main/web/js/ChoiceText.js | 5 +- .../src/main/web/js/EmitterService.js | 49 ----- pollen-ui-riot-js/src/main/web/js/FetchService.js | 12 +- pollen-ui-riot-js/src/main/web/js/I18nHelper.js | 18 +- pollen-ui-riot-js/src/main/web/js/PollForm.js | 63 ++++-- pollen-ui-riot-js/src/main/web/js/PollService.js | 16 ++ pollen-ui-riot-js/src/main/web/js/Session.js | 65 +++++- pollen-ui-riot-js/src/main/web/tag/Footer.tag | 5 +- pollen-ui-riot-js/src/main/web/tag/Header.tag | 15 +- pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag | 13 +- pollen-ui-riot-js/src/main/web/tag/Home.tag | 18 +- pollen-ui-riot-js/src/main/web/tag/Pollen.tag | 17 +- pollen-ui-riot-js/src/main/web/tag/SignCheck.tag | 8 +- pollen-ui-riot-js/src/main/web/tag/SignIn.tag | 11 +- pollen-ui-riot-js/src/main/web/tag/SignUp.tag | 9 +- .../src/main/web/tag/poll/CreatePoll.tag | 130 ++++++++++-- .../src/main/web/tag/poll/PollChoiceText.tag | 23 +- .../src/main/web/tag/poll/PollChoiceTextGroup.tag | 13 +- .../src/main/web/tag/poll/PollChoicesText.tag | 24 ++- .../src/main/web/tag/poll/PollCreated.tag | 40 ++++ .../src/main/web/tag/poll/PollDescription.tag | 27 +-- .../src/main/web/tag/poll/PollSettings.tag | 236 ++++++++++++++------- .../src/main/web/tag/poll/PollVoters.tag | 173 +++++++++++++-- .../src/main/web/tag/popup/AccountCreated.tag | 8 +- .../src/main/web/tag/popup/NewPassword.tag | 8 +- .../src/main/web/tag/popup/ResendValidation.tag | 9 +- 32 files changed, 891 insertions(+), 350 deletions(-) diff --git a/pollen-persistence/src/main/xmi/pollen.zargo b/pollen-persistence/src/main/xmi/pollen.zargo index b32f5a8..e3d4cad 100644 Binary files a/pollen-persistence/src/main/xmi/pollen.zargo and b/pollen-persistence/src/main/xmi/pollen.zargo differ diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index 83822b2..0bb0f7e 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -101,7 +101,7 @@ GET /v1/polls/created PollApi.getCreatedPolls GET /v1/polls/invited PollApi.getInvitedPolls GET /v1/polls/participated PollApi.getParticipatedPolls POST /v1/polls PollApi.createPoll -GET /v1/polls/create PollApi.createPoll +POST,GET /v1/polls/create PollApi.createPoll GET /v1/polls/edit PollApi.editPoll #fix me diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java index ac7f99f..80c7099 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java @@ -21,6 +21,7 @@ package org.chorem.pollen.services.bean; * #L% */ +import com.google.common.base.Joiner; import org.chorem.pollen.persistence.entity.CommentVisibility; import org.chorem.pollen.persistence.entity.Poll; import org.chorem.pollen.persistence.entity.PollImpl; @@ -30,8 +31,12 @@ import org.chorem.pollen.persistence.entity.PollenPrincipalImpl; import org.chorem.pollen.persistence.entity.ResultVisibility; import org.chorem.pollen.persistence.entity.VoteVisibility; +import java.util.Arrays; +import java.util.Collections; import java.util.Date; +import java.util.LinkedHashSet; import java.util.Objects; +import java.util.Set; /** * Created on 5/15/14. @@ -105,6 +110,8 @@ public class PollBean extends PollenBean<Poll> { protected long commentCount; + protected Set<String> participants; + @Override public void fromEntity(Poll entity) { @@ -143,6 +150,7 @@ public class PollBean extends PollenBean<Poll> { setCommentVisibility(entity.getCommentVisibility()); setResultVisibility(entity.getResultVisibility()); setClosed(entity.isClosed()); + setParticipants(new LinkedHashSet<>(entity.getParticipants() == null ? Collections.emptyList() : Arrays.asList(entity.getParticipants().split("\\s")))); } @Override @@ -173,6 +181,7 @@ public class PollBean extends PollenBean<Poll> { entity.setCommentVisibility(getCommentVisibility()); entity.setResultVisibility(getResultVisibility()); entity.setClosed(isClosed()); + entity.setParticipants(Joiner.on(' ').join(getParticipants())); return entity; @@ -369,4 +378,12 @@ public class PollBean extends PollenBean<Poll> { public void setCommentCount(long commentCount) { this.commentCount = commentCount; } + + public Set<String> getParticipants() { + return participants; + } + + public void setParticipants(Set<String> participants) { + this.participants = participants; + } } diff --git a/pollen-ui-riot-js/src/main/web/conf.json b/pollen-ui-riot-js/src/main/web/conf.json index 78dd34b..73eb556 100644 --- a/pollen-ui-riot-js/src/main/web/conf.json +++ b/pollen-ui-riot-js/src/main/web/conf.json @@ -10,5 +10,6 @@ "defaultAlertTimeError": -1, "defaultDateFormat": "shortDate", "defaultTimeFormat": "shortTime", - "defaultDateTimeFormat": "short" + "defaultDateTimeFormat": "short", + "debugI18n":false } \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/i18n.json b/pollen-ui-riot-js/src/main/web/i18n.json index f54d573..c999419 100644 --- a/pollen-ui-riot-js/src/main/web/i18n.json +++ b/pollen-ui-riot-js/src/main/web/i18n.json @@ -17,13 +17,13 @@ "resendvalidation_placeholder": "Entrer votre courriel", "resendvalidation_sent": "Un nouveau courriel d'invitation a été envoyé", "resendvalidation_error_emailNotFound": "Le courriel n'a pas été trouvé", - "signcheck_title":"Validation de votre compte", - "signcheck_signin":"Vous connecter", - "signcheck_resendValidation":"Envoyer une nouvelle invitation", - "signcheck_message":"Votre compte doit être validé afin de pouvoir vous connecter.", - "signcheck_validating":"Votre compte est en cour de validation...", - "signcheck_validating_error":"Votre compte n'a pas pu être validé, essayer de renvoyer une invitation.", - "signcheck_validating_success":"Votre compte a été validé. Vous pouvez vous connecter.", + "signcheck_title": "Validation de votre compte", + "signcheck_signin": "Vous connecter", + "signcheck_resendValidation": "Envoyer une nouvelle invitation", + "signcheck_message": "Votre compte doit être validé afin de pouvoir vous connecter.", + "signcheck_validating": "Votre compte est en cour de validation...", + "signcheck_validating_error": "Votre compte n'a pas pu être validé, essayer de renvoyer une invitation.", + "signcheck_validating_success": "Votre compte a été validé. Vous pouvez vous connecter.", "signin_title": "Déjà membre ?", "signin_login": "Email", "signin_login_placeholder": "Entrer l'email", @@ -53,14 +53,81 @@ "home_createTextPoll": "Créer un sondage de type text", "home_createImagePoll": "Créer un sondage de type image", "home_createDatePoll": "Créer un sondage de type date", - "poll_settings_basic_usage":"Pour un sondage simple, vous pouvez passer cette étape.", - "poll_settings_previous":"Précédent", - "poll_settings_next":"Continuer", - "poll_settings_skip":"Passer", - "poll_header_general":"Description", - "poll_header_choices":"Choix", - "poll_header_options":"Options", - "poll_header_voters":"Participants", + "poll_description_cancel": "Annuler", + "poll_description_next": "Suivant", + "poll_description_title": "Titre", + "poll_description_titlePlaceHolder": "Renseigner le titre du sondage", + "poll_description_description": "Description", + "poll_description_descriptionPlaceHolder": "Renseigner la description du sondage", + "poll_description_name": "Votre nom", + "poll_description_namePlaceHolder": "Renseigner votre nom", + "poll_description_email": "Votre courriel", + "poll_description_emailPlaceHolder": "Renseigner votre courriel", + "poll_settings_basic_usage": "Pour un sondage simple, vous pouvez passer cette étape.", + "poll_settings_previous": "Précédent", + "poll_settings_next": "Continuer", + "poll_settings_skip": "Passer", + "poll_settings_showOptions": "Voir les options avancées", + "poll_settings_hideOptions": "Masquer les options avancées", + "poll_settings_resultVisibility": "Qui peut voir les résultats ?", + "poll_settings_resultVisibility_creator": "Uniquement le créateur", + "poll_settings_resultVisibility_everybody": "Tout le monde", + "poll_settings_resultVisibility_voter": "Les participants", + "poll_settings_commentVisibility": "Qui peut voir les commentaires ?", + "poll_settings_commentVisibility_creator": "Uniquement le créateur", + "poll_settings_commentVisibility_everybody": "Tout le monde", + "poll_settings_commentVisibility_voter": "Les participants", + "poll_settings_voteVisibility": "Qui peut voir les votes ?", + "poll_settings_voteVisibility_creator": "Uniquement le créateur", + "poll_settings_voteVisibility_everybody": "Tout le monde", + "poll_settings_voteVisibility_voter": "Les participants", + "poll_settings_nav_poll": "Sondage", + "poll_settings_nav_voteBeginDate": "Date de début", + "poll_settings_nav_voteEndDate": "Date de fin", + "poll_settings_nav_resultVisibility": "Visibilité des résultats", + "poll_settings_nav_continiousResult": "Résultats continus", + "poll_settings_nav_choices": "Choix", + "poll_settings_nav_addChoices": "Ajouter des choix", + "poll_settings_nav_limitChoices": "Limiter les choix", + "poll_settings_nav_votes": "Votes", + "poll_settings_nav_voteCountingType": "Type de scrutin", + "poll_settings_nav_voteVisibility": "Visibilité", + "poll_settings_nav_anonymousVote": "Anonimisation", + "poll_settings_nav_comments": "Commentaires", + "poll_settings_nav_commentVisibility": "Visiblité", + "poll_settings_poll_configuration": "Configuration du sondage", + "poll_settings_continiousResult": "Voir les résultats en continue", + "poll_settings_choicesConfiguration": "Configuration des choix", + "poll_settings_addChoices": "Est-ce que les participants peuvent ajouter des choix ?", + "poll_settings_limitChoices": "Limiter le nombre de choix par vote", + "poll_settings_votesConfiguration": "Configuration des votes", + "poll_settings_voteCountingType": "Type de scrutin pour effecter le dépouillement du sondage", + "poll_settings_voteCountingType_normal": "Normal", + "poll_settings_voteCountingType_pourcentage": "Pourcentage", + "poll_settings_voteCountingType_condorcet": "Condorcet", + "poll_settings_anonymousVote": "Rendre les votes anonymes", + "poll_settings_commentsConfiguration": "Configuration des commentaires", + "poll_settings_voteBeginDate": "Quand les participants peuvent commencer à voter ?", + "poll_settings_voteEndDate": "Date de fin des votes", + "poll_choices_label": "Choix", + "poll_choices_description": "Description", + "poll_choices_previous": "Précédent", + "poll_choices_next": "Suivant", + "poll_choices_moreChoices": "Ajouter des choix", + "poll_header_general": "Description", + "poll_header_choices": "Choix", + "poll_header_options": "Options", + "poll_header_voters": "Participants", + "poll_header_summary": "Résumé", + "poll_voters_description": "Qui peut voter ?", + "poll_voters_previous": "Précédent", + "poll_voters_save": "Enregistrer", + "poll_voters_freePoll": "Tout le monde peut voter (Sondage public)", + "poll_voters_restrictedPoll": "Seul les invités peuvent voter (Sondage privé)", + "poll_voters_restrictedPoll_withMe": "Je participe au sondage", + "poll_voters_restrictedPoll_withGroup": "Organiser les invités dans des groupes", + "poll_voters_invite": "Inviter des participants", + "poll_voters_invite_label": "Renseigner le courriel des participants (séparé par un espace)", "": "" }, "en": { @@ -73,13 +140,13 @@ "signup_resendValidation": "Already member, but account never validated ?", "signup_error": "Could not register account.", "signup_error_email": "This email is already used.", - "signcheck_title":"Validate your account", - "signcheck_signin":"Sign in", - "signcheck_resendValidation":"Send a new invitation", - "signcheck_message":"Your account must be validate before you can connect.", - "signcheck_validating":"Your account is validating...", - "signcheck_validating_error":"Your account could not be validated, try to send a new invitation.", - "signcheck_validating_success":"Your account was validated! You can now sign in. Enjoy!", + "signcheck_title": "Validate your account", + "signcheck_signin": "Sign in", + "signcheck_resendValidation": "Send a new invitation", + "signcheck_message": "Your account must be validate before you can connect.", + "signcheck_validating": "Your account is validating...", + "signcheck_validating_error": "Your account could not be validated, try to send a new invitation.", + "signcheck_validating_success": "Your account was validated! You can now sign in. Enjoy!", "createdaccount_title": "Your account was created", "createdaccount_description": "We sent you an email with the account validation process and your authentication data.", "createdaccount_action": "Continue", @@ -117,14 +184,81 @@ "home_createTextPoll": "Create a text poll", "home_createImagePoll": "Create a image poll", "home_createDatePoll": "Create a date poll", - "poll_settings_basic_usage":"For a basic poll, you can skip this step.", - "poll_settings_previous":"Previous", - "poll_settings_next":"Continue", - "poll_settings_skip":"Skip", - "poll_header_general":"General", - "poll_header_choices":"Choices", - "poll_header_options":"Options", - "poll_header_voters":"Voters", + "poll_description_cancel": "Cancel", + "poll_description_next": "Next", + "poll_description_title": "Title", + "poll_description_titlePlaceHolder": "Enter poll title", + "poll_description_description": "Description", + "poll_description_descriptionPlaceHolder": "Enter poll description", + "poll_description_name": "Your name", + "poll_description_namePlaceHolder": "Enter your name", + "poll_description_email": "Your email", + "poll_description_emailPlaceHolder": "Enter your email", + "poll_settings_basic_usage": "For a basic poll, you can skip this step.", + "poll_settings_previous": "Previous", + "poll_settings_next": "Continue", + "poll_settings_skip": "Skip", + "poll_settings_showOptions": "Show options", + "poll_settings_hideOptions": "Hide options", + "poll_settings_resultVisibility": "Who can see results?", + "poll_settings_resultVisibility_creator": "Only creator", + "poll_settings_resultVisibility_everybody": "Everybody", + "poll_settings_resultVisibility_voter": "Only voters", + "poll_settings_commentVisibility": "Who can see comments?", + "poll_settings_commentVisibility_creator": "Only creator", + "poll_settings_commentVisibility_everybody": "Everybody", + "poll_settings_commentVisibility_voter": "Only voters", + "poll_settings_voteVisibility": "Who can see votes?", + "poll_settings_voteVisibility_creator": "Only creator", + "poll_settings_voteVisibility_everybody": "Everybody", + "poll_settings_voteVisibility_voter": "Only voters", + "poll_settings_nav_poll": "Poll", + "poll_settings_nav_voteBeginDate": "Begin date", + "poll_settings_nav_voteEndDate": "End date", + "poll_settings_nav_resultVisibility": "Results visibility", + "poll_settings_nav_continiousResult": "Continious results", + "poll_settings_nav_choices": "Choices", + "poll_settings_nav_addChoices": "Add choices", + "poll_settings_nav_limitChoices": "Limit choices", + "poll_settings_nav_votes": "Votes", + "poll_settings_nav_voteCountingType": "Vote counting type", + "poll_settings_nav_voteVisibility": "Visibility", + "poll_settings_nav_anonymousVote": "Anomize", + "poll_settings_nav_comments": "Comments", + "poll_settings_nav_commentVisibility": "Visibility", + "poll_settings_poll_configuration": "Poll configuration", + "poll_settings_continiousResult": "Use continious results", + "poll_settings_choicesConfiguration": "Choices configuration", + "poll_settings_addChoices": "Can user add choices?", + "poll_settings_limitChoices": "Limit number of choices to use on a vote", + "poll_settings_votesConfiguration": "Votes configuration", + "poll_settings_voteCountingType": "Vote counting type used to compute poll's results.", + "poll_settings_voteCountingType_normal": "Normal", + "poll_settings_voteCountingType_pourcentage": "Pourcentage", + "poll_settings_voteCountingType_condorcet": "Condorcet", + "poll_settings_anonymousVote": "Anonymize votes", + "poll_settings_commentsConfiguration": "Comments configuration", + "poll_settings_voteBeginDate": "When users can start to vote?", + "poll_settings_voteEndDate": "When poll is ending?", + "poll_choices_label": "Choice", + "poll_choices_description": "Description", + "poll_choices_previous": "Previous", + "poll_choices_next": "Next", + "poll_choices_moreChoices": "Add more choices", + "poll_header_general": "General", + "poll_header_choices": "Choices", + "poll_header_options": "Options", + "poll_header_voters": "Voters", + "poll_header_summary": "Summary", + "poll_voters_description": "Who can vote?", + "poll_voters_previous": "Previous", + "poll_voters_save": "Save", + "poll_voters_freePoll": "Everybody can vote (Public poll)", + "poll_voters_restrictedPoll": "Only invited people can vote (Private poll)", + "poll_voters_restrictedPoll_withMe": "I also want to participate", + "poll_voters_restrictedPoll_withGroup": "Organize participants in groups", + "poll_voters_invite": "Invite people to vote", + "poll_voters_invite_label": "Type participants emails separated by space", "": "" } } \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/js/AuthService.js b/pollen-ui-riot-js/src/main/web/js/AuthService.js index 1aca463..3052652 100644 --- a/pollen-ui-riot-js/src/main/web/js/AuthService.js +++ b/pollen-ui-riot-js/src/main/web/js/AuthService.js @@ -1,10 +1,12 @@ let singleton = require("./Singleton"); -let emitter = require("./EmitterService"); -let session = require("./Session"); let FetchService = require("./FetchService"); class AuthService extends FetchService { + constructor() { + super(); + } + signIn(login, password) { return this.fetch("/v1/login", "POST", { Authorization: "Basic " + btoa(login + ":" + password) @@ -12,7 +14,7 @@ class AuthService extends FetchService { if (!auth) { return Promise.reject(false); } - session.signIn(auth, this); + this.session.signIn(auth, this); return true; }); } @@ -22,7 +24,7 @@ class AuthService extends FetchService { } signOut() { - session.signOut(); + this.session.signOut(); return this.get("/v1/logout"); } diff --git a/pollen-ui-riot-js/src/main/web/js/ChoiceText.js b/pollen-ui-riot-js/src/main/web/js/ChoiceText.js index d0e64d7..ed1bce3 100644 --- a/pollen-ui-riot-js/src/main/web/js/ChoiceText.js +++ b/pollen-ui-riot-js/src/main/web/js/ChoiceText.js @@ -1,8 +1,9 @@ class ChoiceText { - constructor(text, description) { - this.text = text; + constructor(name, description) { + this.choiceValue = name; this.description = description; + this.choiceType = 'TEXT'; } } diff --git a/pollen-ui-riot-js/src/main/web/js/EmitterService.js b/pollen-ui-riot-js/src/main/web/js/EmitterService.js deleted file mode 100644 index 490fe83..0000000 --- a/pollen-ui-riot-js/src/main/web/js/EmitterService.js +++ /dev/null @@ -1,49 +0,0 @@ -let singleton = require("./Singleton"); - -class EmitterService { - - constructor() { - riot.observable(this); - } - emitUnauthorize() { - this.trigger("unauthorized"); - } - - onUnauthorize(fn) { - this.on("unauthorized", fn); - } - - emitConnected(user) { - this.trigger("connected", user); - } - - onConnected(fn) { - this.on("connected", fn); - } - - emitDisconnected(user) { - this.trigger("disconnected", user); - } - - onDisconnected(fn) { - this.on("disconnected", fn); - } - - emitError() { - this.trigger("error"); - } - - onError(fn) { - this.on("error", fn); - } - - emitLocaleChanged(locale) { - this.trigger("localeChanged", locale); - } - - onLocaleChanged(fn) { - this.on("localeChanged", fn); - } -} - -module.exports = singleton(EmitterService); diff --git a/pollen-ui-riot-js/src/main/web/js/FetchService.js b/pollen-ui-riot-js/src/main/web/js/FetchService.js index 5225eb1..ba33dc3 100644 --- a/pollen-ui-riot-js/src/main/web/js/FetchService.js +++ b/pollen-ui-riot-js/src/main/web/js/FetchService.js @@ -1,8 +1,10 @@ -let emitter = require("./EmitterService"); -let session = require("./Session"); - class FetchService { + constructor() { + this.session = require("./Session"); + this.endPoint = this.session.configuration.endPoint; + } + fetch(url, method, headers, body) { headers = headers || {}; if (!(body instanceof FormData)) { @@ -10,7 +12,7 @@ class FetchService { } return fetch( - session.configuration.endPoint + url, { + this.endPoint + url, { headers, method, credentials: "include", @@ -30,7 +32,7 @@ class FetchService { return response.json(); } if (response.status === 503) { - emitter.emitUnauthorize(); + this.session.emitUnauthorize(); return Promise.reject(); } diff --git a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js index 376f117..d6b04f1 100644 --- a/pollen-ui-riot-js/src/main/web/js/I18nHelper.js +++ b/pollen-ui-riot-js/src/main/web/js/I18nHelper.js @@ -1,12 +1,10 @@ module.exports = { - init() { - this.bundles = require("../i18n.json"); - }, - - installBundle(locale, value, emitter) { - this.generateBundle(locale, value); - emitter.onLocaleChanged((locale) => { + installBundle(session, value) { + this.bundle = session.i18n; + this.debug = session.configuration.debugI18n; + this.generateBundle(session.locale, value); + session.onLocaleChanged((locale) => { this.generateBundle(locale, value); try { this.update(); @@ -18,14 +16,16 @@ module.exports = { generateBundle(locale, value) { - let bundle = this.bundles[locale]; + let bundle = this.bundle[locale]; this.__ = {}; Object.keys(bundle).forEach((key) => { if (key.startsWith(value + "_")) { let realKey = key.substring(value.length + 1); this.__[realKey] = bundle[key]; - console.debug(realKey + " -> " + this.__[realKey]); + if (this.debug) { + console.debug(realKey + " -> " + this.__[realKey]); + } } }); }, 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 630c8bd..52934b8 100644 --- a/pollen-ui-riot-js/src/main/web/js/PollForm.js +++ b/pollen-ui-riot-js/src/main/web/js/PollForm.js @@ -5,14 +5,54 @@ let route = require("riot-route"); class PollForm { constructor() { + this.service = require('./PollService'); this.step = 0; + this.isInit = false; this.type = null; + this.showOptions = true; this.model = null; + this.choices = []; + } + + init() { + this.isInit = true; + console.info("init form"); + this.step = 0; + + return this.service.empty().then((poll) => { + this.model = poll; + console.info("empty poll"); + console.info(this.model); + + this.model.title = "Mon premier sondage"; + this.model.description = "Premier sondage!"; + this.model.name = "Dick Laurent"; + this.model.email = "user@pollen.org"; + this.model.participant = []; + this.choices = [ + new ChoiceText("Mozart", "Requiem is so powerfull"), + new ChoiceText("Schubert", "Truit is so nice"), + new ChoiceText("Malher", "So deep, so dark...")]; + }); + } + + create() { + return this.service.create(this.model, this.choices).then((result) => { + console.info("Poll created"); + console.info(result); + this.model.id = result.id; + this.model.permission = result.permission; + this.nextStep(); + }).catch((error) => { + console.error("Could not create poll"); + console.error(error); + return Promise.reject(error); + }); } previousStep() { - console.info("prevousStep:: "+this.step); + console.info("prevousStep:: " + this.step); this.setStep(this.step - 1); } @@ -20,25 +60,6 @@ class PollForm { this.setStep(this.step + 1); } - init(user) { - console.info("init form"); - this.step = 0; - this.model = { - title: "Mon premier sondage", - description: "", - name: "Tony Chemit", - email: "user@pollen.org", - textChoices: [new ChoiceText("Mozart", "Requiem is so powerfull"), - new ChoiceText("Schubert", "Truit is so nice"), new ChoiceText("Malher", "So deep, so dark...")], - imageChoices: [], - dateChoices: [] - }; - if (user) { - this.model.name = user.name; - this.model.email = user.email; - } - } - fromTextChoices(form) { let choices = []; @@ -63,7 +84,7 @@ class PollForm { } console.info("FromTextChoices"); console.info(choices); - this.model.textChoices = choices; + this.choices = choices; } setStep(step) { diff --git a/pollen-ui-riot-js/src/main/web/js/PollService.js b/pollen-ui-riot-js/src/main/web/js/PollService.js new file mode 100644 index 0000000..69fa890 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/js/PollService.js @@ -0,0 +1,16 @@ +let singleton = require("./Singleton"); +let FetchService = require("./FetchService"); + +class PollService extends FetchService { + + empty() { + return this.get("/v1/polls/new"); + } + + create(form, choices) { + return this.form("/v1/polls/create", {poll: form, choices:choices}); + } + +} + +module.exports = singleton(PollService); 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 6ae934f..bdb846d 100644 --- a/pollen-ui-riot-js/src/main/web/js/Session.js +++ b/pollen-ui-riot-js/src/main/web/js/Session.js @@ -1,13 +1,17 @@ let singleton = require("./Singleton"); -let emitter = require("./EmitterService"); class Session { constructor() { + + riot.observable(this); + // pour contenir la locale à utiliser this.locale = null; // pour contenir la configuration this.configuration = require('../conf.json'); + // pour contenir les traductions + this.i18n = require('../i18n.json'); // pour contenir l'utillisateur connecté this.user = null; @@ -17,18 +21,68 @@ class Session { } else { this.locale = 'fr'; } - emitter.onUnauthorize(() => { + + this.onUnauthorize(() => { this.user = null; }); } + start() { + if (this.isConnected()) { + return this.connect(require("./AuthService")); + }else { + return Promise.resolve(); + } + } + + emitUnauthorize() { + this.trigger("unauthorized"); + } + + onUnauthorize(fn) { + this.on("unauthorized", fn); + } + + emitConnected(user) { + this.trigger("connected", user); + } + + onConnected(fn) { + this.on("connected", fn); + } + + emitDisconnected(user) { + this.trigger("disconnected", user); + } + + onDisconnected(fn) { + this.on("disconnected", fn); + } + + emitError() { + this.trigger("error"); + } + + onError(fn) { + this.on("error", fn); + } + + onLocaleChanged(fn) { + this.on("localeChanged", fn); + } + + changeLocale(locale) { + this.locale = locale; + this.trigger("localeChanged", locale); + } + isConnected() { return document.cookie.indexOf("pollen-connected=true") !== -1; } connect(userService) { console.info("Connect::"); - userService.connectedUserPromise().then((user) => { + return userService.connectedUserPromise().then((user) => { if (!user) { console.info("Connect error"); this.user = null; @@ -37,8 +91,7 @@ class Session { console.info("Connect user::"); console.info(user); this.user = user; - emitter.emitConnected(user); - return user; + this.emitConnected(user); }); } @@ -54,7 +107,7 @@ class Session { console.info("SignIn user::"); console.info(user); this.user = user; - emitter.emitConnected(user); + this.emitConnected(user); return user; }); diff --git a/pollen-ui-riot-js/src/main/web/tag/Footer.tag b/pollen-ui-riot-js/src/main/web/tag/Footer.tag index d514deb..fbfada4 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Footer.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Footer.tag @@ -1,5 +1,3 @@ -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); <footer> <div class="links"> <a href="https://pollen.chorem.org/v/latest/index.html">{__.doc}</a> @@ -10,7 +8,8 @@ let emitter = require("../js/EmitterService"); <a href="http://www.codelutin.com/" target="_blank">Code Lutin</a> </div> <script> - this.installBundle(session.locale, "footer", emitter); + let session = require("../js/Session"); + this.installBundle(session, "footer"); </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/Header.tag b/pollen-ui-riot-js/src/main/web/tag/Header.tag index ff258f6..98e00a7 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Header.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Header.tag @@ -1,9 +1,4 @@ -let route = require("riot-route"); -let authService = require("../js/AuthService"); -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); require("./HeaderI18n.tag"); - <Header> <div class="header-home"> <a class="header-link" href="#home" target="_top">{__.home}</a> @@ -26,7 +21,11 @@ require("./HeaderI18n.tag"); <div class="header-separator"></div> <HeaderI18n></HeaderI18n> <script> - this.installBundle(session.locale, "header", emitter); + let route = require("riot-route"); + let authService = require("../js/AuthService"); + let session = require("../js/Session"); + + this.installBundle(session, "header"); this.signOut = () => { let callback = () => { @@ -43,12 +42,12 @@ require("./HeaderI18n.tag"); this.user = session.user; } - emitter.onConnected((user) => { + session.onConnected((user) => { this.user = user; this.update(); }); - emitter.onUnauthorize(() => { + session.onUnauthorize(() => { this.user = null; this.update(); }); diff --git a/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag b/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag index 4c5bec2..7a059af 100644 --- a/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag +++ b/pollen-ui-riot-js/src/main/web/tag/HeaderI18n.tag @@ -1,6 +1,3 @@ -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); - <HeaderI18n> <div class="dropdown2"> @@ -13,22 +10,20 @@ let emitter = require("../js/EmitterService"); </div> <script> + let session = require("../js/Session"); this.locale = session.locale; - //FIXME Le traduction ne se fait pas - this.generateBundle(session.locale, "header_i18n"); + this.installBundle(session, "header_i18n"); this.toEnglish = () => { if ('en' != session.locale) { - session.locale = 'en'; + session.changeLocale('en'); this.locale = session.locale; - emitter.emitLocaleChanged(session.locale); this.update(); } }; this.toFrench = () => { if ('fr' != session.locale) { - session.locale = 'fr'; + session.changeLocale('fr'); this.locale = session.locale; - emitter.emitLocaleChanged(session.locale); this.update(); } }; diff --git a/pollen-ui-riot-js/src/main/web/tag/Home.tag b/pollen-ui-riot-js/src/main/web/tag/Home.tag index 836f817..001827c 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Home.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Home.tag @@ -10,23 +10,25 @@ <script> let session = require("../js/Session"); - let emitter = require("../js/EmitterService"); let form = require("../js/PollForm"); let route = require("riot-route"); - this.installBundle(session.locale, "home", emitter); + this.installBundle(session, "home"); this.createText = () => { - form.init(session.user); - route("/poll/new/text/0"); + form.init(session.user).then(() => { + route("/poll/new/text/0"); + }); }; this.createImage = () => { - form.init(session.user); - route("/poll/new/image/0"); + form.init(session.user).then(() => { + route("/poll/new/image/0"); + }); }; this.createDate = () => { - form.init(session.user); - route("/poll/new/date/0"); + form.init(session.user).then(() => { + route("/poll/new/date/0"); + }); }; </script> diff --git a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag index 19f89f0..e32a8e4 100644 --- a/pollen-ui-riot-js/src/main/web/tag/Pollen.tag +++ b/pollen-ui-riot-js/src/main/web/tag/Pollen.tag @@ -11,14 +11,8 @@ require("./poll/CreatePoll.tag"); <Footer></Footer> <script> - let emitter = require("../js/EmitterService"); - let session = require("../js/Session"); let route = require("riot-route"); - - if (session.isConnected()) { - session.connect(require("../js/AuthService")); - } - + let session = require("../js/Session"); route("/poll/create", () => { riot.mount(this.refs.content, "createpoll"); }); @@ -50,14 +44,15 @@ require("./poll/CreatePoll.tag"); riot.mount(this.refs.content, "userfavoritelists"); }); route("/poll/new/*/*", (type, step) => { - riot.mount(this.refs.content, "createpoll", {type: type, step:step}); + riot.mount(this.refs.content, "createpoll", {type: type, step: step}); }); - route( () => { + route(() => { riot.mount(this.refs.content, "home"); }); - emitter.onUnauthorize(() => { - route("/signin") + session.start().then(() => { + //console.info('session loaded'); }); + </script> </Pollen> diff --git a/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag b/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag index 1a67725..dda079a 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag +++ b/pollen-ui-riot-js/src/main/web/tag/SignCheck.tag @@ -1,7 +1,3 @@ -let authService = require("../js/AuthService"); -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); - <SignCheck> <div class="body-container"> <div class="body-container"> @@ -23,8 +19,10 @@ let emitter = require("../js/EmitterService"); </div> <script> + let authService = require("../js/AuthService"); + let session = require("../js/Session"); - this.installBundle(session.locale, "signcheck", emitter); + this.installBundle(session, "signcheck"); this.message = this.__.validating; this.error = false; authService.validateEmail(opts.id, opts.token) diff --git a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag index c1a0863..c9b5117 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag +++ b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag @@ -1,9 +1,4 @@ -let authService = require("../js/AuthService"); -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); -let route = require("riot-route"); require("./popup/NewPassword.tag"); - <SignIn> <div class="body-container"> <form class="signin" method="post" onsubmit="{signIn}"> @@ -28,7 +23,11 @@ require("./popup/NewPassword.tag"); <NewPassword ref="newPassword"/> <script> - this.installBundle(session.locale, "signin", emitter); + let authService = require("../js/AuthService"); + let session = require("../js/Session"); + let route = require("riot-route"); + + this.installBundle(session, "signin"); this.message = ""; this.newPassword = () => { diff --git a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag index 1dfa81c..2b6650f 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag +++ b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag @@ -1,7 +1,3 @@ -let authService = require("../js/AuthService"); -let session = require("../js/Session"); -let emitter = require("../js/EmitterService"); -let FormHelper = require("../js/FormHelper"); let route = require("riot-route"); require("./popup/ResendValidation.tag"); require("./popup/AccountCreated.tag"); @@ -28,6 +24,9 @@ require("./popup/AccountCreated.tag"); <AccountCreated ref="accountCreated"/> <script> + let authService = require("../js/AuthService"); + let session = require("../js/Session"); + let FormHelper = require("../js/FormHelper"); this.on('mount', () => { if (this.validate) { @@ -35,7 +34,7 @@ require("./popup/AccountCreated.tag"); } }); - this.installBundle(session.locale, "signup", emitter); + this.installBundle(session, "signup"); this.errors = ""; this.resendValidation = () => { diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag index 76dcb10..4220df5 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/CreatePoll.tag @@ -4,66 +4,154 @@ require("./PollChoicesImage.tag"); require("./PollChoicesDate.tag"); require("./PollSettings.tag"); require("./PollVoters.tag"); +require("./PollCreated.tag"); <CreatePoll> <div> - <div class="header-container"> - <div class="{step == 0 ? 'header-selected-tab' : ''}"> + <div if="{form.step < 4}" class="header-container"> + <div class="{form.step == 0 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">1</strong> + </span> + <a if="{form.step > 0}" onclick="{goto0}"> + {__.header_general} + </a> + <span if="{form.step == 0}"> + {__.header_general} + </span> + </div> + <div class="{form.step == 1 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">2</strong> + </span> + <a if="{form.step > 1}" onclick="{goto1}"> + {__.header_choices} + </a> + <span if="{form.step <= 1}"> + {__.header_choices} + </span> + </div> + <div class="{form.step == 2 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">3</strong> + </span> + <a if="{form.step > 2}" onclick="{goto2}"> + {__.header_options} + </a> + <span if="{form.step <= 2}"> + {__.header_options} + </span> + </div> + <div class="{form.step == 3 ? 'header-selected-tab' : ''}"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">4</strong> + </span> + {__.header_voters} + </div> + <div> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">5</strong> + </span> + {__.header_summary} + </div> + </div> + + <div if="{form.step==4}" class="header-container"> + <div> <span class="fa-stack fa-2x"> <i class="fa fa-circle-o fa-stack-2x"></i> <strong class="fa-stack-1x">1</strong> </span> {__.header_general} </div> - <div class="{step == 1 ? 'header-selected-tab' : ''}"> + <div> <span class="fa-stack fa-2x"> <i class="fa fa-circle-o fa-stack-2x"></i> <strong class="fa-stack-1x">2</strong> </span> {__.header_choices} </div> - <div class="{step == 2 ? 'header-selected-tab' : ''}"> + <div> <span class="fa-stack fa-2x"> <i class="fa fa-circle-o fa-stack-2x"></i> <strong class="fa-stack-1x">3</strong> </span> {__.header_options} </div> - <div class="{step == 3 ? 'header-selected-tab' : ''}"> + <div> <span class="fa-stack fa-2x"> <i class="fa fa-circle-o fa-stack-2x"></i> <strong class="fa-stack-1x">4</strong> </span> {__.header_voters} </div> + <div class="header-selected-tab"> + <span class="fa-stack fa-2x"> + <i class="fa fa-circle-o fa-stack-2x"></i> + <strong class="fa-stack-1x">5</strong> + </span> + {__.summary} + </div> </div> <div> - <PollDescription if="{step == 0}" form="{form}" session="{session}" emitter="{emitter}"/> - <PollChoicesText if="{step == 1 && type == 'text'}" form="{form}" session="{session}" emitter="{emitter}"/> - <PollChoicesImage if="{step == 1 && type == 'image'}" form="{form}" session="{session}" - emitter="{emitter}"/> - <PollChoicesDate if="{step == 1 && type == 'date'}" form="{form}" session="{session}" emitter="{emitter}"/> - <PollSettings if="{step == 2}" form="{form}" session="{session}" emitter="{emitter}"/> - <PollVoters if="{step == 3}" form="{form}" session="{session}" emitter="{emitter}"/> + <div ref="content"/> </div> </div> <script> + + console.info("Create poll"); this.type = opts.type; this.form = require("../../js/PollForm"); - this.emitter = require("../../js/EmitterService"); this.session = require("../../js/Session"); this.form.type = this.type; - this.installBundle(this.session.locale, "poll", this.emitter); + this.steps = { + 0: 'polldescription', + 1: 'pollchoices' + this.type, + 2: 'pollsettings', + 3: 'pollvoters', + 4: 'pollcreated' + }; + this.installBundle(this.session, "poll"); - if (!this.form.model) { - this.form.init(this.session.user); + this.goto0 = (e) => { this.form.setStep(0); - } else if (opts.step) { - this.form.step = parseInt(opts.step); + }; + this.goto1 = (e) => { + this.form.setStep(1); + }; + this.goto2 = (e) => { + this.form.setStep(2); + }; + + this.finalizeInit = () => { + let step = this.form.step; +// console.info("Current step!!!!!! " + step); + + riot.mount(this.refs.content, this.steps[step], {form: this.form, session: this.session}); + + }; + + if (!this.form.isInit) { + this.form.init().then(() => { + this.form.setStep(0); + this.finalizeInit(); + }); + + } else { + if (opts.step) { + this.form.step = parseInt(opts.step); + } + + this.on('mount', () => { + this.finalizeInit(); + }); } - this.step = this.form.step; - console.info("Current step!!!!!! " + this.step); </script> <style> @@ -83,7 +171,7 @@ require("./PollVoters.tag"); width: 160px; } - .header-selected-tab { + .header-selected-tab > span > i, .header-selected-tab > span > strong { color: #13a2ff; } diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceText.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceText.tag index a20c03d..2bd0ae3 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceText.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceText.tag @@ -1,23 +1,24 @@ <PollChoiceText> <div class="container"> - <label class="wide" for="choice{number}">Choix {number}</label> - <label if="{number == 1 }">Description</label> + <label class="wide" for="choice{number}">{__.label} {number + 1}</label> + <label if="{number == 0 }">{__.description}</label> </div> <div class="container"> - - <input class="wide" if="{number == 1}" type="text" required ref="choice{number}" name="choice{number}" - id="choice{number}" - value="{(choices[0] || {text:''}).text}"> - <input class="wide" if="{number > 1}" type="text" ref="choice{number}" name="choice{number}" id="choice{number}" - value="{(choices[number - 1] || {text:''}).text}"> - <input class="wider" type="text" ref="description{number}" name="description{number}" id="description{number}" - value="{(choices[number - 1] || {description:''}).description}"> + <input class="wide" type="text" ref="choice" name="choice{number}" value="{choice.choiceValue}"> + <input class="wider" type="text" ref="description" name="description{number}" value="{choice.description}"> </div> <script> + this.installBundle(opts.session, "poll_choices"); this.number = opts.number; - this.choices = opts.choices; + this.choice = opts.choices[this.number] || {name: '', description: ''}; + this.on('mount', () => { + if (this.number == 0) { + this.refs.choice.required = "require"; + } + }); + </script> <style> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceTextGroup.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceTextGroup.tag index 026cd3c..e4861da 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceTextGroup.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoiceTextGroup.tag @@ -1,14 +1,13 @@ require('./PollChoiceText.tag'); <PollChoiceTextGroup> - <PollChoiceText number="{start}" choices="{choices}"/> - <PollChoiceText number="{start + 1}" choices="{choices}"/> - <PollChoiceText number="{start + 2}" choices="{choices}"/> - <PollChoiceText number="{start + 3}" choices="{choices}"/> - <PollChoiceText number="{start + 4}" choices="{choices}"/> - + <PollChoiceText number="{start}" choices="{choices}" session="{session}"/> + <PollChoiceText number="{start + 1}" choices="{choices}" session="{session}"/> + <PollChoiceText number="{start + 2}" choices="{choices}" session="{session}"/> + <PollChoiceText number="{start + 3}" choices="{choices}" session="{session}"/> + <PollChoiceText number="{start + 4}" choices="{choices}" session="{session}"/> <script> this.choices = opts.choices; - this.descriptions = opts.descriptions; this.start = parseInt(opts.start); + this.session = opts.session; </script> </PollChoiceTextGroup> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesText.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesText.tag index b35c603..ab42cf9 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesText.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollChoicesText.tag @@ -2,25 +2,30 @@ require('./PollChoiceTextGroup.tag'); <PollChoicesText> <form ref="choices" onsubmit="{nextStep}"> <virtual each={item in counts}> - <PollChoiceTextGroup choices="{form.model.textChoices}" start="{item - 4}"/> + <PollChoiceTextGroup choices="{form.choices}" start="{item - 5}" session="{session}"/> </virtual> + <br/> <div class="actions"> - <a class="button" onclick="{addMoreChoices}"> <i class="fa fa-plus"/>Plus de choix</a> - <a class="button" onclick="{previousStep}">Précédent</a> - <input type="submit" class="button mainColorBackground" value="Suivant"> + <a class="button" onclick="{addMoreChoices}"> <i class="fa fa-plus"/>{__.moreChoices}</a> + </div> + <div class="actions"> + <a class="button" onclick="{previousStep}">{__.previous}</a> + <input type="submit" class="button mainColorBackground" value="{__.next}"> </div> </form> <script> + this.installBundle(opts.session, "poll_choices"); this.form = opts.form; + this.session = opts.session; this.on('mount', () => { this.choices = this.refs.choices; - let choices = this.form.model.textChoices; + let choices = this.form.choices; console.info("init step1 with " + choices.length + " choices"); console.info(choices); if (choices.length == 0) { - this.counts = []; - this.count = 0; + this.counts = [5]; + this.count = 5; } else { this.counts = []; this.count = 0; @@ -61,12 +66,15 @@ require('./PollChoiceTextGroup.tag'); </script> <style> + form { + margin-left: 20px; + } + a.button > i { margin-right: 10px; } .actions { - margin: 50px 10px 10px; display: flex; flex-direction: row; justify-content: flex-start; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollCreated.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollCreated.tag new file mode 100644 index 0000000..ee8a5bf --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollCreated.tag @@ -0,0 +1,40 @@ +<PollCreated> + + <div class="container"> + + <div class="legend"> + Sondage créé. + </div> + <div> + Le sondage «{form.model.title}» vient d'être créé. Un courriel vous a été adressé ainsi qu'aux éventuels participants. + + <br/> + <a href="#poll/{form.model.id}/edit">Accéder au sondage</a>. + + </div> + </div> + + <script> + this.form = opts.form; + console.info("Created poll"); + console.info(this.form); + </script> + <style> + + .container { + margin-left: 20px; + } + + .legend { + width: 100%; + height: 70px; + border-bottom: 1px solid #b2c7d3; + display: flex; + justify-content: flex-start; + align-items: center; + margin-bottom: 20px; + font-size: 20px; + } + + </style> +</PollCreated> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag index 8b447dc..5209173 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollDescription.tag @@ -1,20 +1,19 @@ <PollDescription> <form onsubmit="{nextStep}"> - <label for="title">Titre du sondage</label> - <input ref="title" type="text" required name="title" id="title" value="{model.title}" - placeholder="Enter le titre du sondage"> - <label for="name">Votre nom</label> - <input ref="name" type="text" required name="name" id="name" value="{model.name}" placeholder="Enter votre nom"> - <label for="email">Votre courriel</label> - <input ref="email" type="email" required name="email" id="email" value="{model.email}" - placeholder="Enter votre courriel"> - + <label for="title">{__.title}</label> + <input ref="title" type="text" required name="title" value="{model.title}" placeholder="{__.titlePlaceHolder}"> + <label for="name">{__.name}</label> + <input ref="name" type="text" required name="name" value="{model.name}" placeholder="{__.namePlaceHolder}"> + <label for="email">{__.email}</label> + <input ref="email" type="email" required name="email" value="{model.email}" placeholder="{__.emailPlaceHolder}"> + <br/> <div class="actions"> - <a class="button" onclick="{cancel}">Annuler</a> - <input type="submit" class="button mainColorBackground" value="Suivant"> + <a class="button" onclick="{cancel}">{__.cancel}</a> + <input type="submit" class="button mainColorBackground" value="{__.next}"> </div> </form> <script> + this.installBundle(opts.session, "poll_description", opts.emitter); this.form = opts.form; this.emitter = opts.emitter; this.session = opts.session; @@ -33,12 +32,16 @@ }; </script> <style> + form { + margin-left: 20px; + } + form > input { width: 440px; } .actions { - margin: 50px 10px 10px; + /*margin: 50px 10px 10px;*/ display: flex; flex-direction: row; justify-content: flex-start; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag index 86422f2..a1a40ce 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollSettings.tag @@ -5,134 +5,199 @@ <a class="button skip mainColorBackground" onclick="{nextStep}">{__.skip}</a> </div> - <div id="navigation"> + <div class="actions"> + <a if="{!showOptions}" class="button" onclick="{previousStep}">{__.previous}</a> + <a if="{!showOptions}" class="button wide" onclick="{toggleShowOptions}">{__.showOptions}</a> + <a if="{showOptions}" class="button wide" onclick="{toggleShowOptions}">{__.hideOptions}</a> + </div> + + <div if="{showOptions}" id="navigation"> <nav class="bs-docs-sidebar"> <ul id="sidebar" class="nav nav-stacked"> <li> - <a onclick="{scrollTo}" href="#GlobalConfiguration">Poll</a> + <a onclick="{scrollTo}" href="#Poll">{__.nav_poll}</a> <ul class="nav nav-stacked"> - <li><a onclick="{scrollTo}" href="#GlobalConfiguration_beginDate">Begin date</a></li> - <li><a onclick="{scrollTo}" href="#GlobalConfiguration_endDate">End date</a></li> - <li><a onclick="{scrollTo}" href="#GlobalConfiguration_resultVisibility">Result visibility</a> + <li> + <a onclick="{scrollTo}" href="#Poll_beginDate">{__.nav_voteBeginDate}</a> + </li> + <li> + <a onclick="{scrollTo}" href="#Poll_endDate">{__.nav_voteEndDate}</a> + </li> + <li> + <a onclick="{scrollTo}" href="#Poll_resultVisibility">{__.nav_resultVisibility}</a> + </li> + <li> + <a onclick="{scrollTo}" href="#Poll_continiousVisibility">{__.nav_continiousResult}</a> </li> - <li><a onclick="{scrollTo}" href="#GlobalConfiguration_continiousVisibility">Continious - result</a></li> </ul> </li> <li> - <a onclick="{scrollTo}" href="#ChoiceConfiguration">Choices</a> + <a onclick="{scrollTo}" href="#Choice">{__.nav_choices}</a> <ul class="nav nav-stacked"> - <li><a onclick="{scrollTo}" href="#ChoiceConfigurationaddChoices">Add choices</a></li> - <li><a onclick="{scrollTo}" href="#ChoiceConfiguration_limitChoices">Limit choices</a></li> + <li> + <a onclick="{scrollTo}" href="#ChoiceaddChoices">{__.nav_addChoices}</a> + </li> + <li> + <a onclick="{scrollTo}" href="#Choice_limitChoices">{__.nav_limitChoices}</a> + </li> </ul> </li> <li> - <a onclick="{scrollTo}" href="#VoteConfiguration">Votes</a> + <a onclick="{scrollTo}" href="#Vote">{__.nav_votes}</a> <ul class="nav nav-stacked"> - <li><a onclick="{scrollTo}" href="#VoteConfiguration_countingType">Vote counting type</a></li> - <li><a onclick="{scrollTo}" href="#VoteConfiguration_visibility">Vote visibility</a></li> - <li><a onclick="{scrollTo}" href="#VoteConfiguration_anonymous">Anonymous vote</a></li> + <li> + <a onclick="{scrollTo}" href="#Vote_countingType">{__.nav_voteCountingType}</a> + </li> + <li> + <a onclick="{scrollTo}" href="#Vote_visibility">{__.nav_voteVisibility}</a> + </li> + <li> + <a onclick="{scrollTo}" href="#Vote_anonymous">{__.nav_anonymousVote}</a> + </li> </ul> </li> <li> - <a onclick="{scrollTo}" href="#CommentConfiguration">Comments</a> + <a onclick="{scrollTo}" href="#Comment">{__.nav_comments}</a> <ul class="nav nav-stacked"> - <li><a onclick="{scrollTo}" href="#CommentConfiguration_enabled">Use comments</a></li> - <li><a onclick="{scrollTo}" href="#CommentConfiguration_visibility">Comment visibility</a></li> + <li> + <a onclick="{scrollTo}" href="#Comment_visibility">{__.nav_commentVisibility}</a> + </li> </ul> </li> </ul> </nav> <div ref="content" class="content"> - <div class="config-group" id="GlobalConfiguration"> - <div class="config-header">Poll configuration</div> - <div id="GlobalConfiguration_beginDate" class="subgroup"> - <div class="config-subheader">Begin date</div> - <div class="config-description"> - When users can start to vote. + <div class="config-group" id="Poll"> + <div class="config-header">{__.poll_configuration}</div> + <div id="Poll_beginDate"> + <div class="config-subheader">{__.nav_voteBeginDate}</div> + <div class="config-description">{__.voteBeginDate} </div> </div> - <div id="GlobalConfiguration_endDate" class="subgroup"> - <div class="config-subheader">End date</div> - <div class="config-description"> - Limit date of voting. - </div> + <div id="Poll_endDate"> + <div class="config-subheader">{__.nav_voteEndDate}</div> + <div class="config-description">{__.voteEndDate}</div> </div> - <div id="GlobalConfiguration_resultVisibility" class="subgroup"> - <div class="config-subheader">Result visibility</div> + <div id="Poll_resultVisibility"> + <div class="config-subheader">{__.nav_resultVisibility}</div> <div class="config-description"> - Who can see results. + {__.resultVisibility} + </div> + <div class="config-form"> + <ul> + <li> + <input type="radio" name="resultVisibility">{__.resultVisibility_creator} + </li> + <li> + <input type="radio" name="resultVisibility">{__.resultVisibility_voter} + </li> + <li> + <input type="radio" name="resultVisibility">{__.resultVisibility_everybody} + </li> + </ul> </div> </div> - <div id="GlobalConfiguration_continiousVisibility" class="subgroup"> - <div class="config-subheader">Continious result</div> - <div class="config-description"> - Te see continious results. + <div id="Poll_continiousVisibility"> + <div class="config-subheader">{__.nav_continiousResult}</div> + <div class="config-description"> {__.continiousResult}</div> + <div class="config-form"> + <input type="checkbox" name="continiousResult" ref="continiousResult">{__.continiousResult} </div> </div> </div> - <div id="ChoiceConfiguration" class="config-group"> - <div class="config-header">Choices configuration</div> - <div id="ChoiceConfigurationaddChoices" class="subgroup"> - <div class="config-subheader">Can users add choices?</div> - <div class="config-description"> - Is users can add choices to poll? + <div id="Choice" class="config-group"> + <div class="config-header">{__.choicesConfiguration}</div> + <div id="Choice_addChoices"> + <div class="config-subheader">{__.nav_addChoices}</div> + <div class="config-description">{__.addChoices}</div> + <div class="config-form"> + <input type="checkbox" name="addChoices" ref="addChoices">{__.addChoices} </div> </div> - <div id="ChoiceConfiguration_limitChoices" class="subgroup"> - <div class="config-subheader">Limit number of choices</div> - <div class="config-description"> - To limit the number of choices what user can vote on. + <div id="Choice_limitChoices"> + <div class="config-subheader">{__.nav_limitChoices}</div> + <div class="config-description">{__.limitChoices}</div> + <div class="config-form"> + <input type="checkbox" name="limitChoices" ref="limitChoices">{__.limitChoices} </div> </div> </div> - <div id="VoteConfiguration" class="config-group"> - <div class="config-header">Votes configuration</div> - <div id="VoteConfiguration_countingType" class="subgroup"> - <div class="config-subheader">Vote counting type</div> - <div class="config-description"> - Defines the vote counting type. + <div id="Vote" class="config-group"> + <div class="config-header">{__.votesConfiguration}</div> + <div id="Vote_countingType"> + <div class="config-subheader">{__.nav_voteCountingType}</div> + <div class="config-description">{__.voteCountingType}</div> + <div class="config-form"> + <ul> + <li> + <input type="radio" name="voteCountingType">{__.voteCountingType_normal} + </li> + <li> + <input type="radio" name="voteCountingType">{__.voteCountingType_pourcentage} + </li> + <li> + <input type="radio" name="voteCountingType">{__.voteCountingType_condorcet} + </li> + </ul> </div> </div> - <div id="VoteConfiguration_visibility" class="subgroup"> - <div class="config-subheader">Vote visibility</div> - <div class="config-description"> - Who can see votes? + <div id="Vote_visibility"> + <div class="config-subheader">{__.nav_voteVisibility}</div> + <div class="config-description">{__.voteVisibility}</div> + <div class="config-form"> + <ul> + <li> + <input type="radio" name="voteVisibility" ref="voteVisibilityNobody">{__.voteVisibility_creator} + </li> + <li> + <input type="radio" name="voteVisibility" ref="voteVisibilityVoter">{__.voteVisibility_voter} + </li> + <li> + <input type="radio" name="voteVisibility" ref="voteVisibilityEverybody">{__.voteVisibility_everybody} + </li> + </ul> </div> </div> - <div id="VoteConfiguration_anonymous" class="subgroup"> - <div class="config-subheader">Anonymous votes</div> - <div class="config-description"> - Anonymze votes + <div id="Vote_anonymous"> + <div class="config-subheader">{__.nav_anonymousVote}</div> + <div class="config-description">{__.anonoymousVote}</div> + <div class="config-form"> + <input type="checkbox" name="anonymousVote" ref="anonymousVote">{__.anonymousVote} </div> </div> </div> - <div id="CommentConfiguration" class="config-group"> - <div class="config-header">Comments configuration</div> - <div id="CommentConfiguration_enabled" class="subgroup"> - <div class="config-subheader">Comment enabled?</div> - <div class="config-description"> - Can use comments on a poll? - </div> - </div> - <div id="CommentConfiguration_visibility" class="subgroup"> - <div class="config-subheader">Comment visibility</div> - <div class="config-description"> - Who can see comments. + <div id="Comment" class="config-group"> + <div class="config-header">{__.commentsConfiguration}</div> + <div id="Comment_visibility"> + <div class="config-subheader">{__.nav_commentVisibility}</div> + <div class="config-description">{__.commentVisibility}</div> + <div class="config-form"> + <ul> + <li> + <input type="radio" name="commentVisibility" ref="commentVisibilityCreator">{__.commentVisibility_creator} + </li> + <li> + <input type="radio" name="commentVisibility" ref="commentVisibilityVoter">{__.commentVisibility_voter} + </li> + <li> + <input type="radio" name="commentVisibility" ref="commentVisibilityEverybody">{__.commentVisibility_everybody} + </li> + </ul> </div> </div> </div> </div> </div> - <div class="actions"> + <div if="{showOptions}" class="actions"> <a class="button" onclick="{previousStep}">{__.previous}</a> <a class="button mainColorBackground" onclick="{nextStep}">{__.next}</a> </div> <script> this.form = opts.form; - this.installBundle(opts.session.locale, "poll_settings", opts.emitter); + this.showOptions = this.form.showOptions; + this.installBundle(opts.session, "poll_settings"); this.previousStep = (e) => { this.form.previousStep(); }; @@ -144,15 +209,31 @@ e.preventDefault(); e.stopPropagation(); let id = e.currentTarget.href.substring(e.currentTarget.href.indexOf('#') + 1); - if (id.indexOf('_')>-1) { + if (id.indexOf('_') > -1) { id = id.substring(0, id.indexOf('_')); } document.getElementById(id).scrollIntoView(); }; + this.toggleShowOptions = () => { + this.showOptions = this.form.showOptions = !this.showOptions; + } + </script> <style> + .config-form > ul > li > input, .config-form > input { + display: inline; + width: 50px; + margin: 0; + padding: 0; + height: 16px; + } + + .wide { + width: 250px; + } + .config-header { border-bottom: solid 2px #c8ccca; font-size: 20px; @@ -191,17 +272,16 @@ .legend { width: 100%; - height: 70px; border-bottom: 1px solid #b2c7d3; display: flex; - justify-content: center; + justify-content: flex-start; + margin-left: 20px; align-items: center; - margin-bottom: 30px; font-size: 20px; } .actions { - margin: 50px 10px 10px; + margin: 10px; display: flex; flex-direction: row; justify-content: flex-start; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag b/pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag index b057aff..5f9c129 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag +++ b/pollen-ui-riot-js/src/main/web/tag/poll/PollVoters.tag @@ -1,42 +1,185 @@ <PollVoters> - <div> - Participants au sondage - </div> + <form onsubmit="{action}"> - <div class="actions"> - <a class="button" onclick="{previousStep}">Précédent</a> - <a class="button done" onclick="{validate}">Terminer</a> - </div> + <div class="legend"> + {__.description} + </div> + + <div class="mainOptions"> + <div class="mainOptionsDiv"> + <input type="radio" name="voteType" ref="publicType" onclick="{publicPoll}"> + {__.freePoll} + </div> + <div> + <div class="mainOptionsDiv"> + <input type="radio" ref="privateType" name="voteType" onclick="{privatePoll}"> + {__.restrictedPoll} + </div> + <div show="{$private}" class="privateOptions"> + <div> + <input type="checkbox" name="withMe" ref="withMe" onclick="{withMe}">{__.restrictedPoll_withMe} + </div> + </div> + </div> + </div> + <div class="legend"> + {__.invite} + </div> + + <div class="participants"> + <label for="paticipants">{__.invite_label}</label> + <textarea if="{!$private}" rows="5" ref="participants" name="participants" onchange="{participantsChanged}" + value="{participants}"/> + <textarea if="{$private}" required rows="5" ref="participants" name="participants" value="{participants}" + onchange="{participantsChanged}"/> + </div> + <div class="actions"> + <a class="button" onclick="{previousStep}">{__.previous}</a> + <input type="submit" class="button mainColorBackground" value="{__.save}"> + </div> + + </form> <script> + this.installBundle(opts.session, "poll_voters"); this.form = opts.form; + this.$private = this.form.model.pollType != 'FREE'; + this.participants = ""; this.previousStep = (e) => { this.form.previousStep(); }; - this.validate = (e) => { - this.form.save().then(poll => { - console.info("poll saved"); - console.info(poll); - }).catch(errors => { + this.on('mount', () => { + if (this.$private) { + this.refs.privateType.checked='checked'; + } else { + this.refs.publicType.checked='checked'; + } + if (this.form.model.withMe) { + this.refs.withMe.checked='checked'; + } + }); + this.action = (e) => { + e.preventDefault(); + e.stopPropagation(); + + this.form.model.participants = this.refs.participants.value.split(' '); + console.info('Poll form to save'); + console.info(this.form.model); + console.info('Poll choices to save'); + console.info(this.form.choices); + + this.form.create().catch(errors => { console.info("Can't save poll"); console.info(errors); }); + }; + this.publicPoll = () => { + if (this.form.model.pollType != 'FREE') { + this.form.model.pollType = 'FREE'; + this.form.model.withMe = false; + this.$private = false; + this.update(); + } + }; + this.privatePoll = () => { + if (this.form.model.pollType != 'RESTRICTED') { + this.form.model.pollType = 'RESTRICTED'; + this.$private = true; + this.update(); + } + }; + this.withMe = (e) => { + this.form.model.withMe = !this.form.model.withMe; + }; + this.participantsChanged = (e) => { + this.participants = e.target.value; + console.info(this.participants); } + </script> <style> + + form { + margin-left: 20px; + } + + textarea { + width: 80%; + } + + label { + width: 80%; + } + + .mainOptionsDiv > input, .privateOptions > div > input { + display: inline; + width: 50px; + margin: 0; + padding: 0; + height: 16px; + } + + .legend { + width: 100%; + height: 70px; + border-bottom: 1px solid #b2c7d3; + display: flex; + justify-content: flex-start; + align-items: center; + margin-bottom: 20px; + font-size: 20px; + } + + .participants { + margin-bottom: 5px; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + } + + .mainOptions { + margin-bottom: 5px; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + height: 80px; + } + + .mainOptionsDiv { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: flex-start; + margin-bottom: 5px; + } + + .privateOptions { + margin-left: 20px; + margin-bottom: 5px; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + } + .actions { - margin: 50px 10px 10px; + /*margin: 50px 10px 10px;*/ display: flex; flex-direction: row; justify-content: flex-start; align-items: center; } + .actions > a { margin: 5px; } - .done { - background-color: #13a2ff; + + .actions > input { + margin: 5px; } + </style> </PollVoters> \ No newline at end of file diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag b/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag index 9a8b5ef..28d41ce 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag +++ b/pollen-ui-riot-js/src/main/web/tag/popup/AccountCreated.tag @@ -1,7 +1,3 @@ -let session = require("../../js/Session"); -let emitter = require("../../js/EmitterService"); -let route = require("riot-route"); - <AccountCreated class="close"> <div class="popup-background"></div> @@ -18,8 +14,10 @@ let route = require("riot-route"); </div> <script> + let session = require("../../js/Session"); + let route = require("riot-route"); - this.installBundle(session.locale, "createdaccount", emitter); + this.installBundle(session, "createdaccount"); this.oldParent = this.parent.root; diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag b/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag index af16ac7..03a37f1 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag +++ b/pollen-ui-riot-js/src/main/web/tag/popup/NewPassword.tag @@ -1,7 +1,3 @@ -let session = require("../../js/Session"); -let emitter = require("../../js/EmitterService"); -let authService = require("../../js/AuthService"); - <NewPassword class="close"> <div class="popup-background"></div> @@ -23,8 +19,10 @@ let authService = require("../../js/AuthService"); </div> <script> + let session = require("../../js/Session"); + let authService = require("../../js/AuthService"); - this.installBundle(session.locale, "newpassword", emitter); + this.installBundle(session, "newpassword"); this.sent = false; this.error = ""; diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag b/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag index 05bfdbf..cc9bd2f 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag +++ b/pollen-ui-riot-js/src/main/web/tag/popup/ResendValidation.tag @@ -1,7 +1,3 @@ -let session = require("../../js/Session"); -let emitter = require("../../js/EmitterService"); -let authService = require("../../js/AuthService"); - <ResendValidation class="close"> <div class="popup-background"></div> @@ -24,7 +20,10 @@ let authService = require("../../js/AuthService"); <script> - this.installBundle(session.locale, "resendvalidation", emitter); + let session = require("../../js/Session"); + let authService = require("../../js/AuthService"); + + this.installBundle(session, "resendvalidation"); this.oldParent = this.parent.root; -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm