Browse Source

WIP for support_services_provider - works concenptually

juris_katrina_test
JG 2 years ago
parent
commit
84a7d98b0f
  1. 26
      app/controllers/schemes_controller.rb
  2. 8
      app/models/scheme.rb
  3. 54
      app/views/schemes/check_answers.html.erb
  4. 34
      app/views/schemes/details.html.erb
  5. 7
      app/views/schemes/new.html.erb
  6. 5
      app/views/schemes/primary_client_group.html.erb
  7. 36
      app/views/schemes/support_services_provider.html.erb
  8. 1
      config/routes.rb
  9. 1
      spec/features/schemes_spec.rb

26
app/controllers/schemes_controller.rb

@ -60,6 +60,14 @@ class SchemesController < ApplicationController
end
def primary_client_group
case
when request.referrer.include?("new") || request.referrer.include?("details")
@back_button_path = scheme_details_path(@scheme)
when request.referrer.include?("provider")
@back_button_path = scheme_support_services_provider_path(@scheme)
when request.query_parameters["check_answers"]
@back_button_path = scheme_check_asnwers_path(@scheme)
end
render "schemes/primary_client_group"
end
@ -87,6 +95,10 @@ class SchemesController < ApplicationController
render "schemes/edit_name"
end
def support_services_provider
render "schemes/support_services_provider"
end
private
def confirm_secondary_page?(page)
@ -97,21 +109,23 @@ private
case
when page.include?("primary")
"schemes/primary_client_group"
when page.include?("primary")
when page.include?("confirm")
"schemes/confirm_secondary"
when page.include?("primary")
when page.include?("secondary-client")
"schemes/secondary_client_group"
when page.include?("primary")
when page.include?("support")
"schemes/support"
when page.include?("primary")
when page.include?("details")
"schemes/details"
when page.include?("primary")
when page.include?("edit")
"schemes/edit_name"
end
end
def next_page_path(page)
case page
when "support-services-provider"
scheme_primary_client_group_path(@scheme)
when "primary-client-group"
scheme_confirm_secondary_client_group_path(@scheme)
when "confirm-secondary"
@ -121,7 +135,7 @@ private
when "support"
new_location_path
when "details"
scheme_primary_client_group_path(@scheme)
scheme_support_services_provider_path(@scheme)
when "edit-name"
scheme_path(@scheme)
end

8
app/models/scheme.rb

@ -143,14 +143,16 @@ class Scheme < ApplicationRecord
def display_attributes
[
{ name: "Service code", value: id_to_display },
{ name: "Scheme code", value: id_to_display },
{ name: "Name", value: service_name, edit: true },
{ name: "Confidential information", value: sensitive, edit: true },
{ name: "Housing stock owned by", value: owning_organisation.name, edit: true },
{ name: "Managed by", value: managing_organisation&.name },
{ name: "Type of scheme", value: scheme_type },
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act },
{ name: "Housing stock owned by", value: owning_organisation.name, edit: true },
{ name: "Support services provided by", value: support_services_provider },
{ name: "Organisation providing support", value: managing_organisation&.name },
{ name: "Primary client group", value: primary_client_group },
{ name: "Has another client group", value: has_other_client_group },
{ name: "Secondary client group", value: secondary_client_group },
{ name: "Level of support given", value: support_type },
{ name: "Intended length of stay", value: intended_stay },

54
app/views/schemes/check_answers.html.erb

@ -7,57 +7,13 @@
<%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %>
<% component.tab(label: "Scheme") do %>
<%= govuk_summary_list do |summary_list| %>
<% @scheme.check_details_attributes.each do |attr| %>
<% next if current_user.data_coordinator? && attr[:name] == ("owned by") %>
<% @scheme.display_attributes.each do |attr| %>
<% next if current_user.data_coordinator? && attr[:name] == ("Housing stock owned by") %>
<% next if @scheme.has_other_client_group == "No" && attr[:name] == ("Secondary client group") %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.key { attr[:name].eql?("Registered under Care Standards Act 2000") ? "Registered under Care Standards Act 2000" : attr[:name].to_s.humanize } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_details_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% @scheme.check_primary_client_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% if @scheme.has_other_client_group == "Yes" %>
<% @scheme.check_secondary_client_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% end %>
<% end %>
<% end %>
<% @scheme.check_support_attributes.each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s } %>
<% row.value { details_html(attr) } %>
<% row.action(
text: "Change",
href: scheme_support_path(scheme_id: @scheme.id, check_answers: true),
) %>
<% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] %>
<% end %>
<% end %>
<% end %>

