Browse Source

Update routes (#978)

* Update routes

* Remove member from routes
pull/982/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
ef354fada6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/controllers/locations_controller.rb
  2. 2
      app/controllers/schemes_controller.rb
  3. 6
      app/helpers/check_answers_helper.rb
  4. 2
      app/views/locations/edit.html.erb
  5. 2
      app/views/locations/edit_local_authority.html.erb
  6. 2
      app/views/locations/edit_name.html.erb
  7. 2
      app/views/locations/index.html.erb
  8. 2
      app/views/locations/new.html.erb
  9. 2
      app/views/schemes/check_answers.html.erb
  10. 9
      config/routes.rb

12
app/controllers/locations_controller.rb

@ -23,9 +23,9 @@ class LocationsController < ApplicationController
@location = Location.new(location_params)
if @location.save
if @location.location_admin_district.nil?
redirect_to(location_edit_local_authority_path(id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location]))
redirect_to(scheme_location_edit_local_authority_path(scheme_id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location]))
elsif location_params[:add_another_location] == "Yes"
redirect_to new_location_path(@scheme)
redirect_to new_scheme_location_path(@scheme)
else
check_answers_path = @scheme.confirmed? ? scheme_check_answers_path(@scheme, anchor: "locations") : scheme_check_answers_path(@scheme)
redirect_to check_answers_path
@ -69,9 +69,9 @@ class LocationsController < ApplicationController
case page
when "edit"
if @location.location_admin_district.nil?
redirect_to(location_edit_local_authority_path(id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location]))
redirect_to(scheme_location_edit_local_authority_path(scheme_id: @scheme.id, location_id: @location.id, add_another_location: location_params[:add_another_location]))
elsif location_params[:add_another_location] == "Yes"
redirect_to(new_location_path(@location.scheme))
redirect_to(new_scheme_location_path(@location.scheme))
else
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations"))
end
@ -79,7 +79,7 @@ class LocationsController < ApplicationController
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations"))
when "edit-local-authority"
if params[:add_another_location] == "Yes"
redirect_to(new_location_path(@location.scheme))
redirect_to(new_scheme_location_path(@location.scheme))
else
redirect_to(scheme_check_answers_path(@scheme, anchor: "locations"))
end
@ -107,7 +107,7 @@ private
def find_scheme
@scheme = if %w[new create index edit_name].include?(action_name)
Scheme.find(params[:id])
Scheme.find(params[:scheme_id])
else
@location&.scheme
end

2
app/controllers/schemes_controller.rb

@ -176,7 +176,7 @@ private
when "secondary-client-group"
scheme_support_path(@scheme)
when "support"
new_location_path
new_scheme_location_path(@scheme)
when "details"
if @scheme.arrangement_type_before_type_cast == "D"
scheme_primary_client_group_path(@scheme)

6
app/helpers/check_answers_helper.rb

@ -18,14 +18,14 @@ module CheckAnswersHelper
def get_location_change_link_href_postcode(scheme, location)
if location.confirmed?
location_edit_name_path(id: scheme.id, location_id: location.id)
scheme_location_edit_name_path(scheme_id: scheme.id, location_id: location.id)
else
location_edit_path(id: scheme.id, location_id: location.id)
edit_scheme_location_path(scheme_id: scheme.id, id: location.id)
end
end
def get_location_change_link_href_location_admin_district(scheme, location)
location_edit_local_authority_path(id: scheme.id, location_id: location.id)
scheme_location_edit_local_authority_path(scheme_id: scheme.id, location_id: location.id)
end
def any_questions_have_summary_card_number?(subsection, lettings_log)

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

@ -7,7 +7,7 @@
) %>
<% end %>
<%= form_for(@location, method: :patch, url: location_path(@location)) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -5,7 +5,7 @@
) %>
<% end %>
<%= form_for(@location, method: :patch, url: location_path(location_id: @location.id, add_another_location: params[:add_another_location])) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id, add_another_location: params[:add_another_location])) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -7,7 +7,7 @@
) %>
<% end %>
<%= form_for(@location, method: :patch, url: location_path(location_id: @location.id)) do |f| %>
<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id)) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -62,6 +62,6 @@
<% end %>
<% end %>
<% end %>
<%= govuk_button_link_to "Add a location", new_location_path(id: @scheme.id), secondary: true %>
<%= govuk_button_link_to "Add a location", new_scheme_location_path(scheme_id: @scheme.id), secondary: true %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %>

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

@ -7,7 +7,7 @@
) %>
<% end %>
<%= form_for(@location, method: :post, url: locations_path) do |f| %>
<%= form_for(@location, method: :post, url: scheme_locations_path) do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %>

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

@ -78,7 +78,7 @@
<% end %>
<% end %>
<% end %>
<%= govuk_button_link_to "Add a location", new_location_path(id: @scheme.id), secondary: true %>
<%= govuk_button_link_to "Add a location", new_scheme_location_path(scheme_id: @scheme.id), secondary: true %>
<% end %>
<% end %>
<%= f.hidden_field :page, value: "check-answers" %>

9
config/routes.rb

@ -50,12 +50,9 @@ Rails.application.routes.draw do
get "edit-name", to: "schemes#edit_name"
get "support-services-provider", to: "schemes#support_services_provider"
member do
resources :locations do
get "edit-name", to: "locations#edit_name"
get "edit", to: "locations#edit"
get "edit-local-authority", to: "locations#edit_local_authority"
end
resources :locations do
get "edit-name", to: "locations#edit_name"
get "edit-local-authority", to: "locations#edit_local_authority"
end
end

Loading…
Cancel
Save