diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb
index bb132ee7a..6c8bd145e 100644
--- a/app/controllers/schemes_controller.rb
+++ b/app/controllers/schemes_controller.rb
@@ -82,6 +82,10 @@ class SchemesController < ApplicationController
render "schemes/support"
end
+ def details
+ render "schemes/details"
+ end
+
def check_answers
render "schemes/check_answers"
end
@@ -89,7 +93,9 @@ class SchemesController < ApplicationController
private
def scheme_params
- params.require(:scheme).permit(:service_name, :sensitive, :organisation_id, :scheme_type, :registered_under_care_act, :total_units, :id, :confirmed, :has_other_client_group, :primary_client_group, :secondary_client_group)
+ required_params = params.require(:scheme).permit(:service_name, :sensitive, :organisation_id, :scheme_type, :registered_under_care_act, :total_units, :id, :confirmed, :has_other_client_group, :primary_client_group, :secondary_client_group, :support_type, :intended_stay)
+ required_params[:sensitive] = required_params[:sensitive].to_i if required_params[:sensitive]
+ required_params
end
def search_term
diff --git a/app/models/scheme.rb b/app/models/scheme.rb
index e2500bbe9..587698d3a 100644
--- a/app/models/scheme.rb
+++ b/app/models/scheme.rb
@@ -38,7 +38,7 @@ class Scheme < ApplicationRecord
SUPPORT_TYPE = {
"Missing": 0,
- "Resettlement Support": 1,
+ "Resettlement support": 1,
"Low levels of support": 2,
"Medium levels of support": 3,
"High levels of care and support": 4,
diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb
index 99e1a8637..a612c5826 100644
--- a/app/views/schemes/check_answers.html.erb
+++ b/app/views/schemes/check_answers.html.erb
@@ -19,7 +19,7 @@
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
- href: schemes_path(scheme_id: @scheme.id, check_answers: true),
+ href: scheme_details_path(scheme_id: @scheme.id, check_answers: true)
) %>
<% end %>
<% end %>
diff --git a/app/views/schemes/details.html.erb b/app/views/schemes/details.html.erb
new file mode 100644
index 000000000..c19015caa
--- /dev/null
+++ b/app/views/schemes/details.html.erb
@@ -0,0 +1,73 @@
+<% content_for :title, "Create a new supported housing scheme" %>
+
+ <% content_for :before_content do %>
+ <%= govuk_back_link(
+ text: "Back",
+ href: :back,
+ ) %>
+ <% end %>
+
+ <%= render partial: "organisations/headings", locals: { main: "Create a new supported housing scheme", sub: nil } %>
+
+ <%= form_for(@scheme, method: :patch) do |f| %>
+
+
+ <%= f.govuk_error_summary %>
+
+ <%= f.govuk_text_field :service_name,
+ label: { text: "Scheme name", size: "m" },
+ hint: { text: "This is how you’ll refer to this supported housing scheme within your organisation. For example, the name could relate to the address or location. You’ll be able to see the client group when selecting it." } %>
+
+ <%= f.govuk_check_box :sensitive,
+ 1,
+ 0,
+ checked: @scheme.sensitive?,
+ multiple: false,
+ label: { text: "This scheme contains confidential information" } %>
+
+ <% if current_user.support? %>
+ <% answer_options = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %>
+
+ <%= f.govuk_collection_select :organisation_id,
+ answer_options,
+ :id,
+ :name,
+ label: { text: "Which organisation manages this scheme", size: "m" },
+ hint: { text: "Enter organisation name" },
+ options: { required: true },
+ "data-controller": %w[accessible-autocomplete conditional-filter] %>
+ <% end %>
+
+ <% if current_user.data_coordinator? %>
+ <%= f.hidden_field :organisation_id, value: current_user.organisation.id %>
+ <% end %>
+
+ <% scheme_types_selection = Scheme.scheme_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
+
+ <%= f.govuk_collection_radio_buttons :scheme_type,
+ scheme_types_selection,
+ :id,
+ :name,
+ legend: { text: "What is this type of scheme?", size: "m" } %>
+
+ <% care_acts_selection = Scheme.registered_under_care_acts.keys.reverse.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
+
+ <%= f.govuk_collection_radio_buttons :registered_under_care_act,
+ care_acts_selection,
+ :id,
+ :name,
+ legend: { text: "Is this scheme registered under the Care Standards Act 2000?", size: "m" } %>
+
+ <%= f.govuk_number_field :total_units,
+ width: 2,
+ label: { text: "Total number of units", size: "m" },
+ hint: { text: "For example, a unit can be a bedroom in a shared house or flat, or a house with 4 bedrooms. Do not include bedrooms used for wardens, managers, volunteers or sleep-in staff." } %>
+
+ <%= f.hidden_field :page, value: "details" %>
+ <% if request.query_parameters["check_answers"] == "true" %>
+ <%= f.hidden_field :check_answers, value: "true" %>
+ <% end %>
+ <%= f.govuk_submit "Save and continue" %>
+
+
+ <% end %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 0af30910b..0cbaa82c2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -40,6 +40,7 @@ Rails.application.routes.draw do
get "confirm-secondary-client-group", to: "schemes#confirm_secondary_client_group"
get "secondary-client-group", to: "schemes#secondary_client_group"
get "support", to: "schemes#support"
+ get "details", to: "schemes#details"
get "check-answers", to: "schemes#check_answers"
member do
diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb
index ffbe8ecd0..d0f4a4423 100644
--- a/spec/features/schemes_spec.rb
+++ b/spec/features/schemes_spec.rb
@@ -307,6 +307,17 @@ RSpec.describe "Schemes scheme Features" do
end
it "allows changing details questions" do
+ click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
+ expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
+
+ fill_in "Scheme name", with: "Example"
+ choose "Direct access hostel"
+ choose "Yes – registered care home providing nursing care"
+ click_button "Save and continue"
+
+ expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
+ expect(page).to have_content "Example"
+ expect(page).to have_content "Yes – registered care home providing nursing care"
end
it "allows changing primary-client-group question" do
@@ -357,6 +368,19 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "None"
end
+
+ it "allows changing support question to no" do
+ click_link("Change", href: "/schemes/#{scheme.id}/support?check_answers=true", match: :first)
+ expect(page).to have_current_path("/schemes/#{scheme.id}/support?check_answers=true")
+
+ choose "Resettlement support"
+ choose "Medium stay"
+ click_button "Save and continue"
+
+ expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
+ expect(page).to have_content "Resettlement support"
+ expect(page).to have_content "Medium stay"
+ end
end
end
end