diff --git a/app/models/location.rb b/app/models/location.rb index 230bb182e..3c9d9e204 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -450,6 +450,10 @@ class Location < ApplicationRecord end end + def incomplete? + [postcode, name, location_admin_district, units, type_of_unit, mobility_type, startdate].any?(&:blank?) + end + private PIO = PostcodeService.new diff --git a/app/views/locations/check_answers.html.erb b/app/views/locations/check_answers.html.erb index cba0d51fe..7fbcaad32 100644 --- a/app/views/locations/check_answers.html.erb +++ b/app/views/locations/check_answers.html.erb @@ -4,7 +4,7 @@ <% content_for :before_content do %> <%= govuk_back_link( text: "Back", - href: scheme_location_availability_path(@scheme, @location), + href: :back, ) %> <% end %> @@ -22,7 +22,7 @@ if attr[:attribute].eql?("status") status_tag(attr[:value]) elsif attr[:attribute].eql?("availability") - details_html(name: "Availability", value: @location.startdate.to_formatted_s(:govuk_date), attribute: "startdate") + details_html(name: "Availability", value: @location.startdate.present? ? @location.startdate.to_formatted_s(:govuk_date) : nil, attribute: "startdate") else details_html(attr) end } %> @@ -34,7 +34,7 @@ <%= f.hidden_field :confirmed %>
<% end %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index d6673233d..466258616 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, "/schemes/#{@scheme.id}/locations/#{location.id}/check-answers"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> + <% row.cell(text: simple_format(location_cell_postcode(location, "/schemes/#{@scheme.id}/locations/#{location.id}#{"/check-answers" if location.incomplete?}"), { 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) %>