Only show / validate Terms fields on initial submission#753
Only show / validate Terms fields on initial submission#753carrythebanner merged 2 commits intoshift-org:mainfrom
Conversation
app/models/calEventValidator.js
Outdated
| // these don't get stored; but are still required | ||
| v.requireTrue('code_of_conduct', "You must have read the Ride Leading Comic"); | ||
| v.requireTrue('read_comic', "You must agree to the Code of Conduct"); | ||
| v.requireTrue('code_of_conduct', "You must agree to the Code of Conduct"); |
| [[/ id ]] | ||
|
|
||
| [[# id ]] | ||
| <input type="hidden" name="code_of_conduct" value="[[# codeOfConduct ]]1[[/ codeOfConduct ]]" /> |
There was a problem hiding this comment.
this looks good, but maybe it'd be worth it to instead change the server to only validate the two checkboxes for new events?
having special case code on the client to send up a 1 value, for the validator to check and discard feels a bit like working around the issue of the overzealous validator
for example:
shift-docs/app/models/calEventValidator.js
Line 185 in 5c0326f
if (!input.id) {
v.requireTrue('code_of_conduct', "You must have read the Ride Leading Comic");
v.requireTrue('read_comic', "You must agree to the Code of Conduct");
}
There was a problem hiding this comment.
@carrythebanner -- don't worry about this comment being a blocker or anything.
not showing those checkboxes seems like a nice improvement.
we could worry about improving the roundtrip of those flags as part of some other more general issue about reducing the number of fields.
There was a problem hiding this comment.
(Finally coming back to this) Good call, I incorporated that change into the backend. The frontend still hides the terms section when it's not needed, but those hidden inputs are no longer present.
When you create an event listing, the organizer must agree to the code of conduct and affirm that they've read the ride leader comic. On subsequent requests those terms checkboxes are still shown on the front end, but an organizer can't un-read the comic or revoke their acceptance of the terms.
This changes the add/edit form to only show the Terms section for initial submission. After that (if an
idis present, i.e. the event exists), the Terms section is hidden. The fields are still present under the hood as hidden inputs (similar toidandsecretfields) so that backend validation can stay the same.Also, the error messages for the two terms fields were swapped; fixed those as well.