diff --git a/src/main/html/webapp/components/core/user/profile/profile.js b/src/main/html/webapp/components/core/user/profile/profile.js index 5142df29..22a71d9c 100644 --- a/src/main/html/webapp/components/core/user/profile/profile.js +++ b/src/main/html/webapp/components/core/user/profile/profile.js @@ -18,18 +18,37 @@ export default Control.extend({ "init": function(element, options) { + this.emailRequired = options.appState.attr('emailRequired'); $(element).hide(); User.findOne({ user: 'me' }, function(user) { $(element).html(template({ - user: user + user: user, + anonymousAccount: (!options.appState.attr('emailRequired')), + emailProvided: (user.attr('mail') != "" && user.attr('mail') != undefined), + userEmailDescription: options.appState.attr('userEmailDescription'), + userWithoutEmailDescription: options.appState.attr('userWithoutEmailDescription') })); options.user = user; $(element).fadeIn(); }); }, + "#anonymous click" : function(){ + if (!this.emailRequired){ + var anonymousControl = $(this.element).find("[name='anonymous']"); + var anonymous = !anonymousControl.is(':checked'); + var mail = $(this.element).find("[name='mail']"); + if (anonymous){ + mail.attr('disabled','disabled'); + } else { + mail.removeAttr('disabled'); + } + mail.val(""); + } + }, + 'submit': function(element, event) { event.preventDefault(); var user = new User(); @@ -39,10 +58,20 @@ export default Control.extend({ var fullnameError = user.checkName(fullname.val()); this.updateControl(fullname, fullnameError); + var anonymous = false; + if (!this.emailRequired){ + var anonymousControl = $(this.element).find("[name='anonymous']"); + anonymous = !anonymousControl.is(':checked'); + } + // mail var mail = $(element).find("[name='mail']"); - var mailError = user.checkMail(mail.val()); - this.updateControl(mail, mailError); + if (!anonymous){ + var mailError = user.checkMail(mail.val()); + this.updateControl(mail, mailError); + } else { + this.updateControl(mail, undefined); + } // password if password is not empty. else no password update on server side var newPassword = $(element).find("[name='new-password']"); @@ -204,4 +233,4 @@ export default Control.extend({ } -}); \ No newline at end of file +}); diff --git a/src/main/html/webapp/components/core/user/profile/profile.stache b/src/main/html/webapp/components/core/user/profile/profile.stache index e58d5281..a9b3de9d 100644 --- a/src/main/html/webapp/components/core/user/profile/profile.stache +++ b/src/main/html/webapp/components/core/user/profile/profile.stache @@ -16,12 +16,34 @@ Please fill out the form below to change your account settings or your password.
+ {{#is(anonymousAccount, false)}} ++ {{userEmailDescription}} +
+ + + +
+ {{userWithoutEmailDescription}}
+
This service provides a rich RestAPI to submit, monitor and download jobs.
@@ -59,7 +81,7 @@ Please fill out the form below to change your account settings or your password. {{../user.apiTokenMessage}} {{else}} - Expires in + Expires in