Sha256: 59cabfa83fc1e6bc19280725316507b83cebf41fa8a9199db22571a8431763b2

Contents?: true

Size: 1.57 KB

Versions: 21

Compression:

Stored size: 1.57 KB

Contents

require 'active_admin/filters/active'

module ActiveAdmin
  module Filters
    class ActiveSidebar < ActiveAdmin::SidebarSection

      def initialize
        super I18n.t("active_admin.search_status.headline"), sidebar_options
      end

      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

      protected

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

    end
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
activeadmin-rails-1.7.1 lib/active_admin/filters/active_sidebar.rb
activeadmin-rails-1.7.0 lib/active_admin/filters/active_sidebar.rb
activeadmin-rb-1.6.0 lib/active_admin/filters/active_sidebar.rb
activeadmin-rb-1.5.2 lib/active_admin/filters/active_sidebar.rb
activeadmin-rb-1.5.1 lib/active_admin/filters/active_sidebar.rb
activeadmin-rb-1.5.0 lib/active_admin/filters/active_sidebar.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/filters/active_sidebar.rb
activeadmin-rb-1.4.0 lib/active_admin/filters/active_sidebar.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/filters/active_sidebar.rb
activeadmin-1.4.3 lib/active_admin/filters/active_sidebar.rb
activeadmin-1.4.2 lib/active_admin/filters/active_sidebar.rb
activeadmin-1.4.1 lib/active_admin/filters/active_sidebar.rb
activeadmin-1.4.0 lib/active_admin/filters/active_sidebar.rb
activeadmin-1.3.1 lib/active_admin/filters/active_sidebar.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/filters/active_sidebar.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/filters/active_sidebar.rb
activeadmin-1.3.0 lib/active_admin/filters/active_sidebar.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/filters/active_sidebar.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/filters/active_sidebar.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/lib/active_admin/filters/active_sidebar.rb