Class: ActiveAdmin::Filters::ActiveSidebar

Inherits:
SidebarSection show all
Defined in:
lib/active_admin/filters/active_sidebar.rb

Instance Attribute Summary

Attributes inherited from SidebarSection

#name, #options

Instance Method Summary collapse

Methods inherited from SidebarSection

#custom_class, #id, #partial_name, #priority

Methods included from OptionalDisplay

#display_on?

Constructor Details

#initializeActiveSidebar

Returns a new instance of ActiveSidebar.


7
8
9
# File 'lib/active_admin/filters/active_sidebar.rb', line 7

def initialize
  super 'search_status', sidebar_options
end

Instance Method Details

#blockObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_admin/filters/active_sidebar.rb', line 11

def block
  -> do
    active_filters = ActiveAdmin::Filters::Active.new(active_admin_config, assigns[:search])
    span do
      if current_scope
        h4 I18n.t("active_admin.search_status.current_scope"), style: 'display: inline'
        b scope_name(current_scope), class: 'current_scope_name', style: "display: inline"
      end
      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?
            li I18n.t("active_admin.search_status.no_current_filters")
          else
            active_filters.filters.each do |filter|
              li filter.html_options do
                span do
                  text_node filter.label
                end
                b do
                  text_node to_sentence(filter.values.map { |v| pretty_format(v) })
                end
              end
            end
          end
        end
      end
    end
  end
end

48
49
50
# File 'lib/active_admin/filters/active_sidebar.rb', line 48

def sidebar_options
  { only: :index, if: -> { active_admin_config.current_filters_enabled? && (params[:q] || params[:scope]) } }
end

#titleObject


42
43
44
# File 'lib/active_admin/filters/active_sidebar.rb', line 42

def title
  I18n.t("active_admin.search_status.headline")
end