Sha256: 8a31d1e0726b45e145e4e767c06d9d0b732d62f4a8adfb2befc5f51491e2c770
Contents?: true
Size: 1.6 KB
Versions: 6
Compression:
Stored size: 1.6 KB
Contents
<% # headmin/filters/select # # ==== Options # * <tt>name</tt> - Name of the filter parameter # * <tt>label</tt> - Display name # * <tt>options</tt> - List of options to select from # # ==== Examples # Basic version # <%= render "headmin/filters/select", name: :poll_type, label: 'Type', options: [["General", "general", "Fun", "fun"]] %#> label = local_assigns.has_key?(:label) ? label : nil name = local_assigns.has_key?(:name) ? name : nil options = local_assigns.has_key?(:options) ? options : [] select_options = { class: "form-select", prompt: t('.blank'), include_blank: false, required: true, 'data-filters-target': 'input', 'data-action': "change->filters#update" } %> <%= content_for :filters_menu do %> <%= render 'headmin/filters/filter/menu_item', name: name, label: label %> <% end %> <%= content_for :filters_templates do %> <%= render 'headmin/filters/filter/template', name: name, label: label do %> <%= select_tag("#{name}[]", options_for_select(options), select_options) %> <% end %> <% end %> <%= content_for :filters_buttons do %> <% (params[name] || []).each_with_index do |param, index| %> <% selected_option = options.detect { |value, key, config| (key.present? ? key : value) == param } %> <% selected_value = selected_option.is_a?(Array) ? selected_option.first : selected_option %> <%= render 'headmin/filters/filter/button', name: name, label: label, value: selected_value, id: "#{name}_#{index}" do %> <%= select_tag("#{name}[]", options_for_select(options, param), select_options) %> <% end %> <% end %> <% end %>
Version data entries
6 entries across 6 versions & 1 rubygems