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) 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 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 end
def collection_year_options def collection_year_options

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

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

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

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

Loading…
Cancel
Save