From 6072489695b389a2a301964b2e07c6c7d10b060d Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 6 Sep 2022 11:46:52 +0100 Subject: [PATCH] feat: add correct skip and linking behaviour, also rename fallback page --- app/controllers/locations_controller.rb | 4 ++-- app/helpers/check_answers_helper.rb | 2 +- app/helpers/tab_nav_helper.rb | 9 ++++++++- ...allback.html.erb => edit_local_authority.html.erb} | 11 ++++++++--- app/views/locations/index.html.erb | 2 +- app/views/schemes/check_answers.html.erb | 2 +- config/routes.rb | 2 +- 7 files changed, 22 insertions(+), 10 deletions(-) rename app/views/locations/{la_fallback.html.erb => edit_local_authority.html.erb} (97%) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 0406b9d47..4b353816a 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -57,7 +57,7 @@ class LocationsController < ApplicationController location_params[:add_another_location] == "Yes" ? redirect_to(new_location_path(@location.scheme)) : redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) when "edit-name" redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) - when "la-fallback" + when "edit-local-authority" redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) end else @@ -97,7 +97,7 @@ private end def authenticate_action! - if %w[new edit update create index edit_name la_fallback].include?(action_name) && !((current_user.organisation == @scheme&.owning_organisation) || current_user.support?) + if %w[new edit update create index edit_name edit_local_authority].include?(action_name) && !((current_user.organisation == @scheme&.owning_organisation) || current_user.support?) render_not_found and return end end diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index be791effd..9c79d4b00 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -25,7 +25,7 @@ module CheckAnswersHelper end def get_location_change_link_href_location_admin_district(scheme, location) - location_la_fallback_path(id: scheme.id, location_id: location.id) + location_edit_local_authority_path(id: scheme.id, location_id: location.id) end def any_questions_have_summary_card_number?(subsection, lettings_log) diff --git a/app/helpers/tab_nav_helper.rb b/app/helpers/tab_nav_helper.rb index 1f6c25889..1d2cf4063 100644 --- a/app/helpers/tab_nav_helper.rb +++ b/app/helpers/tab_nav_helper.rb @@ -12,7 +12,14 @@ module TabNavHelper end def location_cell_location_admin_district(location, link) - govuk_link_to(location.location_admin_district, link, method: :patch) + la = location.location_admin_district + if location.confirmed? + la + elsif la + govuk_link_to(la, link, method: :patch) + else + govuk_link_to("Select local authority", link, method: :patch) + end end def scheme_cell(scheme) diff --git a/app/views/locations/la_fallback.html.erb b/app/views/locations/edit_local_authority.html.erb similarity index 97% rename from app/views/locations/la_fallback.html.erb rename to app/views/locations/edit_local_authority.html.erb index 39b5804cc..0dcc41ac9 100644 --- a/app/views/locations/la_fallback.html.erb +++ b/app/views/locations/edit_local_authority.html.erb @@ -10,7 +10,7 @@
<%= f.govuk_error_summary %> - <%= render partial: "organisations/headings", locals: { main: "What is the the local authority of this location?", sub: @scheme.service_name } %> + <%= render partial: "organisations/headings", locals: { main: "What is the the local authority of #{@location.postcode}?", sub: @scheme.service_name } %> <% la_hash = { "E07000223": "Adur", @@ -341,9 +341,14 @@ label: { hidden: true }, "data-controller": %w[conditional-filter accessible-autocomplete] %> - <%= f.hidden_field :page, value: "la-fallback" %> + <%= f.hidden_field :page, value: "edit-local-authority" %> + +
+ <%= f.govuk_submit "Save and continue" %> + + <%= govuk_link_to "Skip for now", "/schemes/#{@scheme.id}/check-answers#locations" %> +
- <%= f.govuk_submit "Save and continue" %>
<% end %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index 59e9238b7..6672fc661 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -56,7 +56,7 @@ <% row.cell(text: location.units) %> <% row.cell(text: simple_format("#{location.type_of_unit}")) %> <% row.cell(text: location.mobility_type) %> - <% row.cell(text: simple_format(location_cell_location_admin_district(location, "/schemes/#{@scheme.id}/locations/#{location.id}/la-fallback"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> + <% row.cell(text: simple_format(location_cell_location_admin_district(location, "/schemes/#{@scheme.id}/locations/#{location.id}/edit-local-authority"), wrapper_tag: "div")) %> <% row.cell(text: location.startdate&.to_formatted_s(:govuk_date)) %> <% end %> <% end %> diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb index 349473573..2cb154e1f 100644 --- a/app/views/schemes/check_answers.html.erb +++ b/app/views/schemes/check_answers.html.erb @@ -72,7 +72,7 @@ <% row.cell(text: location.units) %> <% row.cell(text: simple_format("#{location.type_of_unit}")) %> <% row.cell(text: location.mobility_type) %> - <% row.cell(text: simple_format(location_cell_location_admin_district(location, get_location_change_link_href_location_admin_district(@scheme, location)), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> + <% row.cell(text: simple_format(location_cell_location_admin_district(location, get_location_change_link_href_location_admin_district(@scheme, location)), wrapper_tag: "div")) %> <% row.cell(text: location.startdate&.to_formatted_s(:govuk_date)) %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 889cce4eb..0bee9013d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -49,7 +49,7 @@ Rails.application.routes.draw do resources :locations do get "edit-name", to: "locations#edit_name" get "edit", to: "locations#edit" - get "la-fallback", to: "locations#la_fallback" + get "edit-local-authority", to: "locations#edit_local_authority" end end end