Browse Source

CLDC-3072 Add email hint to user filters (#2097)

* Update select filter with hints

* Style hint
pull/2100/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
f0895a163b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      app/frontend/styles/_filter.scss
  2. 2
      app/helpers/filters_helper.rb
  3. 1
      app/views/filters/_radio_filter.html.erb
  4. 17
      app/views/filters/_select_filter.html.erb

11
app/frontend/styles/_filter.scss

@ -104,13 +104,12 @@
background-color: govuk-colour("white"); background-color: govuk-colour("white");
} }
.autocomplete__wrapper {
@include govuk-media-query(wide) {
max-width: 20ex;
}
}
.autocomplete__option { .autocomplete__option {
@include govuk-font(16); @include govuk-font(16);
} }
.autocomplete__option__hint {
@include govuk-font(14);
word-break: break-all;
}
} }

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