Skip to content

Commit ec47bed

Browse files
authored
Merge pull request #3647 from nhsuk/edit-parents-more-fields
Allow editing parent contact details
2 parents f241b7b + 0043a9a commit ec47bed

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

app/controllers/parent_relationships_controller.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class ParentRelationshipsController < ApplicationController
66
before_action :set_parent
77

88
def edit
9+
@parent.contact_method_type = "any" if @parent.contact_method_type.nil?
910
end
1011

1112
def update
@@ -50,7 +51,17 @@ def parent_relationship_params
5051
parent_relationship: [
5152
:type,
5253
:other_name,
53-
{ parent_attributes: %i[id full_name email phone] }
54+
{
55+
parent_attributes: %i[
56+
id
57+
full_name
58+
email
59+
phone
60+
phone_receive_updates
61+
contact_method_other_details
62+
contact_method_type
63+
]
64+
}
5465
]
5566
)
5667
end

app/views/parent_relationships/edit.html.erb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@
2727
<%= f.fields_for :parent do |parent_f| %>
2828
<%= parent_f.govuk_text_field :email, label: { text: "Email address" } %>
2929
<%= parent_f.govuk_text_field :phone, label: { text: "Phone number" } %>
30+
31+
<%= parent_f.govuk_check_boxes_fieldset :phone_receive_updates, multiple: false, legend: nil do %>
32+
<%= parent_f.govuk_check_box :phone_receive_updates, 1, 0, multiple: false, link_errors: true, label: { text: "Get updates by text message" } %>
33+
<% end %>
34+
35+
<%= parent_f.govuk_radio_buttons_fieldset :contact_method_type,
36+
legend: { text: "Does the parent have any specific needs?", size: "s" } do %>
37+
<%= parent_f.govuk_radio_button :contact_method_type, "text",
38+
label: { text: "They can only receive text messages" },
39+
link_errors: true %>
40+
<%= parent_f.govuk_radio_button :contact_method_type, "voice",
41+
label: { text: "They can only receive voice calls" } %>
42+
<%= parent_f.govuk_radio_button :contact_method_type, "other",
43+
label: { text: "Other" } do %>
44+
<%= parent_f.govuk_text_area :contact_method_other_details,
45+
label: { text: "Give details" } %>
46+
<% end %>
47+
<%= parent_f.govuk_radio_divider %>
48+
<%= parent_f.govuk_radio_button :contact_method_type, "any",
49+
label: { text: "They do not have specific needs" } %>
50+
<% end %>
3051
<% end %>
3152

3253
<%= f.govuk_submit "Continue" %>

config/locales/en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ en:
357357
contact_method_type:
358358
inclusion: Choose a contact method
359359
contact_method_other_details:
360-
blank: Enter details about how to contact you
360+
blank: Enter details about how to contact the parent
361361
too_long: Enter details that are less than 300 characters long
362362
email:
363363
blank: Enter an email address

spec/features/edit_parent_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def then_i_see_the_new_relationship_of_the_parent_of_mother
8686
end
8787

8888
def and_i_change_the_relationship_of_the_parent_to_other
89-
choose "Other"
89+
choose "Other", match: :first
9090
fill_in "Relationship to the child", with: "Someone"
9191
click_on "Continue"
9292
end
@@ -98,11 +98,18 @@ def then_i_see_the_new_relationship_of_the_parent_of_other
9898
def when_i_change_the_contact_details_of_the_parent
9999
fill_in "Email address", with: "selina@meyer.com"
100100
fill_in "Phone number", with: "07700 900 000"
101+
check "Get updates by text message"
102+
choose "They can only receive text messages"
101103
click_on "Continue"
102104
end
103105

104106
def then_i_see_the_new_contact_details_of_the_parent
105107
expect(page).to have_content("selina@meyer.com")
106108
expect(page).to have_content("07700 900000")
109+
110+
# Communication preferences aren't shown in the UI
111+
parent = Parent.last
112+
expect(parent.phone_receive_updates).to be(true)
113+
expect(parent.contact_method_type).to eq("text")
107114
end
108115
end

0 commit comments

Comments
 (0)