|
|
@ -65,12 +65,11 @@ class SchemesController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def primary_client_group |
|
|
|
def primary_client_group |
|
|
|
case |
|
|
|
if request.referer&.include?("new") || request.referer&.include?("details") |
|
|
|
when request.referrer.include?("new") || request.referrer.include?("details") |
|
|
|
|
|
|
|
@back_button_path = scheme_details_path(@scheme) |
|
|
|
@back_button_path = scheme_details_path(@scheme) |
|
|
|
when request.referrer.include?("provider") |
|
|
|
elsif request.referer&.include?("provider") |
|
|
|
@back_button_path = scheme_support_services_provider_path(@scheme) |
|
|
|
@back_button_path = scheme_support_services_provider_path(@scheme) |
|
|
|
when request.query_parameters["check_answers"] |
|
|
|
elsif request.query_parameters["check_answers"] |
|
|
|
@back_button_path = scheme_check_asnwers_path(@scheme) |
|
|
|
@back_button_path = scheme_check_asnwers_path(@scheme) |
|
|
|
end |
|
|
|
end |
|
|
|
render "schemes/primary_client_group" |
|
|
|
render "schemes/primary_client_group" |
|
|
@ -106,8 +105,8 @@ class SchemesController < ApplicationController |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def validation_errors scheme_params |
|
|
|
def validation_errors(scheme_params) |
|
|
|
scheme_params.keys.each do |key| |
|
|
|
scheme_params.each_key do |key| |
|
|
|
@scheme.errors.add(key.to_sym) if scheme_params[key].to_s.empty? |
|
|
|
@scheme.errors.add(key.to_sym) if scheme_params[key].to_s.empty? |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -117,18 +116,17 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def current_template(page) |
|
|
|
def current_template(page) |
|
|
|
case |
|
|
|
if page.include?("primary") |
|
|
|
when page.include?("primary") |
|
|
|
|
|
|
|
"schemes/primary_client_group" |
|
|
|
"schemes/primary_client_group" |
|
|
|
when page.include?("confirm") |
|
|
|
elsif page.include?("confirm") |
|
|
|
"schemes/confirm_secondary" |
|
|
|
"schemes/confirm_secondary" |
|
|
|
when page.include?("secondary-client") |
|
|
|
elsif page.include?("secondary-client") |
|
|
|
"schemes/secondary_client_group" |
|
|
|
"schemes/secondary_client_group" |
|
|
|
when page.include?("support") |
|
|
|
elsif page.include?("support") |
|
|
|
"schemes/support" |
|
|
|
"schemes/support" |
|
|
|
when page.include?("details") |
|
|
|
elsif page.include?("details") |
|
|
|
"schemes/details" |
|
|
|
"schemes/details" |
|
|
|
when page.include?("edit") |
|
|
|
elsif page.include?("edit") |
|
|
|
"schemes/edit_name" |
|
|
|
"schemes/edit_name" |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -146,7 +144,7 @@ private |
|
|
|
when "support" |
|
|
|
when "support" |
|
|
|
new_location_path |
|
|
|
new_location_path |
|
|
|
when "details" |
|
|
|
when "details" |
|
|
|
if @scheme.support_services_provider.eql?"The same organisation that owns the housing stock" |
|
|
|
if @scheme.support_services_provider.eql? "The same organisation that owns the housing stock" |
|
|
|
scheme_primary_client_group_path(@scheme) |
|
|
|
scheme_primary_client_group_path(@scheme) |
|
|
|
else |
|
|
|
else |
|
|
|
scheme_support_services_provider_path(@scheme) |
|
|
|
scheme_support_services_provider_path(@scheme) |
|
|
@ -173,7 +171,7 @@ private |
|
|
|
|
|
|
|
|
|
|
|
same_org_providing_support = required_params[:support_services_provider] == "The same organisation that owns the housing stock" |
|
|
|
same_org_providing_support = required_params[:support_services_provider] == "The same organisation that owns the housing stock" |
|
|
|
|
|
|
|
|
|
|
|
full_params = same_org_providing_support ? required_params.merge(managing_organisation_id: required_params[:owning_organisation_id]) : required_params |
|
|
|
full_params = same_org_providing_support && required_params[:owning_organisation_id].present? ? required_params.merge(managing_organisation_id: required_params[:owning_organisation_id]) : required_params |
|
|
|
|
|
|
|
|
|
|
|
full_params[:sensitive] = full_params[:sensitive].to_i if full_params[:sensitive] |
|
|
|
full_params[:sensitive] = full_params[:sensitive].to_i if full_params[:sensitive] |
|
|
|
if current_user.data_coordinator? |
|
|
|
if current_user.data_coordinator? |
|
|
|