Browse Source

feat: add check answers page, continue updating flow

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
75e6760a14
  1. 24
      app/controllers/locations_controller.rb
  2. 37
      app/helpers/locations_helper.rb
  3. 30
      app/views/locations/check_answers.html.erb
  4. 2
      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/show.html.erb
  8. 4
      app/views/locations/startdate.html.erb
  9. 4
      app/views/locations/type_of_unit.html.erb
  10. 4
      app/views/locations/units.html.erb
  11. 4
      config/routes.rb

24
app/controllers/locations_controller.rb

@ -22,15 +22,29 @@ class LocationsController < ApplicationController
def postcode; end def postcode; end
def name; end def name
@location.update(location_params)
end
def type_of_unit; end def units
@location.update(location_params)
end
def mobility_standards; end def type_of_unit
@location.update(location_params)
end
def startdate; end def mobility_standards
@location.update(location_params)
end
def check_answers; end def startdate
@location.update(location_params)
end
def check_answers
@location.update(location_params)
end
def show; end def show; end

37
app/helpers/locations_helper.rb

@ -25,18 +25,18 @@ module LocationsHelper
def display_location_attributes(location) def display_location_attributes(location)
base_attributes = [ base_attributes = [
{ name: "Postcode", value: location.postcode }, { name: "Postcode", value: location.postcode, attribute: "postcode" },
{ name: "Local authority", value: location.location_admin_district }, { name: "Location name", value: location.name, attribute: "name" },
{ name: "Location name", value: location.name, edit: true }, { name: "Local authority", value: location.location_admin_district, attribute: "location_admin_district" },
{ name: "Total number of units at this location", value: location.units }, { name: "Number of units", value: location.units, attribute: "units" },
{ name: "Common type of unit", value: location.type_of_unit }, { name: "Most common unit", value: location.type_of_unit, attribute: "type_of_unit"},
{ name: "Mobility type", value: location.mobility_type }, { name: "Mobility standards", value: location.mobility_type, attribute: "mobility_standards" },
{ name: "Code", value: location.location_code }, { name: "Code", value: location.location_code, attribute: "location_code" },
{ name: "Availability", value: location_availability(location) }, { name: "Availability", value: location_availability(location), attribute: "startdate" },
] ]
if FeatureToggle.location_toggle_enabled? if FeatureToggle.location_toggle_enabled?
base_attributes.append({ name: "Status", value: location.status }) base_attributes.append({ name: "Status", value: location.status, attribute: "status" })
end end
base_attributes base_attributes
@ -66,6 +66,25 @@ module LocationsHelper
availability.strip availability.strip
end end
def location_edit_path(location, page)
case page
when "postcode"
scheme_location_postcode_path(location.scheme, location)
when "name"
scheme_location_name_path(location.scheme, location)
when "location_admin_district"
scheme_location_edit_local_authority_path(location.scheme, location)
when "units"
scheme_location_units_path(location.scheme, location)
when "type_of_unit"
scheme_location_type_of_unit_path(location.scheme, location)
when "mobility_standards"
scheme_location_mobility_standards_path(location.scheme, location)
when "startdate"
scheme_location_startdate_path(location.scheme, location)
end
end
private private
def remove_overlapping_and_empty_periods(periods) def remove_overlapping_and_empty_periods(periods)

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

@ -0,0 +1,30 @@
<% title = @location.name %>
<% content_for :title, title %>
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
href: scheme_locations_path(@scheme),
) %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: "Check your answers", sub: "Add a location to #{@scheme.service_name}" } %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<%= govuk_summary_list do |summary_list| %>
<% display_location_attributes(@location).each do |attr| %>
<% next if attr[:attribute] == "code" %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name] } %>
<% row.value { attr[:attribute].eql?("status") ? status_tag(attr[:value]) : details_html(attr) } %>
<% row.action(text: "Change", href: location_edit_path(@location, attr[:attribute])) unless attr[:name] == "Status" %>
<% end %>
<% end %>
<% end %>
</div>
</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 %>
</div>

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

@ -23,7 +23,7 @@
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div> </div>
</div> </div>
</div> </div>

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

@ -3,7 +3,7 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}/support", href: scheme_locations_path(@scheme),
) %> ) %>
<% end %> <% end %>
@ -20,7 +20,7 @@
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div> </div>
</div> </div>
</div> </div>

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

@ -3,7 +3,7 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}/support", href: scheme_locations_path(@scheme),
) %> ) %>
<% end %> <% end %>
@ -21,7 +21,7 @@
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div> </div>
</div> </div>
</div> </div>

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

@ -16,8 +16,8 @@
<% display_location_attributes(@location).each do |attr| %> <% display_location_attributes(@location).each do |attr| %>
<%= summary_list.row do |row| %> <%= summary_list.row do |row| %>
<% row.key { attr[:name] } %> <% row.key { attr[:name] } %>
<% row.value { attr[:name].eql?("Status") ? status_tag(attr[:value]) : details_html(attr) } %> <% row.value { attr[:attribute].eql?("status") ? status_tag(attr[:value]) : details_html(attr) } %>
<% row.action(text: "Change", href: scheme_location_edit_name_path(scheme_id: @scheme.id, location_id: @location.id)) if attr[:edit] %> <% row.action(text: "Change", href: scheme_location_name_path(@scheme, @location)) if attr[:attribute] == "name" %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

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

@ -3,7 +3,7 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}/support", href: scheme_locations_path(@scheme),
) %> ) %>
<% end %> <% end %>
@ -21,7 +21,7 @@
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div> </div>
</div> </div>
</div> </div>

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

@ -3,7 +3,7 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}/support", href: scheme_locations_path(@scheme),
) %> ) %>
<% end %> <% end %>
@ -22,7 +22,7 @@
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div> </div>
</div> </div>
</div> </div>

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

@ -3,7 +3,7 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}/support", href: scheme_locations_path(@scheme),
) %> ) %>
<% end %> <% end %>
@ -22,7 +22,7 @@
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Continue" %> <%= f.govuk_submit "Continue" %>
<%= govuk_link_to "Cancel", new_scheme_location_path(@scheme) %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div> </div>
</div> </div>
</div> </div>

4
config/routes.rb

@ -73,8 +73,8 @@ Rails.application.routes.draw do
patch "mobility-standards", to: "locations#mobility_standards" patch "mobility-standards", to: "locations#mobility_standards"
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#show" get "check-answers", to: "locations#check_answers"
patch "check-answers", to: "locations#show" 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