08/12: refs #44 nouvelle ui pour les adresses email
This is an automated email from the git hooks/post-receive script. New commit to branch feature/44_several_email_address in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 8c99b526f2a41361eea13396fef7fdabeeb0f6e0 Author: Kevin Morin <morin@codelutin.com> Date: Thu Oct 12 15:32:02 2017 +0200 refs #44 nouvelle ui pour les adresses email --- pollen-ui-riot-js/src/main/web/i18n/en.json | 15 +- pollen-ui-riot-js/src/main/web/i18n/fr.json | 54 +++--- pollen-ui-riot-js/src/main/web/js/UserService.js | 15 ++ .../src/main/web/tag/UserProfile.tag.html | 199 +++++++++++++++------ 4 files changed, 202 insertions(+), 81 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/i18n/en.json b/pollen-ui-riot-js/src/main/web/i18n/en.json index 6cdab3dd..4906fbb7 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/en.json +++ b/pollen-ui-riot-js/src/main/web/i18n/en.json @@ -409,15 +409,20 @@ "userProfile_deleteAccount": "Delete your account", "userProfile_deleteUserMessage": "Delete your account? All the polls you created will be deleted; your votes and comments will be anonymized.", "userProfile_identity": "Identity", + "userProfile_saveIdentity": "Save", + "userProfile_updatedIdentity": "Your identity has been updated", "userProfile_name": "Name", "userProfile_name_placeholder": "Enter your user name", - "userProfile_email": "Email", - "userProfile_email_placeholder": "Enter your email", + "userProfile_email": "Email address", + "userProfile_emails": "Email addresses", + "userProfile_defaultEmailAddress": "Set as default email address", + "userProfile_email_placeholder": "Enter your email address", "userProfile_emailValidate": "Validate", - "userProfile_emailValidationWaiting": "Validation wainting", "userProfile_resendValidation": "Send a new invitation", - "userProfile_saveIdentity": "Save", - "userProfile_updatedIdentity": "Your identity has been updated", + "userProfile_validationResent": "An email has been sent to {0}", + "userProfile_addEmailAddress": "Add a new email address", + "userProfile_deleteEmailAddress": "Delete the email address", + "userProfile_deleteEmailAddressMessage": "Delete the email address {0}?", "userProfile_passwordChange": "Password change", "userProfile_oldPassword": "Old password", "userProfile_oldPassword_placeholder": "Enter your old password", diff --git a/pollen-ui-riot-js/src/main/web/i18n/fr.json b/pollen-ui-riot-js/src/main/web/i18n/fr.json index c3b3037a..6a2e2d5a 100644 --- a/pollen-ui-riot-js/src/main/web/i18n/fr.json +++ b/pollen-ui-riot-js/src/main/web/i18n/fr.json @@ -196,9 +196,9 @@ "resendvalidation_title": "Renvoyer un courriel de validation de compte", "resendvalidation_cancel": "Annuler", "resendvalidation_action": "Envoyer", - "resendvalidation_placeholder": "Entrez votre courriel", + "resendvalidation_placeholder": "Entrez votre adresse électronique", "resendvalidation_sent": "Un nouveau courriel d'invitation a été envoyé", - "resendvalidation_error_emailNotFound": "Le courriel n'a pas été trouvé", + "resendvalidation_error_emailNotFound": "L'adresse électronique n'a pas été trouvé", "signcheck_title": "Validation de votre compte", "signcheck_signin": "Vous connecter", "signcheck_resendValidation": "Envoyer une nouvelle invitation", @@ -214,13 +214,13 @@ "signin_lostpassword": "Mot de passe perdu ?", "signin_connexion": "Se connecter", "signin_signinWithProvider": "Ou connectez vous avec votre compte :", - "signin_error_signin_emailOrPasswordInvalid": "Courriel ou mot de passe invalide", + "signin_error_signin_emailOrPasswordInvalid": "Adresse électronique ou mot de passe invalide", "signin_error_signin_banned": "Compte bloqué", "signin_error_signin_emailNotValidated": "Vous devez valider votre compte avant de pouvoir vous connecter. Relevez vos emails, nous vous avons envoyé un lien de validation.", "newpassword_title": "Obtenir un nouveau mot de passe", "newpassword_action": "Envoyer", - "newpassword_placeholder": "Entrez votre courriel", - "newpassword_error_emailNotFound": "Le courriel n'a pas été trouvé", + "newpassword_placeholder": "Entrez votre adresse électronique", + "newpassword_error_emailNotFound": "L'adresse électronique n'a pas été trouvé", "newpassword_sent": "Un nouveau mot de passe vient d'être envoyé", "footer_doc": "Pollen 3.1", "footer_download": "Télécharger", @@ -259,8 +259,8 @@ "poll_description_name": "Votre nom", "poll_description_namePlaceHolder": "Renseignez votre nom", "poll_description_nameNotBlank": "Vote nom ne doit pas être blanc", - "poll_description_email": "Votre courriel", - "poll_description_emailPlaceHolder": "Renseignez votre courriel", + "poll_description_email": "Votre adresse électronique", + "poll_description_emailPlaceHolder": "Renseignez votre adresse électronique", "poll_settings_restricted": "Sondage restreint ?", "poll_settings_restricted_yes": "Seules les personnes invitées à l'etape suivante peuvent voter. Un courriel leur sera envoyé avec un lien personnel.", "poll_settings_restricted_no": "Toutes les personnes ayant le lien du sondage peuvent voter.", @@ -346,12 +346,12 @@ "poll_settings_restrictedPoll": "Seul les invités peuvent voter (Sondage privé)", "poll_settings_restrictedPoll_withMe": "Je participe au sondage", "poll_settings_notification": "Recevoir des notifications :", - "poll_settings_notification_disabled": "Pour activer les notifications, vous devez renseigner votre courriel dans la partie 'Description'.", + "poll_settings_notification_disabled": "Pour activer les notifications, vous devez renseigner votre adresse électronique dans la partie 'Description'.", "poll_settings_voteNotification": "À chaque action sur les votes", "poll_settings_commentNotification": "À chaque action sur les commentaires", "poll_settings_newChoiceNotification": "À chaque ajout de choix", "poll_settings_notifyMeBeforePollEnds": "Recevoir une notification avant la fin des votes", - "poll_settings_notifyMeBeforePollEnds_disabled": "Pour activer le rappel de la fin du sondage, vous devez renseigner votre courriel dans la partie 'Description', et choisir une date de fin pour le sondage en activant la période d'ouverture des votes.", + "poll_settings_notifyMeBeforePollEnds_disabled": "Pour activer le rappel de la fin du sondage, vous devez renseigner votre adresse électronique dans la partie 'Description', et choisir une date de fin pour le sondage en activant la période d'ouverture des votes.", "poll_settings_notifyMeHoursBeforePollEnds": "Combien d'heures avant ?", "poll_choices_title": "Liste des choix", "poll_choices_label": "Choix", @@ -375,7 +375,7 @@ "poll_voters_restrictedPoll_withGroup": "Organiser les invités dans des groupes", "poll_voters_invite": "Inviter des participants", "poll_voters_already_invite_label": "Participants déjà invités", - "poll_voters_new_invite_label": "Renseignez le courriel des participants (séparé par un espace)", + "poll_voters_new_invite_label": "Renseignez les adresses électroniques des participants (séparées par un espace)", "poll_created_title": "Sondage créé", "poll_created_message": "Le sondage vient d'être créé. Un courriel vous a été adressé ainsi qu'aux éventuels participants.", "poll_created_edit": "Pour gérer le sondage, veuillez utiliser le lien suivant", @@ -391,7 +391,7 @@ "users_manyFound": "{0} trouvés sur ", "user_banned": "Banni", "user_emailValidate": "En cours de validation", - "user_emailIsValidate": "Courriel validé", + "user_emailIsValidate": "Adresse électronique validé", "user_administrator": "Administrateur", "user_edit": "Modifier l'utilisateur", "user_ban": "Désactiver", @@ -400,7 +400,7 @@ "user_deleteUser": "Supprimer l'utilisateur", "user_deleteUserMessage": "Supprimer l'utilisateur ?", "user_name": "Nom", - "user_email": "Courriel", + "user_email": "Adresse électronique", "user_premiumTo": "Illimité jusqu'au", "user_premiumOf": "Fin de l'illimité depuis le", "user_cancel": "Annuler", @@ -411,13 +411,17 @@ "userProfile_identity": "Identité", "userProfile_name": "Nom", "userProfile_name_placeholder": "Entrez votre nom d'utilisateur", - "userProfile_email": "Courriel", - "userProfile_email_placeholder": "Entrez votre courriel", - "userProfile_emailValidate": "Courriel vérifié", - "userProfile_emailValidationWaiting": "En cours de validation", - "userProfile_resendValidation": "Envoyer une nouvelle invitation", "userProfile_saveIdentity": "Enregistrer", "userProfile_updatedIdentity": "Votre identité a été mise à jour", + "userProfile_email": "Adresse électronique", + "userProfile_emails": "Adresses électroniques", + "userProfile_defaultEmailAddress": "Définir comme adresse par défaut", + "userProfile_email_placeholder": "Entrez votre adresse électronique", + "userProfile_resendValidation": "Envoyer un nouveau courriel de validation de l'adresse électronique", + "userProfile_validationResent": "Un courriel a été envoyé à l'adresse {0}", + "userProfile_addEmailAddress": "Ajouter une adresse électronique", + "userProfile_deleteEmailAddress": "Supprimer l'adresse électronique", + "userProfile_deleteEmailAddressMessage": "Supprimer l'adresse électronique {0} ?", "userProfile_passwordChange": "Changement de mot de passe", "userProfile_oldPassword": "Ancien mot de passe", "userProfile_oldPassword_placeholder": "Entrez votre ancien mot de passe", @@ -473,7 +477,7 @@ "favoriteList_add": "Ajouter", "search_label": "Rechercher", "favoriteList_createDate": "Date de création", - "favoriteList_email": "Courriel", + "favoriteList_email": "Adresse électronique", "favoriteList_noFavoriteList": "Aucune liste de votants", "favoriteList_cancel": "Annuler", "favoriteList_back": "Retour", @@ -486,7 +490,7 @@ "favoriteList_member_import": "Importer", "favoriteList_member_importCsv": "Importer un fichier CSV", "favoriteList_member_csvFile": "Fichier des membres", - "favoriteList_member_csvFile_exemple": "# Courriel;Nom;Poids\ndupond@domaine.fr;Jean Dupond;1.00\npseudo@bleu.fr;Arnaud Lemaitre;4.50\nmiller@courriel.com;Benjamin Miller;3.00", + "favoriteList_member_csvFile_exemple": "# Adresse électronique;Nom;Poids\ndupond@domaine.fr;Jean Dupond;1.00\npseudo@bleu.fr;Arnaud Lemaitre;4.50\nmiller@courriel.com;Benjamin Miller;3.00", "favoriteList_member_csvFile_exemple_label": "Exemple de fichier", "favoriteList_member_csvFile_exemple_detail": "Si le poids est omis, sa valeur par défaut est 1", "favoriteList_member_importLdap": "Importer un annuaire LDAP", @@ -501,8 +505,8 @@ "favoriteList_member_save": "Enregistrer", "favoriteList_member_name": "Nom", "favoriteList_member_name_placeholder": "Le nom du membre", - "favoriteList_member_email": "Courriel", - "favoriteList_member_email_placeholder": "Le courriel du membre", + "favoriteList_member_email": "Adresse électronique", + "favoriteList_member_email_placeholder": "L'adresse électronique du membre", "favoriteList_member_weight": "Poids", "favoriteList_member_ldap_placeholder": "L'adresse de l'annuaire LDAP", "favoriteList_member_add": "Ajouter", @@ -546,8 +550,8 @@ "voterList_member_edit": "Modifier le participant", "voterList_member_name": "Nom", "voterList_member_name_error_alreadyExist": "Le Nom existe dèjà dans cette liste", - "voterList_member_email": "Courriel", - "voterList_member_email_error_alreadyExist": "Le Courriel existe dèjà dans cette liste", + "voterList_member_email": "Adresse électronique", + "voterList_member_email_error_alreadyExist": "L'adresse électronique existe dèjà dans cette liste", "voterList_member_weight": "Poids", "voterList_member_delete": "Supprimer le participant", "voterList_member_deleteMessage": "Supprimer le participant ?", @@ -570,8 +574,8 @@ "report_level_off_topic_detail": "Un contenu hors-sujet", "report_level_illegal": "Illégal", "report_level_illegal_detail": "Un contenu manifestement illégal", - "report_email": "Votre courriel", - "report_email_placeholder": "Votre-courriel@exemple.com", + "report_email": "Votre adresse électronique", + "report_email_placeholder": "Votre-adresse-electronique@exemple.com", "report_count": "Signalement", "report_score": "Score", "report_reports_title": "Signalements", diff --git a/pollen-ui-riot-js/src/main/web/js/UserService.js b/pollen-ui-riot-js/src/main/web/js/UserService.js index b54ecc0f..aed9818d 100644 --- a/pollen-ui-riot-js/src/main/web/js/UserService.js +++ b/pollen-ui-riot-js/src/main/web/js/UserService.js @@ -57,6 +57,21 @@ class UserService extends FetchService { return this.post(url, user); } + addEmailAddressToUser(emailAddress) { + let url = this._getUserUrlPrefix() + "/email"; + return this.post(url, emailAddress); + } + + deleteEmailAddress(emailAddressId) { + let url = this._getUserUrlPrefix() + "/email/" + emailAddressId; + return this.doDelete(url); + } + + setDefaultEmailAddress(emailAddressId) { + let url = this._getUserUrlPrefix() + "/email/default?emailAddressId=" + emailAddressId; + return this.put(url); + } + changePassword(oldPassword, newPassword) { let url = this._getUserUrlPrefix() + "/password"; let body = { diff --git a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html index 8852a355..512ae8cc 100644 --- a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html @@ -32,60 +32,87 @@ require("./components/Avatar.tag.html"); <div class="main-content"> <div class="row-content"> - <form ref="identity-form" class="identity-form column-content"> - <HumanInput onsubmit={submitIdentity}/> - <h3 class="c-heading"><i class="fa fa-address-card"/> {__.identity}</h3> - <div class="o-form-element"> - <label class="c-label" for="name">{__.name}</label> - <input class="c-field {c-field--error : errors.name}" - type="text" - name="name" - ref="name" - value={user.name} - placeholder="{__.name_placeholder}" - required - maxlength="255"> - <div if="{errors.name}" - class="c-hint--static c-hint--error"> - {errors.name} + <div class="column-content"> + <form ref="identity-form" class="identity-form"> + <HumanInput onsubmit={submitIdentity}/> + <h3 class="c-heading"><i class="fa fa-address-card"/> {__.identity}</h3> + <div class="o-form-element"> + <label class="c-label" for="name">{__.name}</label> + <input class="c-field {c-field--error : errors.name}" + type="text" + name="name" + ref="name" + value={user.name} + placeholder="{__.name_placeholder}" + required + maxlength="255"> + <div if="{errors.name}" + class="c-hint--static c-hint--error"> + {errors.name} + </div> + </div> + <div class="actions-right"> + <button type="submit" + class="c-button c-button--info"> + <i class="fa fa-check" aria-hidden="true"></i> + {__.saveIdentity} + </button> + </div> + </form> + + <div class="email-addresses"> + <h3 class="c-heading"><i class="fa fa-at"/> {__.emails}</h3> + <div each="{emailAddress, index in user.emailAddresses}" class="email-address {index % 2 == 0 ? 'even' : 'odd'}"> + <span class="email-address-label {validation-pending : !emailAddress.validated} {default-address : user.defaultEmailAddress.id === emailAddress.id}"> + {emailAddress.emailAddress} + </span> + <button type="button" + class="c-button u-small c-button--gost-info" + if={!emailAddress.validated} + title="{__.resendValidation}" + onclick={resendValidation(emailAddress.emailAddress)}> + <i class="fa fa-paper-plane" aria-hidden="true"></i> + </button> + <button if="{user.defaultEmailAddress.id !== emailAddress.id && emailAddress.validated}" + class="c-button u-small c-button--info" + title="{__.defaultEmailAddress}" + onclick="{setDefaultEmailAddress(emailAddress.id)}"> + <i class="fa fa-envelope"></i> + </button> + <button disabled="{user.defaultEmailAddress.id === emailAddress.id}" + class="c-button u-small c-button--error" + title="{__.deleteEmailAddress}" + onclick="{deleteEmailAddress(emailAddress.id, index)}"> + <i class="fa fa-trash"></i> + </button> </div> </div> - <div class="o-form-element"> - <label class="c-label" for="email">{__.email}</label> - <div class="o-field o-field--icon-right"> - <input class="c-field {c-field--error : errors.email}" - type="email" - name="email" - ref="email" - value={user.email} - placeholder="{__.email_placeholder}" - required - maxlength="255"> - <i class="fa fa-fw fa-{user.emailIsValidate ? 'check' : 'refresh'} c-icon" - title={user.emailIsValidate ? __.emailValidate : __.emailValidationWaiting}></i> - </div> + <form ref="new-email-form" class="new-email-form"> + <HumanInput onsubmit={submitEmailAddress}/> + <div class="o-form-element c-input-group"> + <div class="o-field o-field--icon-right"> + <input class="c-field {c-field--error : errors.email}" + type="email" + name="email" + ref="newEmailAddress" + placeholder="{__.email_placeholder}" + required + maxlength="255"> + </div> + <button type="submit" + class="c-button c-button--success" + title="{__.addEmailAddress}"> + <i class="fa fa-plus" aria-hidden="true"></i> + </button> + </div> <div if="{errors.email}" class="c-hint--static c-hint--error"> {errors.email} </div> - </div> + </form> - <div class="actions-right"> - <button type="button" - class="c-button c-button--gost-info" - if={!user.emailIsValidate} - onclick={resendValidation}> - <i class="fa fa-paper-plane" aria-hidden="true"></i> - {__.resendValidation} - </button> - <button type="submit" - class="c-button c-button--info"> - <i class="fa fa-check" aria-hidden="true"></i> - {__.saveIdentity} - </button> - </div> - </form> + </div> <form ref="password-form" class="password-form column-content"> <HumanInput onsubmit={submitPassword}/> @@ -235,21 +262,60 @@ require("./components/Avatar.tag.html"); this.update(); }; - this.resendValidation = () => { - this.authService.resendValidation(this.user.email); - }; - this.submitIdentity = e => { e.preventDefault(); e.stopPropagation(); + let previousName = this.user.name; this.user.name = this.refs.name.value; - this.user.email = this.refs.email.value; userService.saveUser(this.user).then(() => { this.session.updateUser(); this.bus.trigger("message", new Message(this._l("updatedIdentity"), "success")); + }).catch((e) => { + this.errors.name = e.name; + this.update(); + }); + }; + + this.resendValidation = (emailAddress) => () => { + this.authService.resendValidation(emailAddress).then(() => { + this.bus.trigger("message", new Message(this._l("validationResent", emailAddress), "success")); + }); + }; + + this.deleteEmailAddress = (emailAddressId, index) => () => { + this.confirm(this._l("deleteEmailAddressMessage", this.user.emailAddresses[index].emailAddress)).then((confirm) => { + if (!confirm) { + return Promise.reject(); + } + return userService.deleteEmailAddress(emailAddressId); + }).then(result => { + this.user.emailAddresses.splice(index, 1); + this.session.updateUser(); }); }; + this.setDefaultEmailAddress = (emailAddressId, index) => () => { + userService.setDefaultEmailAddress(emailAddressId).then(() => { + this.user.defaultEmailAddress = this.user.emailAddresses[index]; + this.session.updateUser(); + }); + }; + + this.submitEmailAddress = e => { + e.preventDefault(); + e.stopPropagation(); + let emailAddress = this.refs.newEmailAddress.value; + userService.addEmailAddressToUser(emailAddress).then((result) => { + this.user.emailAddresses.push({id: result.id, emailAddress: emailAddress, validated: false}); + this.refs.newEmailAddress.value = null; + this.update(); + this.session.updateUser(); + }).catch((e) => { + this.errors.email = e.email; + this.update(); + }); + } + this.checkPassword = () => { var password = this.refs.newPassword.value; var repeatPassword = this.refs.repeatPassword.value; @@ -412,6 +478,37 @@ require("./components/Avatar.tag.html"); padding: 0 5px; } + .email-addresses { + width: 100%; + margin-top: 20px; + } + + .email-address { + display: flex; + justify-content: space-around; + align-items: center; + margin: 1px 0; + padding: 1px 5px; + } + + .email-address.odd { + background-color: var(--list-alternate-row); + } + + .email-address-label { + flex-grow: 1; + padding: 0 5px; + } + + .email-address-label.default-address { + font-weight: bold; + } + + .email-address-label.validation-pending { + font-style: italic; + opacity: 0.7; + } + .providers { padding: 0 10px; } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm