Browse Source

feat: more flow work

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
935d63e261
  1. 45
      app/controllers/locations_controller.rb
  2. 14
      app/helpers/locations_helper.rb
  3. 4
      app/views/locations/check_answers.html.erb
  4. 4
      app/views/locations/mobility_standards.html.erb
  5. 4
      app/views/locations/name.html.erb
  6. 4
      app/views/locations/postcode.html.erb
  7. 4
      app/views/locations/startdate.html.erb
  8. 4
      app/views/locations/type_of_unit.html.erb
  9. 4
      app/views/locations/units.html.erb
  10. 2
      config/routes.rb

45
app/controllers/locations_controller.rb

@ -20,31 +20,58 @@ class LocationsController < ApplicationController
redirect_to scheme_location_postcode_path(@scheme, @location)
end
def postcode; end
def postcode
if params[:location].present?
@location.postcode = params[:location][:postcode]
@location.save!
redirect_to scheme_location_name_path(@scheme, @location)
end
end
def name
@location.update(location_params)
if params[:location].present?
@location.name = params[:location][:name]
@location.save!
redirect_to scheme_location_units_path(@scheme, @location)
end
end
def units
@location.update(location_params)
if params[:location].present?
@location.units = params[:location][:units]
@location.save!
redirect_to scheme_location_type_of_unit_path(@scheme, @location)
end
end
def type_of_unit
@location.update(location_params)
if params[:location].present?
@location.type_of_unit = params[:location][:type_of_unit]
@location.save!
redirect_to scheme_location_mobility_standards_path(@scheme, @location)
end
end
def mobility_standards
@location.update(location_params)
if params[:location].present?
@location.mobility_type = params[:location][:mobility_type]
@location.save!
redirect_to scheme_location_startdate_path(@scheme, @location)
end
end
def startdate
@location.update(location_params)
if params[:location].present?
day = params[:location]["startdate(3i)"]
month = params[:location]["startdate(2i)"]
year = params[:location]["startdate(1i)"]
@location.startdate = Time.zone.local(year.to_i, month.to_i, day.to_i)
@location.save!
redirect_to scheme_location_check_answers_path(@scheme, @location)
end
end
def check_answers
@location.update(location_params)
end
def check_answers; end
def show; end

14
app/helpers/locations_helper.rb

@ -56,19 +56,19 @@ module LocationsHelper
def location_edit_path(location, page)
case page
when "postcode"
scheme_location_postcode_path(location.scheme, location)
scheme_location_postcode_path(location.scheme, location, referrer: "check_answers")
when "name"
scheme_location_name_path(location.scheme, location)
scheme_location_name_path(location.scheme, location, referrer: "check_answers")
when "location_admin_district"
scheme_location_edit_local_authority_path(location.scheme, location)
scheme_location_edit_local_authority_path(location.scheme, location, referrer: "check_answers")
when "units"
scheme_location_units_path(location.scheme, location)
scheme_location_units_path(location.scheme, location, referrer: "check_answers")
when "type_of_unit"
scheme_location_type_of_unit_path(location.scheme, location)
scheme_location_type_of_unit_path(location.scheme, location, referrer: "check_answers")
when "mobility_standards"
scheme_location_mobility_standards_path(location.scheme, location)
scheme_location_mobility_standards_path(location.scheme, location, referrer: "check_answers")
when "startdate"
scheme_location_startdate_path(location.scheme, location)
scheme_location_startdate_path(location.scheme, location, referrer: "check_answers")
end
end

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

@ -4,7 +4,7 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: :back,
href: scheme_location_startdate_path(@scheme, @location),
) %>
<% end %>
@ -26,5 +26,5 @@
</div>
<div class="govuk-button-group">
<%= govuk_button_to "Add this location", scheme_locations_path(@scheme) %>
<%= govuk_button_link_to "Cancel", new_scheme_location_path(@scheme), secondary: true %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div>

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

@ -3,11 +3,11 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: :back,
href: scheme_location_type_of_unit_path(@scheme, @location),
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_startdate_path(@scheme, @location)) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -3,11 +3,11 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: :back,
href: scheme_location_postcode_path(@scheme, @location),
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_units_path(@scheme, @location)) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -3,11 +3,11 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: :back,
href: scheme_locations_path(@scheme),
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location)) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_postcode_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

4
app/views/locations/startdate.html.erb

@ -3,11 +3,11 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: :back,
href: scheme_location_mobility_standards_path(@scheme, @location),
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_check_answers_path(@scheme, @location)) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_startdate_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -3,11 +3,11 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: :back,
href: scheme_location_units_path(@scheme, @location),
) %>
<% end %>
<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location)) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_type_of_unit_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -3,11 +3,11 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: :back,
href: scheme_location_name_path(@scheme, @location),
) %>
<% 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_units_path(@scheme, @location)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

2
config/routes.rb

@ -65,6 +65,7 @@ Rails.application.routes.draw do
get "reactivate", to: "locations#reactivate"
get "new-reactivation", to: "locations#new_reactivation"
get "postcode", to: "locations#postcode"
patch "postcode", to: "locations#postcode"
get "name", to: "locations#name"
patch "name", to: "locations#name"
get "units", to: "locations#units"
@ -76,7 +77,6 @@ Rails.application.routes.draw do
get "startdate", to: "locations#startdate"
patch "startdate", to: "locations#startdate"
get "check-answers", to: "locations#check_answers"
patch "check-answers", to: "locations#check_answers"
patch "new-deactivation", to: "locations#new_deactivation"
patch "deactivate", to: "locations#deactivate"
patch "reactivate", to: "locations#reactivate"

Loading…
Cancel
Save