|
|
@ -41,14 +41,15 @@ class SchemesController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def update |
|
|
|
def update |
|
|
|
|
|
|
|
check_answers = params[:scheme][:check_answers] |
|
|
|
|
|
|
|
page = params[:scheme][:page] |
|
|
|
|
|
|
|
|
|
|
|
if @scheme.update(scheme_params) |
|
|
|
if @scheme.update(scheme_params) |
|
|
|
if params[:scheme][:check_answers] == "true" |
|
|
|
if check_answers |
|
|
|
if params[:scheme][:page] == "confirm-secondary" && @scheme.has_other_client_group == "Yes" |
|
|
|
if confirm_secondary_page? page |
|
|
|
redirect_to scheme_secondary_client_group_path(@scheme, check_answers: "true") |
|
|
|
redirect_to scheme_secondary_client_group_path(@scheme, check_answers: "true") |
|
|
|
else |
|
|
|
else |
|
|
|
if @scheme.has_other_client_group == "No" |
|
|
|
@scheme.update!(secondary_client_group: nil) unless @scheme.has_other_client_group == "Yes" |
|
|
|
@scheme.update!(secondary_client_group: nil) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
redirect_to scheme_check_answers_path(@scheme) |
|
|
|
redirect_to scheme_check_answers_path(@scheme) |
|
|
|
end |
|
|
|
end |
|
|
|
else |
|
|
|
else |
|
|
@ -87,6 +88,10 @@ class SchemesController < ApplicationController |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def confirm_secondary_page? page |
|
|
|
|
|
|
|
page == "confirm-secondary" && @scheme.has_other_client_group == "Yes" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def next_page_path(page) |
|
|
|
def next_page_path(page) |
|
|
|
case page |
|
|
|
case page |
|
|
|
when "primary-client-group" |
|
|
|
when "primary-client-group" |
|
|
@ -103,7 +108,20 @@ private |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def scheme_params |
|
|
|
def scheme_params |
|
|
|
required_params = params.require(:scheme).permit(:service_name, :sensitive, :organisation_id, :stock_owning_organisation_id, :scheme_type, :registered_under_care_act, :total_units, :id, :has_other_client_group, :primary_client_group, :secondary_client_group, :support_type, :intended_stay) |
|
|
|
required_params = params.require(:scheme).permit(:service_name, |
|
|
|
|
|
|
|
:sensitive, |
|
|
|
|
|
|
|
:organisation_id, |
|
|
|
|
|
|
|
:stock_owning_organisation_id, |
|
|
|
|
|
|
|
:scheme_type, |
|
|
|
|
|
|
|
:registered_under_care_act, |
|
|
|
|
|
|
|
:total_units, |
|
|
|
|
|
|
|
:id, |
|
|
|
|
|
|
|
: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[:sensitive] = required_params[:sensitive].to_i if required_params[:sensitive] |
|
|
|
if current_user.data_coordinator? |
|
|
|
if current_user.data_coordinator? |
|
|
|
required_params[:organisation_id] = current_user.organisation_id |
|
|
|
required_params[:organisation_id] = current_user.organisation_id |
|
|
|