diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 496007740..ab6b322ac 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -19,7 +19,7 @@ class LocationsController < ApplicationController @location = Location.new(location_params) if @location.save - location_params[:add_another_location] == "Yes" ? redirect_to(location_new_scheme_path) : redirect_to(scheme_check_answers_path(scheme_id: @scheme.id)) + location_params[:add_another_location] == "Yes" ? redirect_to(new_location_path(id: @scheme.id)) : redirect_to(scheme_check_answers_path(scheme_id: @scheme.id)) else render :new, status: :unprocessable_entity end @@ -29,7 +29,7 @@ class LocationsController < ApplicationController def update if @location.update(location_params) - location_params[:add_another_location] == "Yes" ? redirect_to(location_new_scheme_path) : redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) + location_params[:add_another_location] == "Yes" ? redirect_to(new_location_path) : redirect_to(scheme_check_answers_path(@scheme, anchor: "locations")) else render :details, status: :unprocessable_entity end @@ -38,11 +38,11 @@ class LocationsController < ApplicationController private def find_scheme - if %w[new create].include?(action_name) - @scheme = Scheme.find(params[:id]) - else - @scheme = @location.scheme - end + @scheme = if %w[new create].include?(action_name) + Scheme.find(params[:id]) + else + @location.scheme + end end def find_location diff --git a/app/views/schemes/locations.html.erb b/app/views/schemes/locations.html.erb deleted file mode 100644 index 6d3cc3de3..000000000 --- a/app/views/schemes/locations.html.erb +++ /dev/null @@ -1,49 +0,0 @@ -<% title = @scheme.service_name %> -<% content_for :title, title %> -<% content_for :before_content do %> - <%= govuk_back_link( - text: "Back", - href: "/schemes/#{@scheme.id}", - ) %> -<% end %> -<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> -<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %> -<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, location_caption)) %> - -
-
- <%= govuk_table do |table| %> - <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> - <%= @scheme.locations.count %> <%= @scheme.locations.count.eql?(1) ? "location" : "locations" %>. - <% end %> - <%= table.head do |head| %> - <%= head.row do |row| %> - <% row.cell(header: true, text: "Code", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Postcode", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Units", html_attributes: { - scope: "col", - }) %> - <% row.cell(header: true, text: "Common unit type", html_attributes: { - scope: "col", - }) %> - <% end %> - <% end %> - <% @locations.each do |location| %> - <%= table.body do |body| %> - <%= body.row do |row| %> - <% row.cell(text: location.id) %> - <% row.cell(text: location.postcode) %> - <% row.cell(text: location.total_units) %> - <% row.cell(text: simple_format("#{location.type_of_unit}#{location.wheelchair_adaptation == 'Yes' ? "\nWith wheelchair adaptations" : ''}")) %> - <% end %> - <% end %> - <% end %> - <% end %> -
-
- -<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %>