Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/models/calEventValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ function makeValidator(input, errors) {
return validator.toBoolean(str) ? 1 : 0;
}
},
// requires a 0, 1, true, or false value; empty is an error
requiredFlag(field, msg) {
const str = getString(field);
if (validator.isEmpty(str)) {
errors.addError(field, msg);
} else if (!validator.isBoolean(str)) {
errors.addError(field);
} else {
return validator.toBoolean(str) ? 1 : 0;
}
},
// if not specified, returns 0
// otherwise expects an int-like value
// greater than or equal to 0
Expand Down Expand Up @@ -215,7 +226,7 @@ function validateEvent(input) {
address: v.requireString('address', 'Address missing'),
name: v.requireString('organizer', 'Organizer missing'),
email: v.requireEmail('email'),
hideemail: v.optionalFlag('hideemail'),
hideemail: v.requiredFlag('hideemail', 'Please select whether or not to publish your email address'),
phone: v.nullString('phone'),
hidephone: v.optionalFlag('hidephone'),
contact: v.nullString('contact'),
Expand Down
16 changes: 10 additions & 6 deletions site/themes/s2b_hugo_theme/layouts/partials/cal/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,17 @@ <h2>
<input type="text" class="form-control" name="email" id="email" value="[[email]]" autocomplete="email" aria-describedby="email-help email-suggestion" required="true" aria-invalid="false" />
<p class="input-help" id="email-help">This must be a valid email address where we can reach you. A confirmation message will be mailed to this address.</p>
<div id="email-suggestion" aria-live="polite"></div>
</div>

<div>
<label class="control-label" for="hideemail">
<input type="checkbox" name="hideemail" id="hideemail" value="1" [[^ id ]]checked[[/ id ]] [[# hideemail ]]checked[[/ hideemail ]] />
Don't publish my email address online
</label>
</div>
<div class="form-group">
<label class="control-label req-label" for="hideemail">Publish email address online?</label>
<select class="form-control" name="hideemail" id="hideemail" required="true" aria-invalid="false" aria-describedby="hideemail-help hideemail-suggestion">
<option value="">Select one</option>
<option value="1" [[# hideemail ]]selected[[/ hideemail ]]>🚫 Don't publish my email address online</option>
<option value="0" [[# id ]][[^ hideemail ]]selected[[/ hideemail ]][[/ id ]]>✅ Do publish my email address online</option>
</select>
<p class="input-help" id="hideemail-help">This option chooses whether or not to publish your email address on the calendar.</p>
<div id="hideemail-suggestion" aria-live="polite"></div>
</div>

<div>Website for additional details</div>
Expand Down