Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Server-Side Price Filtering
This commit modifies the `seats#index` HTML to take the `?maximum` query parameter into account when deciding which `Seat` records are emphasized or de-emphasized based on their section's price. First, extend the price filtering `<form>` element to declare the [`action` attribute] to the current page, and the [`method` attribute to `GET`][get]. To declare these methods, and to integrate with Rails' CSRF protection, declare the `<form>` using the [`form_with` helper][form_with]. Unfortunately, Turbolinks does not support `<form>` submission redirects for `GET` requests: > The Turbolinks Rails engine performs this optimization automatically > for non-GET XHR requests that redirect with the `redirect_to` helper. To counteract that constraint, this commit passes the `local: true` option to the `form_with` call, [opting-out of remote form submission through unobtrusive JavaScript][local] and (transitively) Turbolinks. Next, determine which `<input type="radio">` element to denote as [`checked`][checked] based on whether or not its `value` attribute matches the value of the `maximum` query parameter. If no query parameter is provided, ensure that the last `<input type="radio">` element is `checked`. Render the `Section` records as a [`<g>`][g] element to group them together. When rendering the `<g>` element, declare its [`opacity`][opacity] based on whether its `price` is within the bounds of the price filter. Additionally, set [`aria-hidden="true"`][aria-hidden] for `<g>` elements that do not match the filter criteria, so that we can exclude them from the accessibility tree. [action]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#Attributes [get]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET [form_with]: https://api.rubyonrails.org/v5.2/classes/ActionView/Helpers/FormHelper.html#method-i-form_with [checked]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/radio#checked [turbolinks-get]: https://github.com/turbolinks/turbolinks/tree/v5.2.0#redirecting-after-a-form-submission [local]: https://api.rubyonrails.org/v5.2/classes/ActionView/Helpers/FormHelper.html#method-i-form_with-label-form_with+options [g]: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/g [opacity]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/opacity [aria-hidden]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#States_and_properties
- Loading branch information