|
41 | 41 | #if(user == nil) { |
42 | 42 | <p>If you don't specify a password, then the user will receive an email with instructions on how to set one. If you specify a password, then no email will be sent to the new user.</p> |
43 | 43 |
|
44 | | - <div class="form-group form-check"> |
45 | | - <input type="checkbox" class="form-check-input" id="shouldSpecifyPassword" name="shouldSpecifyPassword" aria-describedby="shouldSpecifyPasswordHelp" value="1"> |
46 | | - <label class="form-check-label" for="shouldSpecifyPassword">Specify password</label> |
47 | | - <small id="shouldSpecifyPasswordHelp" class="form-text text-muted">Leave this out and the user will have to specify one themselves.</small> |
| 44 | + #submissions:checkbox("shouldSpecifyPassword", "Specify password", "Leave this out and the user will have to specify one themselves.") |
| 45 | + |
| 46 | + <div id="specifyPassword" style="display:none;"> |
| 47 | + #submissions:password("password", "Enter password", "Minimum 8 characters and needs to satisfy three of the following: has a lowercase character, has an uppercase character, has a digit or has a special character.") |
| 48 | + #submissions:password("passwordAgain", "Enter password again") |
48 | 49 | </div> |
49 | | - } |
50 | 50 |
|
51 | | - <div id="specifyPassword" style="#if(user == nil) { display:none; }"> |
| 51 | + #submissions:checkbox("shouldResetPassword", "Should reset password", "This will require the user to set a new password after logging in the first time.") |
| 52 | + } else { |
52 | 53 | #submissions:password("password", "Enter password", "Minimum 8 characters.") |
53 | 54 | #submissions:password("passwordAgain", "Enter password again") |
54 | | - |
55 | | - #if(user == nil) { |
56 | | - <div class="form-group form-check"> |
57 | | - <input type="checkbox" class="form-check-input" id="shouldResetPassword" name="shouldResetPassword" aria-describedby="shouldResetPasswordHelp" value="1"> |
58 | | - <label class="form-check-label" for="shouldResetPassword">Should reset password</label> |
59 | | - <small id="shouldResetPasswordHelp" class="form-text text-muted">This will require the user to set a new password after logging in the first time.</small> |
60 | | - </div> |
61 | | - } |
62 | | - </div> |
| 55 | + } |
63 | 56 |
|
64 | 57 | <button type="submit" class="btn btn-primary">Submit</button> |
65 | 58 | <a href="/admin/users" class="btn btn-secondary">Cancel</a> |
|
85 | 78 |
|
86 | 79 | // Password toggle |
87 | 80 | $(function () { |
88 | | - $("#shouldSpecifyPassword").click(function(){ |
| 81 | + $("#specifyPassword").toggle($("#shouldSpecifyPassword").prop("checked")); |
| 82 | + $("#shouldSpecifyPassword").click(function() { |
| 83 | + if (!this.checked) { |
| 84 | + $("#password").val(""); |
| 85 | + $("#passwordAgain").val(""); |
| 86 | + \} |
| 87 | + |
| 88 | + $("#password").prop('required', (this.checked)) |
| 89 | + $("#passwordAgain").prop('required', (this.checked)) |
| 90 | + |
89 | 91 | $("#specifyPassword").toggle(); |
90 | 92 | \}); |
91 | | - |
92 | 93 | \}); |
93 | 94 | </script> |
94 | 95 | } |
|
0 commit comments