From 19c669b65a2c6b7fde69d427bc9593f680a30411 Mon Sep 17 00:00:00 2001 From: JG Date: Thu, 14 Jul 2022 08:14:38 +0100 Subject: [PATCH] lmoved back button logic to the view --- app/controllers/schemes_controller.rb | 7 ------- app/views/schemes/primary_client_group.html.erb | 10 +++++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index eb343cc0a..b4433b5f4 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -65,13 +65,6 @@ class SchemesController < ApplicationController end def primary_client_group - 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_asnwers_path(@scheme) - end render "schemes/primary_client_group" end diff --git a/app/views/schemes/primary_client_group.html.erb b/app/views/schemes/primary_client_group.html.erb index f4682ebc4..23731b67e 100644 --- a/app/views/schemes/primary_client_group.html.erb +++ b/app/views/schemes/primary_client_group.html.erb @@ -1,9 +1,17 @@ <% content_for :title, "What client group is this scheme intended for?" %> +<% 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_asnwers_path(@scheme) %> +<% end %> + <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: @back_button_path, + href: back_button_path, ) %> <% end %>