diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 32c579a60..7b13353f6 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -36,7 +36,7 @@ class LocationsController < ApplicationController elsif params[:referrer] == "check_answers" redirect_to scheme_location_check_answers_path(@scheme, @location) else - redirect_to scheme_location_name_path(@scheme, @location) + redirect_to scheme_location_name_path(@scheme, @location, referrer: params[:referrer]) end else render :postcode, status: :unprocessable_entity @@ -48,12 +48,12 @@ class LocationsController < ApplicationController if params[:location].present? @location.location_admin_district = params[:location][:location_admin_district] @location.location_code = Location.local_authorities.key(params[:location][:location_admin_district]) - if @location.valid?(:local_authority) + if @location.valid?(:location_admin_district) @location.save! if params[:referrer] == "check_answers" redirect_to scheme_location_check_answers_path(@scheme, @location) else - redirect_to scheme_location_name_path(@scheme, @location) + redirect_to scheme_location_name_path(@scheme, @location, referrer: params[:referrer]) end else render :local_authority, status: :unprocessable_entity @@ -72,7 +72,7 @@ class LocationsController < ApplicationController when "details" redirect_to scheme_location_path(@scheme, @location) else - redirect_to scheme_location_units_path(@scheme, @location) + redirect_to scheme_location_units_path(@scheme, @location, referrer: params[:referrer]) end else render :name, status: :unprocessable_entity @@ -88,7 +88,7 @@ class LocationsController < ApplicationController if params[:referrer] == "check_answers" redirect_to scheme_location_check_answers_path(@scheme, @location) else - redirect_to scheme_location_type_of_unit_path(@scheme, @location) + redirect_to scheme_location_type_of_unit_path(@scheme, @location, referrer: params[:referrer]) end else render :units, status: :unprocessable_entity @@ -104,7 +104,7 @@ class LocationsController < ApplicationController if params[:referrer] == "check_answers" redirect_to scheme_location_check_answers_path(@scheme, @location) else - redirect_to scheme_location_mobility_standards_path(@scheme, @location) + redirect_to scheme_location_mobility_standards_path(@scheme, @location, referrer: params[:referrer]) end else render :type_of_unit, status: :unprocessable_entity @@ -120,7 +120,7 @@ class LocationsController < ApplicationController if params[:referrer] == "check_answers" redirect_to scheme_location_check_answers_path(@scheme, @location) else - redirect_to scheme_location_availability_path(@scheme, @location) + redirect_to scheme_location_availability_path(@scheme, @location, referrer: params[:referrer]) end else render :mobility_standards, status: :unprocessable_entity @@ -138,7 +138,7 @@ class LocationsController < ApplicationController @location.startdate = Time.zone.local(year.to_i, month.to_i, day.to_i) if @location.valid?(:startdate) @location.save! - redirect_to scheme_location_check_answers_path(@scheme, @location) + redirect_to scheme_location_check_answers_path(@scheme, @location, referrer: params[:referrer]) else render :availability, status: :unprocessable_entity end @@ -158,7 +158,7 @@ class LocationsController < ApplicationController def check_answers if params[:location].present? flash[:notice] = "#{@location.postcode} #{@location.startdate < Time.zone.now ? 'has been' : 'will be'} added to this scheme" - redirect_to scheme_locations_path(@scheme, @location) + redirect_to scheme_locations_path(@scheme) end end diff --git a/app/views/locations/availability.erb b/app/views/locations/availability.erb index 071561bd4..702ea9258 100644 --- a/app/views/locations/availability.erb +++ b/app/views/locations/availability.erb @@ -3,7 +3,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_mobility_standards_path(@scheme, @location), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_mobility_standards_path(@scheme, @location, referrer: params[:referrer]), ) %> <% end %> diff --git a/app/views/locations/check_answers.html.erb b/app/views/locations/check_answers.html.erb index 69a91ee55..3356f75af 100644 --- a/app/views/locations/check_answers.html.erb +++ b/app/views/locations/check_answers.html.erb @@ -4,7 +4,14 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: :back, + href: case params[:referrer] + when "new_scheme" + scheme_location_availability_path(@scheme, @location, referrer: params[:referrer]) + when "locations" + scheme_locations_path(@scheme) + else + :back + end, ) %> <% end %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index 2804bc0ba..bc436bb18 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -52,7 +52,7 @@ <%= table.body do |body| %> <%= body.row do |row| %> <% row.cell(text: location.id) %> - <% row.cell(text: simple_format(location_cell_postcode(location, location.confirmed ? scheme_location_path(@scheme, location) : scheme_location_check_answers_path(@scheme, location)), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> + <% row.cell(text: simple_format(location_cell_postcode(location, location.confirmed ? scheme_location_path(@scheme, location) : scheme_location_check_answers_path(@scheme, location, referrer: "locations")), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: location.units) %> <% row.cell(text: simple_format("#{location.type_of_unit}")) %> <% row.cell(text: location.mobility_type) %> diff --git a/app/views/locations/local_authority.html.erb b/app/views/locations/local_authority.html.erb index 493c4f9cf..32e035950 100644 --- a/app/views/locations/local_authority.html.erb +++ b/app/views/locations/local_authority.html.erb @@ -3,7 +3,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_postcode_path(@scheme), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer]), ) %> <% end %> diff --git a/app/views/locations/mobility_standards.html.erb b/app/views/locations/mobility_standards.html.erb index d4844c0d6..663544c7d 100644 --- a/app/views/locations/mobility_standards.html.erb +++ b/app/views/locations/mobility_standards.html.erb @@ -3,7 +3,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_type_of_unit_path(@scheme, @location), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_type_of_unit_path(@scheme, @location, referrer: params[:referrer]), ) %> <% end %> diff --git a/app/views/locations/name.html.erb b/app/views/locations/name.html.erb index aa9f43b4c..6c6ef57e6 100644 --- a/app/views/locations/name.html.erb +++ b/app/views/locations/name.html.erb @@ -6,7 +6,7 @@ href: if params[:referrer] == "check_answers" scheme_location_check_answers_path(@scheme, @location) else - params[:referrer] == "details" ? scheme_location_path(@scheme, @location) : scheme_location_postcode_path(@scheme, @location) + params[:referrer] == "details" ? scheme_location_path(@scheme, @location) : scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer]) end, ) %> <% end %> diff --git a/app/views/locations/type_of_unit.html.erb b/app/views/locations/type_of_unit.html.erb index 7befd6f2e..e437c1374 100644 --- a/app/views/locations/type_of_unit.html.erb +++ b/app/views/locations/type_of_unit.html.erb @@ -3,7 +3,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_units_path(@scheme, @location), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_units_path(@scheme, @location, referrer: params[:referrer]), ) %> <% end %> diff --git a/app/views/locations/units.html.erb b/app/views/locations/units.html.erb index e212abd27..1b2fa6271 100644 --- a/app/views/locations/units.html.erb +++ b/app/views/locations/units.html.erb @@ -3,7 +3,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_name_path(@scheme, @location), + href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_name_path(@scheme, @location, referrer: params[:referrer]), ) %> <% end %>