Browse Source

feat: add correct skip and linking behaviour, also rename fallback page

CLDC-1390-la-lookup-fallback-WIP
natdeanlewissoftwire 2 years ago
parent
commit
6072489695
  1. 4
      app/controllers/locations_controller.rb
  2. 2
      app/helpers/check_answers_helper.rb
  3. 9
      app/helpers/tab_nav_helper.rb
  4. 9
      app/views/locations/edit_local_authority.html.erb
  5. 2
      app/views/locations/index.html.erb
  6. 2
      app/views/schemes/check_answers.html.erb
  7. 2
      config/routes.rb

4
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

2
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)

9
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)

9
app/views/locations/la_fallback.html.erb → app/views/locations/edit_local_authority.html.erb

@ -10,7 +10,7 @@
<div class="govuk-grid-column-two-thirds">
<%= 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" %>
<div class="govuk-button-group">
<%= f.govuk_submit "Save and continue" %>
<%= govuk_link_to "Skip for now", "/schemes/#{@scheme.id}/check-answers#locations" %>
</div>
</div>
</div>
<% end %>

2
app/views/locations/index.html.erb

@ -56,7 +56,7 @@
<% row.cell(text: location.units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>")) %>
<% 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 %>

2
app/views/schemes/check_answers.html.erb

@ -72,7 +72,7 @@
<% row.cell(text: location.units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>")) %>
<% 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 %>

2
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

Loading…
Cancel
Save