From 2e8e3f2fbc2c21186bf3b4a62cbe96819a7621d0 Mon Sep 17 00:00:00 2001
From: Phil Lee
Date: Mon, 17 Jun 2024 09:21:41 +0100
Subject: [PATCH 1/5] remove unused form method
---
app/helpers/govuk_form_helper.rb | 18 ------------------
spec/helpers/govuk_form_helper_spec.rb | 12 ------------
2 files changed, 30 deletions(-)
diff --git a/app/helpers/govuk_form_helper.rb b/app/helpers/govuk_form_helper.rb
index a12749498f..3aed7b4e28 100644
--- a/app/helpers/govuk_form_helper.rb
+++ b/app/helpers/govuk_form_helper.rb
@@ -83,24 +83,6 @@ def errors_tag(object, attribute)
content_tag(:span, messages.join(" ").html_safe, {class: "govuk-error-message", id: error_id(object.model_name.singular, attribute)})
end
- # Returns a string of the GOVUK css classes for the ++ html element along with any
- # existing css classes provided.
- #
- # When _object_ contains errors for _attribute_ the 'govuk-input--error' css class is added.
- #
- # === Example
- #
- # css_classes_for_select(object, :attribute, "another-css-class")
- #
- # "govuk-select another-css-class"
- #
- def css_classes_for_select(object, attribute, css_classes = "")
- css_classes = css_classes.split
- css_classes << "govuk-select"
- css_classes << "govuk-select--error" if object.errors.key?(attribute)
- css_classes.join(" ")
- end
-
# Returns a string of the GOVUK css classes for the + + html element along with any
# existing css classes provided.
#
diff --git a/spec/helpers/govuk_form_helper_spec.rb b/spec/helpers/govuk_form_helper_spec.rb
index 6f339a3257..5717613002 100644
--- a/spec/helpers/govuk_form_helper_spec.rb
+++ b/spec/helpers/govuk_form_helper_spec.rb
@@ -66,16 +66,4 @@
expect(helper.css_classes_for_input(claim, :attribute, "class-one class-two") {}).to eq("class-one class-two govuk-input")
end
end
-
- describe "#css_classes_for_select" do
- it "adds the correct css class" do
- expect(helper.css_classes_for_select(claim, :attribute) {}).to eq("govuk-select")
- end
-
- it "adds the error class when there are errors" do
- claim.errors.add(:attribute, "Test error")
-
- expect(helper.css_classes_for_select(claim, :attribute) {}).to eq("govuk-select govuk-select--error")
- end
- end
end
From 2752bf3c45c825b5519e5b11500d48c0fddf4b54 Mon Sep 17 00:00:00 2001
From: Phil Lee
Date: Mon, 17 Jun 2024 09:47:07 +0100
Subject: [PATCH 2/5] use govuk formbuilder for reminder form
- also removes multiple `h1`s on the page
---
.../reminders/personal_details.html.erb | 37 ++++++++++---------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/app/views/additional_payments/reminders/personal_details.html.erb b/app/views/additional_payments/reminders/personal_details.html.erb
index e024de195f..633b4c8876 100644
--- a/app/views/additional_payments/reminders/personal_details.html.erb
+++ b/app/views/additional_payments/reminders/personal_details.html.erb
@@ -2,43 +2,44 @@
- <%= render("shared/error_summary", instance: @form) if @form.errors.any? %>
+ <%= form_for @form, url: reminder_path(current_journey_routing_name), builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
+ <%= f.govuk_error_summary %>
- <%= form_for @form, url: reminder_path(current_journey_routing_name) do |f| %>
<%= t("questions.personal_details") %>
- <%= form_group_tag @form, :full_name do %>
-
- <%= f.label :full_name, t("additional_payments.reminders.full_name"), {class: "govuk-label govuk-label--l"} %>
-
- <%= errors_tag @form, :full_name %>
- <%= f.text_field :full_name, class: css_classes_for_input(@form, :full_name), type: "text", spellcheck: "false", autocomplete: "name" %>
- <% end %>
+ <%= f.govuk_text_field :full_name,
+ label: {
+ text: t("additional_payments.reminders.full_name"),
+ size: "l"
+ },
+ spellcheck: "false", autocomplete: "name" %>
- <%= form_group_tag @form, :email_address do %>
-
- <%= f.label :email_address, t("questions.email_address"), {class: "govuk-label govuk-label--l"} %>
-
-
+ <%= f.govuk_text_field :email_address,
+ label: {
+ text: t("questions.email_address"),
+ size: "l"
+ },
+ spellcheck: "false",
+ autocomplete: "email",
+ hint: -> do %>
Tell us the email you want us to send reminders to.
We recommend you use a non-work email address in case your circumstances change.
+
To verify your email address we will send you an email with a 6-digit passcode.
You can enter the passcode on the next screen.
-
- <%= errors_tag @form, :email_address %>
- <%= f.text_field :email_address, class: css_classes_for_input(@form, :email_address), type: "text", spellcheck: "false", autocomplete: "email" %>
<% end %>
Get help with access codes
+
If you have any issues with the passcode, email us at:
@@ -47,7 +48,7 @@
- <%= f.submit "Continue", class: "govuk-button", data: {module: "govuk-button"} %>
+ <%= f.govuk_submit "Continue" %>
<% end %>
From 8422749b22639a4efe24ac8a224d45bacb92ff29 Mon Sep 17 00:00:00 2001
From: Phil Lee
Date: Mon, 17 Jun 2024 09:55:38 +0100
Subject: [PATCH 3/5] refactor to use govuk details component
---
.../reminders/personal_details.html.erb | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/app/views/additional_payments/reminders/personal_details.html.erb b/app/views/additional_payments/reminders/personal_details.html.erb
index 633b4c8876..e55bbb5e12 100644
--- a/app/views/additional_payments/reminders/personal_details.html.erb
+++ b/app/views/additional_payments/reminders/personal_details.html.erb
@@ -35,18 +35,12 @@
<% end %>
-
-
- Get help with access codes
-
-
-
-
- If you have any issues with the passcode, email us at:
- <%= mail_to support_email_address, support_email_address, class: "govuk-link" -%>.
-
-
-
+ <%= govuk_details(summary_text: "Get help with access codes") do %>
+
+ If you have any issues with the passcode, email us at:
+ <%= govuk_mail_to support_email_address, support_email_address -%>.
+
+ <% end %>
<%= f.govuk_submit "Continue" %>
<% end %>
From 84e00f4352fe03b39f8fcf82b707c05db57c40e9 Mon Sep 17 00:00:00 2001
From: Phil Lee
Date: Mon, 17 Jun 2024 10:30:07 +0100
Subject: [PATCH 4/5] use govuk formbuilder for reminders OTP form
---
.../reminders/_one_time_password.html.erb | 42 +++++++++----------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/app/views/additional_payments/reminders/_one_time_password.html.erb b/app/views/additional_payments/reminders/_one_time_password.html.erb
index 4dfe9fbd26..46481dbf21 100644
--- a/app/views/additional_payments/reminders/_one_time_password.html.erb
+++ b/app/views/additional_payments/reminders/_one_time_password.html.erb
@@ -1,35 +1,35 @@
- <%= render("shared/error_summary", instance: @form) if @form.errors.any? %>
-
Email verification
- <%= form_for @form, url: reminder_path(current_journey_routing_name) do |f| %>
- <%= form_group_tag @form do %>
-
- <%= t("one_time_password.title") %>
-
+ <%= form_for @form, url: reminder_path(current_journey_routing_name), builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
+ <%= f.govuk_error_summary %>
-
- <%= t("one_time_password.hint1_html", email_or_mobile_message: "an email", email_or_mobile_value: @form.email_address) %>
-
- <%= t("one_time_password.validity_duration", duration_valid: one_time_password_validity_duration) %>
-
+ <%= f.govuk_text_field :one_time_password,
+ autocomplete: "off",
+ width: 5,
+ label: {
+ text: t("one_time_password.title"),
+ size: "l",
+ tag: "h1"
+ },
+ hint: -> do %>
+
+ <%= t("one_time_password.hint1_html", email_or_mobile_message: "an email", email_or_mobile_value: @form.email_address) %>
+
- <%= errors_tag @form, :one_time_password %>
- <%= f.text_field :one_time_password,
- autocomplete: "off",
- class: css_classes_for_input(@form, :one_time_password, 'govuk-input--width-5'),
- "aria-describedby" => "one-time-password-hint" %>
- <% end %>
+
+ <%= t("one_time_password.validity_duration", duration_valid: one_time_password_validity_duration) %>
+
+ <% end %>
- <%= link_to "Resend passcode (you will be sent back to the email address page)", new_reminder_path, class: "govuk-link govuk-link--no-visited-state" %>
+ <%= govuk_link_to "Resend passcode (you will be sent back to the email address page)", new_reminder_path, no_visited_state: true %>
- <%= f.submit "Confirm", class: "govuk-button" %>
- <%= link_to "Change email address", new_reminder_path, class: "govuk-button govuk-button--secondary", role: "button", data: {module: "govuk-button"} %>
+ <%= f.govuk_submit "Confirm" %>
+ <%= govuk_button_link_to "Change email address", new_reminder_path, secondary: true %>
<% end %>
From c8f76c3994c68d0e8953d6a0141ec86ad6f13349 Mon Sep 17 00:00:00 2001
From: Phil Lee
Date: Mon, 17 Jun 2024 10:37:11 +0100
Subject: [PATCH 5/5] fix tests
---
spec/features/reminders_spec.rb | 4 ++--
.../trainee_teacher_subjourney_for_lup_schools_spec.rb | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/spec/features/reminders_spec.rb b/spec/features/reminders_spec.rb
index e710f51169..28dba59c23 100644
--- a/spec/features/reminders_spec.rb
+++ b/spec/features/reminders_spec.rb
@@ -67,7 +67,7 @@
fill_in "Full name", with: "David Tau"
fill_in "Email address", with: "david.tau1988@hotmail.co.uk"
click_on "Continue"
- fill_in "form_one_time_password", with: get_otp_from_email
+ fill_in "form-one-time-password-field", with: get_otp_from_email
click_on "Confirm"
reminder = Reminder.order(:created_at).last
@@ -153,7 +153,7 @@
expect(page).to have_text("Personal details")
click_on "Continue"
- fill_in "form_one_time_password", with: get_otp_from_email
+ fill_in "form-one-time-password-field", with: get_otp_from_email
click_on "Confirm"
reminder = Reminder.order(:created_at).last
diff --git a/spec/features/trainee_teacher_subjourney_for_lup_schools_spec.rb b/spec/features/trainee_teacher_subjourney_for_lup_schools_spec.rb
index f3932610d8..420de6bdf9 100644
--- a/spec/features/trainee_teacher_subjourney_for_lup_schools_spec.rb
+++ b/spec/features/trainee_teacher_subjourney_for_lup_schools_spec.rb
@@ -41,7 +41,7 @@
fill_in "Full name", with: "David Tau"
fill_in "Email address", with: "david.tau1988@hotmail.co.uk"
click_on "Continue"
- fill_in "form_one_time_password", with: get_otp_from_email
+ fill_in "form-one-time-password-field", with: get_otp_from_email
click_on "Confirm"
reminder = Reminder.order(:created_at).last
@@ -76,7 +76,7 @@
fill_in "Full name", with: "David Tau"
fill_in "Email address", with: "david.tau1988@hotmail.co.uk"
click_on "Continue"
- fill_in "form_one_time_password", with: get_otp_from_email
+ fill_in "form-one-time-password-field", with: get_otp_from_email
click_on "Confirm"
reminder = Reminder.order(:created_at).last