Module: ActiveAdmin::Inputs::Filters::Base::SearchMethodSelect
- Included in:
- NumericInput, StringInput, TextInput
- Defined in:
- lib/active_admin/inputs/filters/base/search_method_select.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #current_filter ⇒ Object
- #filter_options ⇒ Object
- #filters ⇒ Object
- #input_html ⇒ Object
- #select_html ⇒ Object
- #to_html ⇒ Object
- #wrapper_html_options ⇒ Object
Instance Method Details
#current_filter ⇒ Object
63 64 65 66 67 68 |
# File 'lib/active_admin/inputs/filters/base/search_method_select.rb', line 63 def current_filter @current_filter ||= begin methods = filters.map { |f| "#{method}_#{f}" } methods.detect { |m| @object.public_send m } || methods.first end end |
#filter_options ⇒ Object
70 71 72 73 74 |
# File 'lib/active_admin/inputs/filters/base/search_method_select.rb', line 70 def filters.collect do |filter| [I18n.t("ransack.predicates.#{filter}").capitalize, "#{method}_#{filter}"] end end |
#filters ⇒ Object
59 60 61 |
# File 'lib/active_admin/inputs/filters/base/search_method_select.rb', line 59 def filters [:filters] || self.class.filters end |
#input_html ⇒ Object
51 52 53 |
# File 'lib/active_admin/inputs/filters/base/search_method_select.rb', line 51 def input_html builder.text_field current_filter, end |
#select_html ⇒ Object
55 56 57 |
# File 'lib/active_admin/inputs/filters/base/search_method_select.rb', line 55 def select_html template.select_tag "", template.(, current_filter) end |
#to_html ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_admin/inputs/filters/base/search_method_select.rb', line 39 def to_html input_wrapping do [ label_html, # your label '<div class="filter-input-group">', select_html, # the dropdown that holds the available search methods input_html, # your input field '</div>' ].join("\n").html_safe end end |
#wrapper_html_options ⇒ Object
33 34 35 36 37 |
# File 'lib/active_admin/inputs/filters/base/search_method_select.rb', line 33 def opts = super (opts[:class] ||= "") << " select_and_search" unless seems_searchable? opts end |