-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make smart answers optional https://eaflood.atlassian.net/browse/WC-275 In order to reduce the number of pages users have to go through, and to give more choice for those who have good knowledge of what the difference is between lower and upper tier, we will make smart answers optional. We have already tested this in user research without issue, and the team feels it better highlights that smart answers is an aid and not an approval or clarification of what users can do (which testing has shown some view it as). This story covers implementing the version contained in the prototype into the production renewals service. * Scaffold the new tier_check_form * Set up and persist the tier check form Add text and form fields, and store the user's answer so we can prefill the form if they return to it. The tier check form uses a new temporary attribute called temp_tier_check for the answer - this will be used for routing into or around smart answers in the future. Adding that routing is the next step. Also update the .gitignore to get rid of pesky .DS_Store files. * Add missing error message * Route around smart answers based on tier check answer If a user asks to skip smart answers, route them straight to the CBD type page instead. If a user tries to go back from the CBD page, cehck if they have skipped smart answers and send them straight back to the tier check page if so. Otherwise, send them back through the smart answers route they came from, just as we did before.
- Loading branch information
1 parent
b4adf6a
commit b80732e
Showing
21 changed files
with
559 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class TierCheckFormsController < FormsController | ||
def new | ||
super(TierCheckForm, "tier_check_form") | ||
end | ||
|
||
def create | ||
super(TierCheckForm, "tier_check_form") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class TierCheckForm < BaseForm | ||
attr_accessor :temp_tier_check | ||
|
||
def initialize(transient_registration) | ||
super | ||
self.temp_tier_check = @transient_registration.temp_tier_check | ||
end | ||
|
||
def submit(params) | ||
# Assign the params for validation and pass them to the BaseForm method for updating | ||
self.temp_tier_check = convert_to_boolean(params[:temp_tier_check]) | ||
attributes = { temp_tier_check: temp_tier_check } | ||
|
||
super(attributes, params[:reg_identifier]) | ||
end | ||
|
||
validates :temp_tier_check, inclusion: { in: [true, false] } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<%= render("shared/back", back_path: back_tier_check_forms_path(@tier_check_form.reg_identifier)) %> | ||
|
||
<div class="text"> | ||
<%= form_for(@tier_check_form) do |f| %> | ||
<%= render("shared/errors", object: @tier_check_form) %> | ||
|
||
<h1 class="heading-large"><%= t(".heading") %></h1> | ||
|
||
<p><%= t(".paragraph_1") %></p> | ||
<p><%= t(".paragraph_2") %></p> | ||
<p><%= t(".paragraph_3") %></p> | ||
|
||
<div class="form-group"> | ||
<details> | ||
<summary> | ||
<span class="summary"><%= t(".tier_details_subheading") %></span> | ||
</summary> | ||
<div class="panel panel-border-narrow"> | ||
<p><%= t(".tier_details_paragraph_1") %></p> | ||
<p class="strong"><%= t(".tier_details_paragraph_2") %></p> | ||
<ul class="list list-bullet"> | ||
<% t(".tier_details_list_1").each do |item| %> | ||
<li><%= item[:item] %></li> | ||
<% end %> | ||
</ul> | ||
<p class="strong"><%= t(".tier_details_paragraph_3") %></p> | ||
<ul class="list list-bullet"> | ||
<% t(".tier_details_list_2").each do |item| %> | ||
<li><%= item[:item] %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</details> | ||
</div> | ||
|
||
<% if @tier_check_form.errors[:temp_tier_check].any? %> | ||
<div class="form-group form-group-error"> | ||
<% else %> | ||
<div class="form-group"> | ||
<% end %> | ||
<fieldset id="temp_tier_check"> | ||
<legend class="visuallyhidden"> | ||
<%= t(".heading") %> | ||
</legend> | ||
|
||
<% if @tier_check_form.errors[:temp_tier_check].any? %> | ||
<span class="error-message"><%= @tier_check_form.errors[:temp_tier_check].join(", ") %></span> | ||
<% end %> | ||
|
||
<div class="multiple-choice"> | ||
<%= f.radio_button :temp_tier_check, "true" %> | ||
<%= f.label :temp_tier_check, t(".options.true"), value: "true" %> | ||
</div> | ||
<div class="multiple-choice"> | ||
<%= f.radio_button :temp_tier_check, "false" %> | ||
<%= f.label :temp_tier_check, t(".options.false"), value: "false" %> | ||
</div> | ||
</fieldset> | ||
</div> | ||
|
||
<%= f.hidden_field :reg_identifier, value: @tier_check_form.reg_identifier %> | ||
<div class="form-group"> | ||
<%= f.submit t(".next_button"), class: "button" %> | ||
</div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
en: | ||
tier_check_forms: | ||
new: | ||
title: Check your tier | ||
heading: You are renewing an upper tier registration | ||
paragraph_1: "If you're not sure if you should be upper or lower tier, you can answer a few questions about your business's activities to check." | ||
paragraph_2: The questions only relate to your business activities and what type of waste you currently deal with. | ||
paragraph_3: "Upper tier registrations need to be renewed every 3 years for a cost. Lower tier registrations are free and don’t expire." | ||
tier_details_subheading: "What’s the difference between upper and lower tier?" | ||
tier_details_paragraph_1: This depends on what waste you deal with and who creates it. | ||
tier_details_paragraph_2: "You need an upper tier registration if you do any of the following:" | ||
tier_details_list_1: | ||
- item: transport other people's waste (for example, a skip company) | ||
- item: carry construction or demolition waste | ||
- item: buy and/or sell waste or arrange for others to carry it | ||
tier_details_paragraph_3: "If your activities are limited to the categories below, you only need a lower tier registration:" | ||
tier_details_list_2: | ||
- item: "You ONLY deal with waste you produce in the course of carrying out your business – for example, a hairdresser dealing with hair clippings. This does not include construction or demolition waste" | ||
- item: "You ONLY deal with waste from mines or quarries, from agricultural premises, or animal by-products" | ||
options: | ||
"true": I want to check if my tier is correct before renewing | ||
"false": I am happy to skip this check | ||
error_heading: Something is wrong | ||
next_button: Continue | ||
activemodel: | ||
errors: | ||
models: | ||
tier_check_form: | ||
attributes: | ||
temp_tier_check: | ||
inclusion: "You must answer this question" | ||
reg_identifier: | ||
invalid_format: "The registration ID is not in a valid format" | ||
no_registration: "There is no registration matching this ID" | ||
renewal_in_progress: "This renewal is already in progress" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FactoryBot.define do | ||
factory :tier_check_form do | ||
trait :has_required_data do | ||
temp_tier_check false | ||
|
||
initialize_with { new(create(:transient_registration, :has_required_data, workflow_state: "tier_check_form")) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.