diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 39e4bdcc4..ac77018d4 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -69,10 +69,16 @@ class SchemesController < ApplicationController render "schemes/support" end + def details + @scheme = Scheme.find_by(id: params[:scheme_id]) + render "schemes/details" + end + def check_answers @scheme = Scheme.find_by(id: params[:scheme_id]) if params[:scheme] - required_params = params.require(:scheme).permit(:intended_stay, :support_type) + required_params = params.require(:scheme).permit(:intended_stay, :support_type, :service_name, :sensitive, :organisation_id, :scheme_type, :registered_under_care_act, :total_units, :id, :confirmed) + required_params[:sensitive] = required_params[:sensitive].to_i if required_params[:sensitive] @scheme.update(required_params) end render "schemes/check_answers" diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb index a56ee00b7..d2254147b 100644 --- a/app/views/schemes/check_answers.html.erb +++ b/app/views/schemes/check_answers.html.erb @@ -7,6 +7,8 @@ ) %> <% end %> +<%= render partial: "organisations/headings", locals: { main: "Check your changes before updating this scheme", sub: @scheme.service_name } %> + <%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %> <% component.tab(label: 'Scheme') do %> <%= govuk_summary_list do |summary_list| %> diff --git a/app/views/schemes/confirm_secondary.html.erb b/app/views/schemes/confirm_secondary.html.erb index 6972df35d..382d33094 100644 --- a/app/views/schemes/confirm_secondary.html.erb +++ b/app/views/schemes/confirm_secondary.html.erb @@ -1,26 +1,25 @@ +<% content_for :title, "What client group is this scheme intended for?" %> + <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: "/schemes/#{@scheme.id}/primary", + href: "/schemes/#{@scheme.id}/primary-client-group", ) %> <% end %> <%= render partial: "organisations/headings", locals: { main: "Does this scheme provide for another client group?", sub: @scheme.service_name } %> -<%= form_for(:confirmed, method: :patch, url: scheme_secondary_path(scheme_id: @scheme.id)) do |f| %> +<%= form_for(:confirmed, method: :patch, url: scheme_secondary_client_group_path(scheme_id: @scheme.id)) do |f| %>
-

- <%= content_for(:title) %> -

- <% selection = ["Yes", "No"].map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <%= f.govuk_collection_radio_buttons :selection, selection, :id, :name, + { checked: "Yes" }, legend: nil %> diff --git a/app/views/schemes/details.html.erb b/app/views/schemes/details.html.erb index 36c365167..3dd5d3489 100644 --- a/app/views/schemes/details.html.erb +++ b/app/views/schemes/details.html.erb @@ -1,28 +1,27 @@ -<% content_for :title, "Create a new supported housing scheme" %> +<% content_for :title, "Scheme details" %> <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: 'javascript:history.go(-1);', + href: "/schemes/#{@scheme.id}/secondary", ) %> <% end %> -<%= form_for(@scheme, method: :patch, url: scheme_details_path(scheme_id: @scheme.id)) do |f| %> +<%= render partial: "organisations/headings", locals: { main: "Scheme details", sub: @scheme.service_name } %> + +<%= form_for(@scheme, method: :patch, url: scheme_check_answers_path(scheme_id: @scheme.id)) do |f| %>
<%= f.govuk_error_summary %> -

- <%= content_for(:title) %> -

