Browse Source

Update select filter with hints

pull/2097/head
Kat 2 years ago
parent
commit
26bc1a0cad
  1. 2
      app/helpers/filters_helper.rb
  2. 1
      app/views/filters/_radio_filter.html.erb
  3. 17
      app/views/filters/_select_filter.html.erb

2
app/helpers/filters_helper.rb

@ -89,7 +89,7 @@ module FiltersHelper
def assigned_to_filter_options(user)
user_options = user.support? ? User.all : (user.organisation.users + user.organisation.managing_agents.flat_map(&:users) + user.organisation.stock_owners.flat_map(&:users)).uniq
[OpenStruct.new(id: "", name: "Select an option")] + user_options.map { |user_option| OpenStruct.new(id: user_option.id, name: user_option.name) }
[OpenStruct.new(id: "", name: "Select an option", hint: "")] + user_options.map { |user_option| OpenStruct.new(id: user_option.id, name: user_option.name, hint: user_option.email) }
end
def collection_year_options

1
app/views/filters/_radio_filter.html.erb

@ -11,6 +11,7 @@
category: option[:conditional_filter][:category],
label: option[:conditional_filter][:label],
secondary: true,
hint_text: option[:conditional_filter][:hint_text],
} %>
<% end %>
<% end %>

17
app/views/filters/_select_filter.html.erb

@ -1,7 +1,10 @@
<%= f.govuk_collection_select category.to_sym,
collection,
:id,
:name,
label: { hidden: secondary },
options: { disabled: [""], selected: selected_option(category, @filter_type) },
"data-controller": %w[accessible-autocomplete conditional-filter] %>
<%= f.govuk_select(category.to_sym,
label: { text: label, hidden: secondary },
"data-controller": "accessible-autocomplete conditional-filter") do %>
<% collection.each do |answer| %>
<option value="<%= answer.id %>"
data-hint="<%= answer.hint %>"
<%= answer.id.to_s == selected_option(category, @filter_type).to_s ? "selected" : "" %>
<%= answer.id == "" ? "disabled" : "" %>><%= answer.name %></option>
<% end %>
<% end %>

Loading…
Cancel
Save