Browse Source

feat: add check_answers referrer linking

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
1a85e7ee36
  1. 6
      app/controllers/locations_controller.rb
  2. 2
      app/helpers/locations_helper.rb
  3. 11
      app/views/locations/availability.erb
  4. 2
      app/views/locations/check_answers.html.erb
  5. 11
      app/views/locations/mobility_standards.html.erb
  6. 11
      app/views/locations/name.html.erb
  7. 11
      app/views/locations/postcode.html.erb
  8. 11
      app/views/locations/type_of_unit.html.erb
  9. 11
      app/views/locations/units.html.erb

6
app/controllers/locations_controller.rb

@ -24,7 +24,11 @@ class LocationsController < ApplicationController
if params[:location].present? if params[:location].present?
@location.postcode = params[:location][:postcode] @location.postcode = params[:location][:postcode]
@location.save! @location.save!
redirect_to scheme_location_name_path(@scheme, @location) if params[:referrer] == "check_answers"
redirect_to scheme_location_check_answers_path(@scheme, @location)
else
redirect_to scheme_location_name_path(@scheme, @location)
end
end end
end end

2
app/helpers/locations_helper.rb

@ -67,7 +67,7 @@ module LocationsHelper
scheme_location_type_of_unit_path(location.scheme, location, referrer: "check_answers") scheme_location_type_of_unit_path(location.scheme, location, referrer: "check_answers")
when "mobility_standards" when "mobility_standards"
scheme_location_mobility_standards_path(location.scheme, location, referrer: "check_answers") scheme_location_mobility_standards_path(location.scheme, location, referrer: "check_answers")
when "avaliability" when "availability"
scheme_location_availability_path(location.scheme, location, referrer: "check_answers") scheme_location_availability_path(location.scheme, location, referrer: "check_answers")
end end
end end

11
app/views/locations/availability.erb

@ -3,11 +3,11 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: 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),
) %> ) %>
<% end %> <% end %>
<%= form_for(@location, method: :patch, url: scheme_location_availability_path(@scheme, @location)) do |f| %> <%= form_for(@location, method: :patch, url: scheme_location_availability_path(@scheme, @location, referrer: params[:referrer])) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
@ -20,8 +20,13 @@
width: 20 %> width: 20 %>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <% if params[:referrer] == "check_answers" %>
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %>
<% else %>
<%= f.govuk_submit "Save and continue" %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

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

@ -15,7 +15,7 @@
<div class="govuk-grid-column-two-thirds-from-desktop"> <div class="govuk-grid-column-two-thirds-from-desktop">
<%= govuk_summary_list do |summary_list| %> <%= govuk_summary_list do |summary_list| %>
<% display_location_attributes(@location).each do |attr| %> <% display_location_attributes(@location).each do |attr| %>
<% next if attr[:attribute] == "code" %> <% next if %w[location_code status].include? attr[:attribute] %>
<%= summary_list.row do |row| %> <%= summary_list.row do |row| %>
<% row.key { attr[:name] } %> <% row.key { attr[:name] } %>
<% row.value { attr[:attribute].eql?("status") ? status_tag(attr[:value]) : details_html(attr) } %> <% row.value { attr[:attribute].eql?("status") ? status_tag(attr[:value]) : details_html(attr) } %>

11
app/views/locations/mobility_standards.html.erb

@ -3,11 +3,11 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: 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),
) %> ) %>
<% end %> <% end %>
<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location)) do |f| %> <%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location, referrer: params[:referrer])) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
@ -22,8 +22,13 @@
legend: nil %> legend: nil %>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <% if params[:referrer] == "check_answers" %>
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %>
<% else %>
<%= f.govuk_submit "Save and continue" %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

11
app/views/locations/name.html.erb

@ -3,11 +3,11 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: scheme_location_postcode_path(@scheme, @location), href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_postcode_path(@scheme, @location),
) %> ) %>
<% end %> <% end %>
<%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location)) do |f| %> <%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location, referrer: params[:referrer])) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
@ -19,8 +19,13 @@
hint: { text: I18n.t("hints.location.name") } %> hint: { text: I18n.t("hints.location.name") } %>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <% if params[:referrer] == "check_answers" %>
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %>
<% else %>
<%= f.govuk_submit "Save and continue" %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

11
app/views/locations/postcode.html.erb

@ -3,11 +3,11 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: scheme_locations_path(@scheme), href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_locations_path(@scheme),
) %> ) %>
<% end %> <% end %>
<%= form_for(@location, method: :patch, url: scheme_location_postcode_path(@scheme, @location)) do |f| %> <%= form_for(@location, method: :patch, url: scheme_location_postcode_path(@scheme, @location, referrer: params[:referrer])) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
@ -20,8 +20,13 @@
width: 5 %> width: 5 %>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <% if params[:referrer] == "check_answers" %>
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %>
<% else %>
<%= f.govuk_submit "Save and continue" %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

11
app/views/locations/type_of_unit.html.erb

@ -3,11 +3,11 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: scheme_location_units_path(@scheme, @location), href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_units_path(@scheme, @location),
) %> ) %>
<% end %> <% end %>
<%= form_for(@location, method: :patch, url: scheme_location_type_of_unit_path(@scheme, @location)) do |f| %> <%= form_for(@location, method: :patch, url: scheme_location_type_of_unit_path(@scheme, @location, referrer: params[:referrer])) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
@ -21,8 +21,13 @@
legend: nil %> legend: nil %>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <% if params[:referrer] == "check_answers" %>
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %>
<% else %>
<%= f.govuk_submit "Save and continue" %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

11
app/views/locations/units.html.erb

@ -3,11 +3,11 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: scheme_location_name_path(@scheme, @location), href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location) : scheme_location_name_path(@scheme, @location),
) %> ) %>
<% end %> <% end %>
<%= form_for(@location, method: :patch, url: scheme_location_units_path(@scheme, @location)) do |f| %> <%= form_for(@location, method: :patch, url: scheme_location_units_path(@scheme, @location, referrer: params[:referrer])) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
@ -21,8 +21,13 @@
autofocus: true %> autofocus: true %>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <% if params[:referrer] == "check_answers" %>
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location), secondary: true %>
<% else %>
<%= f.govuk_submit "Save and continue" %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
<% end %>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save