- <%= 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, - 0, + <%= f.govuk_check_box :sensitive, 1, + 0, + checked: @scheme.sensitive?, multiple: false, label: { text: "This scheme contains confidential information" } %> @@ -41,7 +40,8 @@ :name, label: { text: "Which organisation manages this scheme", size: "m" }, hint: { text: "Enter organisation name" }, - options: { disabled: [""], selected: selected_option(answer_options) }, + selected: selected_option(@scheme.organisation.id), + options: { disabled: [""], selected: selected_option(@scheme.organisation.name) }, "data-controller": %w[accessible-autocomplete conditional-filter] %> <% end %> diff --git a/app/views/schemes/new.html.erb b/app/views/schemes/new.html.erb index 9658a8511..31780d8a2 100644 --- a/app/views/schemes/new.html.erb +++ b/app/views/schemes/new.html.erb @@ -3,7 +3,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: :back, + href: 'javascript:history.go(-1);', ) %> <% end %> @@ -20,9 +20,9 @@ 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, - 0, + <%= f.govuk_check_box :sensitive, 1, + 0, multiple: false, label: { text: "This scheme contains confidential information" } %> diff --git a/app/views/schemes/primary_client_group.html.erb b/app/views/schemes/primary_client_group.html.erb index fb1322e65..b634dc5ad 100644 --- a/app/views/schemes/primary_client_group.html.erb +++ b/app/views/schemes/primary_client_group.html.erb @@ -1,3 +1,5 @@ +<% content_for :title, "What client group is this scheme intended for?" %> + <% content_for :before_content do %> <%= govuk_back_link( text: "Back", @@ -7,15 +9,11 @@ <%= render partial: "organisations/headings", locals: { main: "What client group is this scheme intended for?", sub: @scheme.service_name } %> -<%= form_for(@scheme, method: :patch, url: scheme_confirm_secondary_path(scheme_id: @scheme.id)) do |f| %> +<%= form_for(@scheme, method: :patch, url: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id)) do |f| %>
<%= f.govuk_error_summary %> -

- <%= content_for(:title) %> -

- diff --git a/app/views/schemes/secondary_client_group.html.erb b/app/views/schemes/secondary_client_group.html.erb index 01432dc20..f57a8dde6 100644 --- a/app/views/schemes/secondary_client_group.html.erb +++ b/app/views/schemes/secondary_client_group.html.erb @@ -1,7 +1,9 @@ +<% content_for :title, "What is the other client group?" %> + <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: "/schemes/#{@scheme.id}/confirm_secondary", + href: "/schemes/#{@scheme.id}/confirm-secondary-client-group", ) %> <% end %> @@ -12,10 +14,6 @@
<%= f.govuk_error_summary %> -

- <%= content_for(:title) %> -

- diff --git a/app/views/schemes/support.html.erb b/app/views/schemes/support.html.erb index 82578dbf3..24900a5fc 100644 --- a/app/views/schemes/support.html.erb +++ b/app/views/schemes/support.html.erb @@ -1,21 +1,19 @@ +<% content_for :title, "What support does this scheme provide?" %> + <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: "/schemes/#{@scheme.id}/secondary", + href: "/schemes/#{@scheme.id}/secondary-client-group", ) %> <% end %> <%= render partial: "organisations/headings", locals: { main: "What support does this scheme provide?", sub: @scheme.service_name } %> -<%= form_for(@scheme, method: :patch, url: scheme_check_answers_path(scheme_id: @scheme.id)) do |f| %> +<%= form_for(@scheme, method: :patch, url: scheme_check_your_answers_path(scheme_id: @scheme.id)) do |f| %>
<%= f.govuk_error_summary %> -

- <%= content_for(:title) %> -

- diff --git a/config/routes.rb b/config/routes.rb index d1ed89353..d73a44291 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,17 +36,17 @@ Rails.application.routes.draw do end resources :schemes do - patch "primary", to: "schemes#primary_client_group" - get "primary", to: "schemes#primary_client_group" - patch "secondary", to: "schemes#secondary_client_group" - get "secondary", to: "schemes#secondary_client_group" + patch "primary-client-group", to: "schemes#primary_client_group" + get "primary-client-group", to: "schemes#primary_client_group" + patch "secondary-client-group", to: "schemes#secondary_client_group" + get "secondary-client-group", to: "schemes#secondary_client_group" patch "support", to: "schemes#support" get "support", to: "schemes#support" get "update", to: "schemes#update" - patch "check_answers", to: "schemes#check_answers" - get "check_answers", to: "schemes#check_answers" - patch "confirm_secondary", to: "schemes#confirm_secondary_group" - get "confirm_secondary", to: "schemes#confirm_secondary_group" + patch "check-your-answers", to: "schemes#check_answers" + get "check-your-answers", to: "schemes#check_answers" + patch "confirm-secondary-client-group", to: "schemes#confirm_secondary_group" + get "confirm-secondary-client-group", to: "schemes#confirm_secondary_group" member do get "locations", to: "schemes#locations"