Class: ActiveAdmin::Views::ActiveFiltersSidebarContent
- Inherits:
-
Component
- Object
- Arbre::Component
- Component
- ActiveAdmin::Views::ActiveFiltersSidebarContent
- Defined in:
- lib/active_admin/views/components/active_filters_sidebar_content.rb
Instance Method Summary collapse
- #build ⇒ Object
- #filter_item(filter) ⇒ Object
- #filters_list(active_filters, active_scopes) ⇒ Object
- #scope_block(current_scope) ⇒ Object
- #scope_item(name, value) ⇒ Object
Instance Method Details
#build ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/active_admin/views/components/active_filters_sidebar_content.rb', line 10 def build active_filters = ActiveAdmin::Filters::Active.new(active_admin_config, assigns[:search]) active_scopes = assigns[:search].instance_variable_get("@scope_args") scope_block(current_scope) filters_list(active_filters, active_scopes) end |
#filter_item(filter) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/active_admin/views/components/active_filters_sidebar_content.rb', line 39 def filter_item(filter) li filter. do span filter.label b to_sentence(filter.values.map { |v| pretty_format(v) }) end end |
#filters_list(active_filters, active_scopes) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_admin/views/components/active_filters_sidebar_content.rb', line 25 def filters_list(active_filters, active_scopes) div style: "margin-top: 10px" do h4 I18n.t("active_admin.search_status.current_filters"), style: "margin-bottom: 10px" ul do if active_filters.filters.blank? && active_scopes.blank? li I18n.t("active_admin.search_status.no_current_filters") else active_filters.filters.each { |filter| filter_item(filter) } active_scopes.each { |name, value| scope_item(name, value) } end end end end |
#scope_block(current_scope) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/active_admin/views/components/active_filters_sidebar_content.rb', line 18 def scope_block(current_scope) return unless current_scope h4 I18n.t("active_admin.search_status.current_scope"), style: "display: inline" b scope_name(current_scope), class: "current_scope_name" end |
#scope_item(name, value) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/active_admin/views/components/active_filters_sidebar_content.rb', line 46 def scope_item(name, value) filter_name = name.gsub(/_eq$/, "") filter = active_admin_config.filters[filter_name.to_sym] label = filter.try(:[], :label) || filter_name.titleize li class: "current_filter_#{name}" do span "#{label} #{Ransack::Translate.predicate('eq')}" b value end end |