Class: ActiveAdmin::Filters::ActiveFilter
- Inherits:
-
Object
- Object
- ActiveAdmin::Filters::ActiveFilter
- Includes:
- ViewHelpers
- Defined in:
- lib/active_admin/filters/active_filter.rb
Constant Summary
Constants included from ViewHelpers::DisplayHelper
ViewHelpers::DisplayHelper::DISPLAY_NAME_FALLBACK
Constants included from ViewHelpers::BreadcrumbHelper
ViewHelpers::BreadcrumbHelper::GUID_REGEX, ViewHelpers::BreadcrumbHelper::ID_REGEX
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
Methods included from ViewHelpers::ScopeNameHelper
Methods included from ViewHelpers::FlashHelper
Methods included from ViewHelpers::ViewFactoryHelper
Methods included from ViewHelpers::TitleHelper
Methods included from ViewHelpers::FormHelper
#active_admin_form_for, #fields_for_params, #hidden_field_tags_for
Methods included from ViewHelpers::SidebarHelper
#skip_sidebar!, #skip_sidebar?
Methods included from MethodOrProcHelper
#call_method_or_exec_proc, #call_method_or_proc_on, #render_in_context, #render_or_call_method_or_proc_on
Methods included from ViewHelpers::LayoutHelper
#action_items_for_action, #body_classes, #sidebar_sections_for_action
Methods included from ViewHelpers::DisplayHelper
#association_methods_for, #boolean_attr?, #display_name, #display_name_method_for, #find_value, #format_attribute, #pretty_format
Methods included from ViewHelpers::BreadcrumbHelper
#breadcrumb_links, #breadcrumb_part_config, #default_breadcrumb_links
Methods included from ViewHelpers::AutoLinkHelper
#active_admin_resource_for, #auto_link, #auto_url_for
Methods included from ViewHelpers::ActiveAdminApplicationHelper
Constructor Details
#initialize(resource, condition) ⇒ ActiveFilter
Instantiate a ‘ActiveFilter`
13 14 15 16 17 |
# File 'lib/active_admin/filters/active_filter.rb', line 13 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.
7 8 9 |
# File 'lib/active_admin/filters/active_filter.rb', line 7 def condition @condition end |
#related_class ⇒ Object (readonly)
Returns the value of attribute related_class.
7 8 9 |
# File 'lib/active_admin/filters/active_filter.rb', line 7 def @related_class end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
7 8 9 |
# File 'lib/active_admin/filters/active_filter.rb', line 7 def resource @resource end |
Instance Method Details
#html_options ⇒ Object
45 46 47 |
# File 'lib/active_admin/filters/active_filter.rb', line 45 def { class: "current_filter current_filter_#{condition.key}" } end |
#label ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_admin/filters/active_filter.rb', line 28 def label # TODO: to remind us to go back to the simpler str.downcase once we support ruby >= 2.4 only. translated_predicate = predicate_name.mb_chars.downcase.to_s if filter_label "#{filter_label} #{translated_predicate}" elsif "#{} #{translated_predicate}" else "#{attribute_name} #{translated_predicate}" end.strip end |
#predicate_name ⇒ Object
40 41 42 43 |
# File 'lib/active_admin/filters/active_filter.rb', line 40 def predicate_name I18n.t("active_admin.filters.predicates.#{condition.predicate.name}", default: ransack_predicate_name) end |
#values ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/active_admin/filters/active_filter.rb', line 19 def values condition_values = condition.values.map(&:value) if .where( => condition_values) else condition_values end end |