Sha256: 72addf68b88637d56b09181e5f92d46238bfa9b67e5a123a9cda2adebf0bb480

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

<%#
    name: headmin/filters/select
    accepts block: no
    parameters:
      name: (string) Name of the parameter
      label: (string) Display name
      options: (array) List of options to select from
%>
<% 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 %>
  <% if filter_param_exists?(name) %>
    <% option_name = options.select { |value, key| params[name].include?(key.to_s)}.map{|value, key| value}.join(', ') %>
    <%= render 'headmin/filters/filter/button', name: name, label: label, value: option_name do %>
      <%= select_tag("#{name}[]", options_for_select(options, params[name]), select_options) %>
    <% end %>
  <% end %>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
headmin-0.1.2 app/views/headmin/filters/_select.html.erb
headmin-0.1.1 app/views/headmin/filters/_select.html.erb