|
|
@ -6,9 +6,12 @@ class LocationsController < ApplicationController |
|
|
|
before_action :find_scheme |
|
|
|
before_action :find_scheme |
|
|
|
before_action :authenticate_action! |
|
|
|
before_action :authenticate_action! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include Modules::SearchFilter |
|
|
|
|
|
|
|
|
|
|
|
def index |
|
|
|
def index |
|
|
|
@pagy, @locations = pagy(@scheme.locations) |
|
|
|
@pagy, @locations = pagy(filtered_collection(@scheme.locations, search_term)) |
|
|
|
@total_count = @scheme.locations.size |
|
|
|
@total_count = @scheme.locations.size |
|
|
|
|
|
|
|
@searched = search_term.presence |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def new |
|
|
|
def new |
|
|
@ -19,7 +22,12 @@ class LocationsController < ApplicationController |
|
|
|
if date_params_missing?(location_params) || valid_date_params?(location_params) |
|
|
|
if date_params_missing?(location_params) || valid_date_params?(location_params) |
|
|
|
@location = Location.new(location_params) |
|
|
|
@location = Location.new(location_params) |
|
|
|
if @location.save |
|
|
|
if @location.save |
|
|
|
location_params[:add_another_location] == "Yes" ? redirect_to(new_location_path(id: @scheme.id)) : redirect_to(scheme_check_answers_path(scheme_id: @scheme.id)) |
|
|
|
if location_params[:add_another_location] == "Yes" |
|
|
|
|
|
|
|
redirect_to new_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 |
|
|
|
|
|
|
|
end |
|
|
|
else |
|
|
|
else |
|
|
|
render :new, status: :unprocessable_entity |
|
|
|
render :new, status: :unprocessable_entity |
|
|
|
end |
|
|
|
end |
|
|
@ -92,4 +100,8 @@ private |
|
|
|
required_params[:postcode] = PostcodeService.clean(required_params[:postcode]) if required_params[:postcode] |
|
|
|
required_params[:postcode] = PostcodeService.clean(required_params[:postcode]) if required_params[:postcode] |
|
|
|
required_params |
|
|
|
required_params |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def search_term |
|
|
|
|
|
|
|
params["search"] |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|