Skip to content

Commit

Permalink
Update signup form and add templates to customize it
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Dec 9, 2023
1 parent ed8938f commit 2c9f258
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
39 changes: 37 additions & 2 deletions src/main/html/webapp/components/core/user/signup/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,50 @@ export default Control.extend({
this.emailRequired = options.appState.attr('emailRequired');
$(element).hide();
$(element).html(template({
emailRequired: options.appState.attr('emailRequired')
emailRequired: options.appState.attr('emailRequired'),
userEmailDescription: options.appState.attr('userEmailDescription'),
userWithoutEmailDescription: options.appState.attr('userWithoutEmailDescription')
}));
$(element).fadeIn();
},

"#anonymous1 click" : function(){
this.updateEmailControl();
},

"#anonymous2 click" : function(){
this.updateEmailControl();
},

"updateEmailControl": function() {
if (!this.emailRequired){
var anonymousControl = $(this.element).find("[name='anonymous']:checked");
var anonymous = (anonymousControl.val() == "1");
console.log(anonymous);
var mail = $(this.element).find("[name='mail']");
console.log(mail);
if (anonymous){
mail.attr('disabled','disabled');
} else {
mail.removeAttr('disabled');
}
}
},

'submit': function(element, event) {
event.preventDefault();

var that = this;
var user = new User();

// anonymous radiobutton
var anonymous = false;

if (!this.emailRequired){
var anonymousControl = $(element).find("[name='anonymous']:checked");
anonymous = (anonymousControl.val() == "1");
}

// username
var username = $(element).find("[name='username']");
var usernameError = user.checkUsername(username.val());
Expand All @@ -35,9 +68,11 @@ export default Control.extend({

// mail
var mail = $(element).find("[name='mail']");
if (this.emailRequired || (mail.val() != "")){
if (!anonymous){
var mailError = user.checkMail(mail.val());
this.updateControl(mail, mailError);
} else {
this.updateControl(mail, undefined);
}

// password
Expand Down
24 changes: 23 additions & 1 deletion src/main/html/webapp/components/core/user/signup/signup.stache
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,36 @@
<div class="invalid-feedback"></div>
</div>

<p>Email Required: {{emailRequired}} </p>
{{#is(emailRequired, true)}}

<div class="form-group">
<label for="mail" class="control-label">E-Mail:</label>
<input id="mail" name="mail" type="text" class="form-control col-sm-3" autocomplete="off">
<div class="invalid-feedback"></div>
</div>

{{else}}
<hr>
<div class="form-group">
<input type="radio" id="anonymous1" name="anonymous" value="0" checked> <label for="anonymous1" class="control-label">E-Mail Address</label>
<div class="form-group" style="margin-left: 30px;">
<p>
{{userEmailDescription}}
</p>
<label for="mail" class="control-label">E-Mail:</label>
<input id="mail" name="mail" type="text" class="form-control col-sm-3" autocomplete="off">
<div class="invalid-feedback"></div>
</div>
<input type="radio" id="anonymous2" name="anonymous" value="1"> <label for="anonymous2" class="control-label">I don't want to provide my email address</label>
<div class="form-group" style="margin-left: 30px;">
<p>
{{userWithoutEmailDescription}}
</p>
</div>
</div>
<hr>
{{/is}}

<div class="form-group">
<label for="new-password" class="control-label">Password:</label>
<input id="new-password" name="new-password" type="password" class="form-control col-sm-3" autocomplete="off">
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cloudgene/mapred/api/v2/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public Representation getServer() {
data.put("foreground", getSettings().getColors().get("foreground"));
data.put("footer", getWebApp().getTemplate(Template.FOOTER));
data.put("emailRequired", getSettings().isEmailRequired());
data.put("userEmailDescription", getWebApp().getTemplate(Template.USER_EMAIL_DESCRIPTION));
data.put("userWithoutEmailDescription", getWebApp().getTemplate(Template.USER_WITHOUT_EMAIL_DESCRIPTION));
if (user != null) {
JSONObject userJson = new JSONObject();
userJson.put("username", user.getUsername());
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/cloudgene/mapred/util/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class Template {
public static final String FOOTER_SUBMIT_JOB = "FOOTER_SUBMIT_JOB";

public static final String TERMS = "TERMS";

public static final String USER_EMAIL_DESCRIPTION = "USER_EMAIL_DESCRIPTION";

public static final String USER_WITHOUT_EMAIL_DESCRIPTION = "USER_WITHOUT_EMAIL_DESCRIPTION";

public static final Template[] SNIPPETS = new Template[] {

Expand All @@ -39,7 +43,11 @@ public class Template {
new Template(FOOTER_SUBMIT_JOB, ""),

new Template(TERMS, "I will not attempt to re-identify or contact research participants.<br>" +
"I will report any inadvertent data release, security breach or other data management incident of which I become aware.")
"I will report any inadvertent data release, security breach or other data management incident of which I become aware."),

new Template(USER_EMAIL_DESCRIPTION, "Receive email notifications when jobs are completed."),

new Template(USER_WITHOUT_EMAIL_DESCRIPTION, "You can enter your email address at any time to upgrade your account.")

};

Expand Down

0 comments on commit 2c9f258

Please sign in to comment.