Class: ActiveAdmin::Filters::ActiveFilter
- Inherits:
-
Object
- Object
- ActiveAdmin::Filters::ActiveFilter
- Defined in:
- lib/active_admin/filters/active_filter.rb
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#related_class ⇒ Object
readonly
Returns the value of attribute related_class.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #html_options ⇒ Object
-
#initialize(resource, condition) ⇒ ActiveFilter
constructor
Instantiate a ‘ActiveFilter`.
- #label ⇒ Object
- #predicate_name ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(resource, condition) ⇒ ActiveFilter
Instantiate a ‘ActiveFilter`
12 13 14 15 16 |
# File 'lib/active_admin/filters/active_filter.rb', line 12 def initialize(resource, condition) @resource = resource @condition = condition @related_class = find_class if find_class? end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
6 7 8 |
# File 'lib/active_admin/filters/active_filter.rb', line 6 def condition @condition end |
#related_class ⇒ Object (readonly)
Returns the value of attribute related_class.
6 7 8 |
# File 'lib/active_admin/filters/active_filter.rb', line 6 def @related_class end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
6 7 8 |
# File 'lib/active_admin/filters/active_filter.rb', line 6 def resource @resource end |
Instance Method Details
#html_options ⇒ Object
46 47 48 |
# File 'lib/active_admin/filters/active_filter.rb', line 46 def { "data-filter": condition.key } end |
#label ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_admin/filters/active_filter.rb', line 27 def label translated_predicate = predicate_name.downcase if filter_label && filter_label.is_a?(Proc) "#{filter_label.call} #{translated_predicate}" elsif filter_label "#{filter_label} #{translated_predicate}" elsif "#{} #{translated_predicate}" else "#{attribute_name} #{translated_predicate}" end.strip end |
#predicate_name ⇒ Object
40 41 42 43 44 |
# File 'lib/active_admin/filters/active_filter.rb', line 40 def predicate_name I18n.t( "ransack.predicates.#{condition.predicate.name}", default: ransack_predicate_name) end |
#values ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/active_admin/filters/active_filter.rb', line 18 def values condition_values = condition.values.map(&:value) if .where( => condition_values) else condition_values end end |