Implement describing none of the above for radio and checkbox selection questions#1799
Conversation
If users will be asked to provide another answer if 'None of the above' is selected, we need to know whether an autocomplete will be shown to determine whether the question is on the same page in a conditional reveal or on a new page. Add this method to re-use this code.
Add a method to the selection question model to determine if there is an additional question that should be shown to the user when they select 'None of the above'. Use `Struct` rather than `OpenStruct` in the tests to better mock out ActiveResouce::Base which throws a NoMethodError if we try to access an attribute that doesn't exist. Co-authored-by: Samuel Culley <samuel.culley@digital.cabinet-office.gov.uk>
If a none_of_the_above_question is defined in the answer_settings for the question, render a field in a conditional reveal if the "None of the above" option is selected for a radios or checkboxes selection question. We will handle the case when an autocomplete component is rendered when there are more than 30 options in a subsequent commit. Co-authored-by: Samuel Culley <samuel.culley@digital.cabinet-office.gov.uk>
818157a to
fc4cd55
Compare
Add validation for the none of the above question when it is displayed for checkboxes or radios. When an autocomplete component is displayed, the field will be on a separate page - validation for this will be handled in a subsequent commit. The error messages are the same as those for a text answer, so the Welsh translations are directly copied from those error messages.
Add a before_validation callback to clear the `none_of_the_above_answer` for a selection question if 'None of the above' is not the selected option. This is because we don't want to include it in the saved answer in this case. This also means that we no longer need to check the selected option when applying length validation for `none_of_the_above_answer`.
fc4cd55 to
303d98d
Compare
Enable the describe_none_of_the_above_enabled feature flag for the forms-admin review app.
We've defined the answer_settings in the factory to use Struct rather than OpenStruct for the answer_settings to better mock the behaviour of ActiveResouce::Base which raises a NoMethodError when trying to access attributes that don't exist. Use the factory so we don't need to define this behaviour in multiple places.
809a35e to
a3df05f
Compare
|
|
🎉 A review copy of this PR has been deployed! It is made of up two components Important Not all of the functionality of forms-runner is present in review apps. You should use the full dev environment to test the functionality which is disabled here. It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready For the sign in details and more information, see the review apps wiki page. |



What problem does this pull request solve?
Trello card: https://trello.com/c/bfFa7B13
Implement the forms-runner changes to add in a field in a conditional reveal for selection questions for the additional 'None of the above' question when one is configured.
Validation has been added that an answer is provided when the question is mandatory and 'None of the above' is selected, and that the answer is not longer than 499 characters.
This PR does not yet handle adding in the additional page for the None of the above question when an autocomplete component is shown when the selection question has more than 30 options.
This also doesn't handle displaying the answer on the 'Check your answers' page or including it in submissions.
Things to consider when reviewing