<% placeholder = defined?(table_filter["placeholder"]) ? table_filter["placeholder"] : "" %> <% prompt = defined?(table_filter["prompt"]) ? table_filter["prompt"] : "" %> <% index = defined?(index) ? index : nil %> <% filter_count = defined?(filter_count) ? filter_count : nil %> <% width = defined?(table_filter["width"]) ? table_filter["width"] : "100%" %> <% allow_clear = table_filter.key?("allow-clear") ? table_filter["allow-clear"] : true %> <% searchable = table_filter.key?("searchable") && table_filter["searchable"] ? 0 : -1 %> <% if table_filter["type"] == "checkbox" %>
<% elsif ["select", "group-select"].include?(table_filter["type"]) %>
<% if table_filter["type"] == "select" %> <%= select_tag(table_filter["name"].parameterize('_'), options_for_select(table_filter["values"], table_filter["selection"]), options = {:prompt => prompt, :data =>{:placeholder => placeholder, "allow-clear" => allow_clear }}) %> <% elsif table_filter["type"] == "group-select" %> <%= select_tag(table_filter["name"].parameterize('_'), grouped_options_for_select(table_filter["values"], table_filter["selection"]), options = {:prompt => prompt, :data =>{:placeholder => placeholder, "allow-clear" => allow_clear }}) %> <% end %>
<% content_for :scripts do %> $('#<%= "#{table_name}_content" %>').find('select[name="<%= table_filter["name"].parameterize('_') %>"]').select2({theme: "bootstrap", minimumResultsForSearch: <%= searchable %>, width: '<%= width %>', allowClear: <%= allow_clear %>}) <% end %> <% elsif table_filter["type"] == "boolean" %>
' <%= table_filter["selection"] == "true" ? 'checked' : ''%>>
<% end %>