diff --git a/app/frontend/controllers/search_controller.js b/app/frontend/controllers/search_controller.js index ada55d820..72532e24a 100644 --- a/app/frontend/controllers/search_controller.js +++ b/app/frontend/controllers/search_controller.js @@ -25,6 +25,10 @@ export default class extends Controller { const rawFieldName = matches ? `${matches[1]}[${matches[2]}_raw]` : '' const searchUrl = JSON.parse(this.element.dataset.info).search_url + document.querySelectorAll('.non-js-text-search-input-field').forEach((el) => { + el.style.display = 'none' + }) + accessibleAutocomplete.enhanceSelectElement({ defaultValue: '', selectElement: selectEl, diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 0d5b00796..a43ccb120 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -102,13 +102,13 @@ module FiltersHelper def assigned_to_filter_options(filter_type) if applied_filters(filter_type)["assigned_to"] == "specific_user" && applied_filters(filter_type)["user"].present? user_id = applied_filters(filter_type)["user"] - user = if user.support? - User.where(id: user_id)&.first - else - User.affiliated_users(user.organisation).where(id: user_id)&.first - end + selected_user = if current_user.support? + User.where(id: user_id)&.first + else + User.affiliated_users(current_user.organisation).where(id: user_id)&.first + end - return [OpenStruct.new(id: user.id, name: user.name, hint: user.email)] if user.present? + return [OpenStruct.new(id: selected_user.id, name: selected_user.name, hint: selected_user.email)] if selected_user.present? end [OpenStruct.new(id: "", name: "Select an option", hint: "")] end diff --git a/app/views/filters/_select_filter.html.erb b/app/views/filters/_select_filter.html.erb index 0540ad3db..ecc997bba 100644 --- a/app/views/filters/_select_filter.html.erb +++ b/app/views/filters/_select_filter.html.erb @@ -1,10 +1,11 @@ + <%= f.govuk_text_field "#{category}_text_search".to_sym, label: { text: label, hidden: secondary }, "data-controller": "search conditional-filter", caption: { text: caption_text }, "data-info": { search_url: filter_search_url(category.to_sym) }.to_json, value: selected_option("#{category}_text_search", @filter_type) %> - + <%= f.govuk_select(category.to_sym, label: { text: label, hidden: secondary }, "data-controller": "search conditional-filter",