diff --git a/app/forms/find/location_filter_form.rb b/app/forms/find/location_filter_form.rb index 18485f5de9..4d0176ced5 100644 --- a/app/forms/find/location_filter_form.rb +++ b/app/forms/find/location_filter_form.rb @@ -41,7 +41,7 @@ def handle_location_option @params.merge!(geocode_params) @valid = true else - @errors = [I18n.t('find.location_filter.fields.location'), I18n.t('find.location_filter.errors.unknown_location')] + @errors = [I18n.t('find.fields.location'), I18n.t('find.location_filter.errors.unknown_location')] end end diff --git a/app/view_objects/find/result_filters/filters_view.rb b/app/view_objects/find/result_filters/filters_view.rb index 7eb977d601..a2c01b9538 100644 --- a/app/view_objects/find/result_filters/filters_view.rb +++ b/app/view_objects/find/result_filters/filters_view.rb @@ -7,6 +7,16 @@ def initialize(params:) @params = params end + def radius_options = [1, 5, 10, 15, 20, 25, 50, 100, 200] + + def radius_options_for_select + radius_options.map { |r| [I18n.t('find.result_filters_filters_view.radius_options_for_select.label', count: r), r] } + end + + def radius + params[:radius] + end + def qts_only_checked? checked?('qts') end @@ -120,7 +130,6 @@ def location_query_params loc: params[:loc], longitude: params[:longitude], query: params['provider.provider_name'], - radius: params[:radius], sortby: params[:sortby] } end diff --git a/app/view_objects/find/results_view.rb b/app/view_objects/find/results_view.rb index 057cc6e155..46330b9c3e 100644 --- a/app/view_objects/find/results_view.rb +++ b/app/view_objects/find/results_view.rb @@ -8,7 +8,7 @@ class ResultsView include ActionView::Helpers::NumberHelper DISTANCE = 'distance' - MILES = '50' + MILES = '10' def initialize(query_parameters:) @query_parameters = query_parameters diff --git a/app/views/find/result_filters/_all.html.erb b/app/views/find/result_filters/_all.html.erb index 1588f31b61..2730a36c59 100644 --- a/app/views/find/result_filters/_all.html.erb +++ b/app/views/find/result_filters/_all.html.erb @@ -5,6 +5,7 @@
<%= form.submit "Apply filters", name: nil, class: "govuk-button", data: { qa: "apply-filters" } %> + <%= render "find/result_filters/radius", form: %> <%= render "find/result_filters/visa_filter", form: %> <%= render "find/result_filters/engineers_teach_physics_filter", form: %> <%= render "find/result_filters/study_type_filter", form: %> diff --git a/app/views/find/result_filters/_radius.html.erb b/app/views/find/result_filters/_radius.html.erb new file mode 100644 index 0000000000..c16c1c4af2 --- /dev/null +++ b/app/views/find/result_filters/_radius.html.erb @@ -0,0 +1,12 @@ +<% if @filters_view.location_query? %> +
+ + <%= form.label :radius, "Search radius", class: "govuk-label govuk-fieldset__legend govuk-fieldset__legend--s" %> + +
+
+ <%= form.select :radius, options_for_select(@filters_view.radius_options_for_select, @filters_view.radius), {}, class: "govuk-select" %> +
+
+
+<% end %> diff --git a/config/locales/find.yml b/config/locales/find.yml index 1292a98d1e..0c0d2014b3 100644 --- a/config/locales/find.yml +++ b/config/locales/find.yml @@ -211,6 +211,11 @@ en: html: PGDE without QTS links: national_pay_scales: https://www.gov.uk/government/publications/national-pay-scales-for-eligible-teaching-and-education-jobs/national-pay-scales-for-eligible-teaching-and-education-leadership-occupation-codes + result_filters_filters_view: + radius_options_for_select: + label: + one: '%{count} mile' + other: '%{count} miles' activemodel: errors: models: diff --git a/spec/features/find/search/location_options_spec.rb b/spec/features/find/search/location_options_spec.rb index 3afe3abcc0..4fd1a9f8c6 100644 --- a/spec/features/find/search/location_options_spec.rb +++ b/spec/features/find/search/location_options_spec.rb @@ -62,7 +62,7 @@ def then_i_should_see_the_age_groups_form def and_the_correct_age_group_form_page_url_and_query_params_are_present URI(current_url).then do |uri| expect(uri.path).to eq('/age-groups') - expect(uri.query).to eq('c=England&l=1&latitude=51.4524877&loc=AA+Teamworks+W+Yorks+SCITT%2C+School+Street%2C+Greetland%2C+Halifax%2C+West+Yorkshire+HX4+8JB&longitude=-0.1204749&lq=Yorkshire&radius=50&sortby=distance') + expect(uri.query).to eq('c=England&l=1&latitude=51.4524877&loc=AA+Teamworks+W+Yorks+SCITT%2C+School+Street%2C+Greetland%2C+Halifax%2C+West+Yorkshire+HX4+8JB&longitude=-0.1204749&lq=Yorkshire&radius=10&sortby=distance') end end diff --git a/spec/view_objects/find/result_filters/filters_view_spec.rb b/spec/view_objects/find/result_filters/filters_view_spec.rb index e1e689f277..9116627af7 100644 --- a/spec/view_objects/find/result_filters/filters_view_spec.rb +++ b/spec/view_objects/find/result_filters/filters_view_spec.rb @@ -354,6 +354,30 @@ module ResultFilters it { is_expected.to be(false) } end end + + describe '#radius' do + subject { described_class.new(params: { radius: 10 }).radius } + + it { is_expected.to eq(10) } + end + + describe '#radius_options_for_select' do + subject { described_class.new(params: {}).radius_options_for_select } + + it 'returns an array of arrays' do + expect(subject).to eq([ + ['1 mile', 1], + ['5 miles', 5], + ['10 miles', 10], + ['15 miles', 15], + ['20 miles', 20], + ['25 miles', 25], + ['50 miles', 50], + ['100 miles', 100], + ['200 miles', 200] + ]) + end + end end end end