Browse Source

feat: remove support services provider question page

pull/1173/head
natdeanlewissoftwire 3 years ago
parent
commit
8409bdf58b
  1. 28
      app/controllers/schemes_controller.rb
  2. 6
      app/helpers/schemes_helper.rb
  3. 8
      app/models/scheme.rb
  4. 1
      app/services/imports/scheme_location_import_service.rb
  5. 5
      app/views/schemes/check_answers.html.erb
  6. 2
      app/views/schemes/primary_client_group.html.erb
  7. 34
      app/views/schemes/support_services_provider.html.erb
  8. 2
      config/locales/en.yml

28
app/controllers/schemes_controller.rb

@ -92,11 +92,7 @@ class SchemesController < ApplicationController
validation_errors scheme_params
if @scheme.errors.empty? && @scheme.save
if @scheme.arrangement_type_before_type_cast == "D"
redirect_to scheme_primary_client_group_path(@scheme)
else
redirect_to scheme_support_services_provider_path(@scheme)
end
redirect_to scheme_primary_client_group_path(@scheme)
else
@scheme.errors.add(:owning_organisation_id, message: @scheme.errors[:organisation])
@scheme.errors.delete(:owning_organisation)
@ -182,12 +178,6 @@ class SchemesController < ApplicationController
render "schemes/edit_name"
end
def support_services_provider
render_not_found and return unless @scheme
render "schemes/support_services_provider"
end
private
def validation_errors(scheme_params)
@ -196,10 +186,6 @@ private
@scheme.errors.add(key.to_sym)
end
end
if @scheme.arrangement_type_same? && arrangement_type_value(scheme_params[:arrangement_type]) != "D"
@scheme.errors.delete(:managing_organisation_id)
end
end
def confirm_secondary_page?(page)
@ -209,8 +195,6 @@ private
def current_template(page)
if page.include?("primary")
"schemes/primary_client_group"
elsif page.include?("support-services-provider")
"schemes/support_services_provider"
elsif page.include?("confirm")
"schemes/confirm_secondary"
elsif page.include?("secondary-client")
@ -228,8 +212,6 @@ private
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"
@ -239,13 +221,7 @@ private
when "support"
scheme_check_answers_path(@scheme)
when "details"
if @scheme.arrangement_type_before_type_cast == "D"
scheme_primary_client_group_path(@scheme)
elsif @scheme.arrangement_type.present? && @scheme.arrangement_type_before_type_cast != "D"
scheme_support_services_provider_path(@scheme)
else
scheme_details_path(@scheme)
end
scheme_primary_client_group_path(@scheme)
when "edit-name"
scheme_check_answers_path(@scheme)
when "check-answers"

6
app/helpers/schemes_helper.rb

@ -8,7 +8,6 @@ module SchemesHelper
{ name: "Registered under Care Standards Act 2000", value: scheme.registered_under_care_act },
{ name: "Housing stock owned by", value: scheme.owning_organisation.name, edit: true },
{ name: "Support services provided by", value: scheme.arrangement_type },
{ name: "Organisation providing support", value: scheme.managing_organisation&.name },
{ name: "Primary client group", value: scheme.primary_client_group },
{ name: "Has another client group", value: scheme.has_other_client_group },
{ name: "Secondary client group", value: scheme.secondary_client_group },
@ -25,9 +24,10 @@ module SchemesHelper
base_attributes.delete_if { |item| item[:name] == "Housing stock owned by" }
end
if scheme.arrangement_type_same?
base_attributes.delete_if { |item| item[:name] == "Organisation providing support" }
if scheme.has_other_client_group == "Yes"
base_attributes.append
end
base_attributes
end

8
app/models/scheme.rb

@ -127,12 +127,6 @@ class Scheme < ApplicationRecord
]
end
def check_support_services_provider_attributes
[
{ name: "Organisation providing support", value: managing_organisation&.name, id: "managing_organisation_id" },
]
end
def check_primary_client_attributes
[
{ name: "Primary client group", value: primary_client_group, id: "primary_client_group" },
@ -201,7 +195,7 @@ class Scheme < ApplicationRecord
end
def validate_confirmed
required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group deactivation_date deactivation_date_type]
required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group deactivation_date deactivation_date_type managing_organisation_id]
if confirmed == true
required_attributes.any? do |attribute|

1
app/services/imports/scheme_location_import_service.rb

@ -38,6 +38,7 @@ module Imports
end_date: attributes["end_date"],
# These values were set by the scheme import (management groups)
owning_organisation_id: source_scheme.owning_organisation_id,
# change this?
managing_organisation_id: source_scheme.managing_organisation_id,
service_name: source_scheme.service_name,
arrangement_type: source_scheme.arrangement_type,

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

@ -12,11 +12,6 @@
<% next if current_user.data_coordinator? && attr[:name] == ("owned by") %>
<%= render partial: "scheme_summary_list_row", locals: { scheme: @scheme, attribute: attr, change_link: @scheme.confirmed? ? scheme_edit_name_path(@scheme) : scheme_details_path(@scheme, check_answers: true) } %>
<% end %>
<% if !@scheme.arrangement_type_same? %>
<% @scheme.check_support_services_provider_attributes.each do |attr| %>
<%= render partial: "scheme_summary_list_row", locals: { scheme: @scheme, attribute: attr, change_link: scheme_support_services_provider_path(@scheme, check_answers: true) } %>
<% end %>
<% end %>
<% @scheme.check_primary_client_attributes.each do |attr| %>
<%= render partial: "scheme_summary_list_row", locals: { scheme: @scheme, attribute: attr, change_link: scheme_primary_client_group_path(@scheme, check_answers: true) } %>
<% end %>

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

@ -2,8 +2,6 @@
<% if request.referer&.include?("new") || request.referer&.include?("details") %>
<% back_button_path = scheme_details_path(@scheme) %>
<% elsif request.referer&.include?("provider") %>
<% back_button_path = scheme_support_services_provider_path(@scheme) %>
<% elsif request.query_parameters["check_answers"] %>
<% back_button_path = scheme_check_answers_path(@scheme) %>
<% end %>

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

@ -1,34 +0,0 @@
<% 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 %>
<%= 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 provides the support services used by 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 %>

2
config/locales/en.yml

@ -71,8 +71,6 @@ en:
attributes:
owning_organisation_id:
invalid: "Enter the name of the organisation that owns the housing stock"
managing_organisation_id:
invalid: "Enter the name of the organisation that manages the housing stock"
service_name:
invalid: "Enter the name of the scheme"
scheme_type:

Loading…
Cancel
Save