Sha256: 8386fe7542d3a2d0aba8da50b519d75c8af3a1e2f25ae31a6ae651242d95f52f

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

<%
  conditions = @refine_filter_query.available_conditions_attributes

  conditions_for_category = -> (category) do
    conditions.filter { |c| c[:meta][:category] == category}
  end

  categories = conditions.map { |c| c[:meta][:category] }.uniq.compact

  # Note that the stimulus controllers set default condition id for new conditions
  # so this is only for rare cases where it gets unset
  selected_condition_id ||= @refine_filter.default_condition_id
  selected_condition_id ||= categories
    .first
    &.conditions_for_category.call(categories.first)
    [:id]

  uncategorized_conditions = conditions.filter { |c| c[:meta][:category].nil? }

%>

<%= tag.div data: {
  action: "$change->refine--update#condition",
  controller: 'fields--super-select',
  fields__super_select_enable_search_value: 'true',
  fields__super_select_container_width_value: 'resolve',
} do %>
  <select
    data-fields--super-select-target="select"
    data-condition-id="<%= selected_condition_id %>"
    name="conditions"
    class="refine-condition-select"
  >
    <optgroup >
      <% uncategorized_conditions.each do |condition_option| %>
        <option
          value="<%= condition_option[:id] %>"
          <% if selected_condition_id == condition_option[:id] %>selected<% end %>
          title="<%= condition_option[:display] %>"
        ><%= condition_option[:display] %></option>
      <% end %>
    </optgroup>
    <% categories.each do |category| %>
      <optgroup class="divider" label="<%= category %>">
        <% conditions_for_category.call(category).each do |condition_option| %>
          <option
            value="<%= condition_option[:id] %>"
            <% if selected_condition_id == condition_option[:id] %>selected<% end %>
            title="<%= condition_option[:display] %>"
          ><%= condition_option[:display] %></option>
        <% end %>
      </optgroup>
    <% end %>
  </select>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
refine-rails-2.9.14 app/views/refine/blueprints/_condition_select.html.erb
refine-rails-2.9.13 app/views/refine/blueprints/_condition_select.html.erb