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) redirect_to scheme_location_postcode_path(@scheme, @location)
end 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 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 end
def units 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 end
def type_of_unit 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 end
def mobility_standards 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 end
def startdate 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 end
def check_answers def check_answers; end
@location.update(location_params)
end
def show; end def show; end

14
app/helpers/locations_helper.rb

@ -56,19 +56,19 @@ module LocationsHelper
def location_edit_path(location, page) def location_edit_path(location, page)
case page case page
when "postcode" when "postcode"
scheme_location_postcode_path(location.scheme, location) scheme_location_postcode_path(location.scheme, location, referrer: "check_answers")
when "name" when "name"
scheme_location_name_path(location.scheme, location) scheme_location_name_path(location.scheme, location, referrer: "check_answers")
when "location_admin_district" 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" when "units"
scheme_location_units_path(location.scheme, location) scheme_location_units_path(location.scheme, location, referrer: "check_answers")
when "type_of_unit" 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" when "mobility_standards"
scheme_location_mobility_standards_path(location.scheme, location) scheme_location_mobility_standards_path(location.scheme, location, referrer: "check_answers")
when "startdate" when "startdate"
scheme_location_startdate_path(location.scheme, location) scheme_location_startdate_path(location.scheme, location, referrer: "check_answers")
end end
end end

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

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

4
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: :back, href: scheme_location_type_of_unit_path(@scheme, @location),
) %> ) %>
<% end %> <% 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-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>

4
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: :back, href: scheme_location_postcode_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_name_path(@scheme, @location)) 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 %>

4
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: :back, href: scheme_locations_path(@scheme),
) %> ) %>
<% end %> <% 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-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>

4
app/views/locations/startdate.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: :back, href: scheme_location_mobility_standards_path(@scheme, @location),
) %> ) %>
<% end %> <% 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-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>

4
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: :back, href: scheme_location_units_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_type_of_unit_path(@scheme, @location)) 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 %>

4
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: :back, href: scheme_location_name_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_units_path(@scheme, @location)) 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 %>

2
config/routes.rb

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

Loading…
Cancel
Save