Module: ActiveAdmin::Inputs::FilterBase::SearchMethodSelect
- Defined in:
- lib/active_admin/inputs/filter_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
57 58 59 60 61 62 |
# File 'lib/active_admin/inputs/filter_base/search_method_select.rb', line 57 def current_filter @current_filter ||= begin methods = filters.map{ |f| "#{method}_#{f}" } methods.detect{ |m| @object.send m } || methods.first end end |
#filter_options ⇒ Object
64 65 66 67 68 |
# File 'lib/active_admin/inputs/filter_base/search_method_select.rb', line 64 def filters.collect do |filter| [I18n.t("active_admin.filters.predicates.#{filter}"), "#{method}_#{filter}"] end end |
#filters ⇒ Object
53 54 55 |
# File 'lib/active_admin/inputs/filter_base/search_method_select.rb', line 53 def filters [:filters] || self.class.filters end |
#input_html ⇒ Object
45 46 47 |
# File 'lib/active_admin/inputs/filter_base/search_method_select.rb', line 45 def input_html builder.text_field current_filter, end |
#select_html ⇒ Object
49 50 51 |
# File 'lib/active_admin/inputs/filter_base/search_method_select.rb', line 49 def select_html template.select_tag '', template.(, current_filter) end |
#to_html ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/active_admin/inputs/filter_base/search_method_select.rb', line 37 def to_html input_wrapping do label_html << # your label select_html << # the dropdown that holds the available search methods input_html # your input field end end |
#wrapper_html_options ⇒ Object
31 32 33 34 35 |
# File 'lib/active_admin/inputs/filter_base/search_method_select.rb', line 31 def opts = super (opts[:class] ||= '') << ' select_and_search' opts end |