34
app/views/schemes/details.html.erb

@ -30,24 +30,7 @@
<% null_option = [OpenStruct.new(id: "", name: "Select an option")] %>
<% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %>
<% managing_org_answer_options = null_option + organisations %>
<%= f.govuk_collection_select :managing_organisation_id,
managing_org_answer_options,
:id,
:name,
label: { text: "Which organisation manages this scheme?", size: "m" },
options: { required: true },
"data-controller": %w[accessible-autocomplete conditional-filter] %>
<% if current_user.support? %>
<%= f.govuk_collection_select :owning_organisation_id,
organisations,
:id,
:name,
label: { text: "Which organisation owns the housing stock for this scheme?", size: "m" },
"data-controller": %w[accessible-autocomplete conditional-filter] %>
<% end %>
<% if current_user.data_coordinator? %>
<%= f.hidden_field :owning_organisation_id, value: current_user.organisation.id %>
@ -69,6 +52,23 @@
:name,
legend: { text: "Is this scheme registered under the Care Standards Act 2000?", size: "m" } %>
<% if current_user.support? %>
<%= f.govuk_collection_select :owning_organisation_id,
organisations,
:id,
:name,
label: { text: "Which organisation owns the housing stock for this scheme?", size: "m" },
"data-controller": %w[accessible-autocomplete conditional-filter] %>
<% end %>
<% support_services_provider_selection = Scheme.support_services_providers.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :support_services_provider,
support_services_provider_selection,
:id,
:name,
legend: { text: "Who provides the support services used by this scheme?", size: "m" } %>
<%= f.hidden_field :page, value: "details" %>
<% if request.query_parameters["check_answers"] %>
<%= f.hidden_field :check_answers, value: "true" %>

7
app/views/schemes/new.html.erb

@ -33,13 +33,6 @@
<% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %>
<% answer_options = null_option + organisations %>
<%= f.govuk_collection_select :managing_organisation_id,
answer_options,
:id,
:name,
label: { text: "Which organisation manages this scheme?", size: "m" },
"data-controller": %w[accessible-autocomplete conditional-filter] %>
<% if current_user.data_coordinator? %>
<%= f.hidden_field :owning_organisation_id, value: current_user.organisation.id %>
<% end %>

5
app/views/schemes/primary_client_group.html.erb

@ -3,7 +3,7 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/details",
href: @back_button_path,
) %>
<% end %>
@ -25,6 +25,9 @@
<% if request.query_parameters["check_answers"] == "true" %>
<%= f.hidden_field :check_answers, value: "true" %>
<% end %>
<% if request.query_parameters["select_managing_org"] == "true" %>
<%= f.hidden_field :check_answers, value: "true" %>
<% end %>
<%= f.govuk_submit "Save and continue" %>
</div>

36
app/views/schemes/support_services_provider.html.erb

@ -0,0 +1,36 @@
<% content_for :title, "Which organisation provides the support services used by this scheme?" %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/details",
) %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: "Which organisation provides the support services used by this scheme?", sub: @scheme.service_name } %>
<%= form_for(@scheme, method: :patch) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>
<% null_option = [OpenStruct.new(id: "", name: "Select an option")] %>
<% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %>
<% managing_org_answer_options = null_option + organisations %>
<%= f.govuk_collection_select :managing_organisation_id,
managing_org_answer_options,
:id,
:name,
label: { text: "Which organisation manages this scheme?", size: "m" },
options: { required: true },
"data-controller": %w[accessible-autocomplete conditional-filter] %>
<%= f.hidden_field :page, value: "support-services-provider" %>
<% if request.query_parameters["check_answers"] %>
<%= f.hidden_field :check_answers, value: "true" %>
<% end %>
<%= f.govuk_submit "Save and continue" %>
</div>
</div>
<% end %>

1
config/routes.rb

@ -43,6 +43,7 @@ Rails.application.routes.draw do
get "details", to: "schemes#details"
get "check-answers", to: "schemes#check_answers"
get "edit-name", to: "schemes#edit_name"
get "support-services-provider", to: "schemes#support_services_provider"
member do
resources :locations do

1
spec/features/schemes_spec.rb

@ -691,7 +691,6 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_current_path("/schemes/#{scheme.id}/details")
expect(page).to have_content "Scheme name"
expect(page).to have_content "This scheme contains confidential information"
expect(page).to have_content "Which organisation manages this scheme"
expect(page).to have_content "What is this type of scheme?"
expect(page).to have_content "Who provides the support services used by this scheme?"
expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"

Loading…
Cancel
Save