Skip to content

Only show / validate Terms fields on initial submission#753

Merged
carrythebanner merged 2 commits intoshift-org:mainfrom
carrythebanner:terms-validation
Dec 10, 2024
Merged

Only show / validate Terms fields on initial submission#753
carrythebanner merged 2 commits intoshift-org:mainfrom
carrythebanner:terms-validation

Conversation

@carrythebanner
Copy link
Copy Markdown
Collaborator

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 id is present, i.e. the event exists), the Terms section is hidden. The fields are still present under the hood as hidden inputs (similar to id and secret fields) so that backend validation can stay the same.

Also, the error messages for the two terms fields were swapped; fixed those as well.

// 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");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! 😅

[[/ id ]]

[[# id ]]
<input type="hidden" name="code_of_conduct" value="[[# codeOfConduct ]]1[[/ codeOfConduct ]]" />
Copy link
Copy Markdown
Contributor

@ionous ionous Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

v.requireTrue('code_of_conduct', "You must have read the Ride Leading Comic");

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");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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.

@ionous ionous mentioned this pull request Jun 25, 2024
@carrythebanner carrythebanner marked this pull request as ready for review November 5, 2024 02:22
@carrythebanner carrythebanner changed the title Only show Terms section on initial submission Only show / validate Terms fields on initial submission Nov 26, 2024
@carrythebanner carrythebanner merged commit 22df5b1 into shift-org:main Dec 10, 2024
@carrythebanner carrythebanner deleted the terms-validation branch December 10, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants