Sha256: 14d3a776953cc73ecfab4ab215535813f24f3501c0d636ed929eb575a6efe897

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

module ActiveAdminSidebar::ActiveAdminViewsPagesBase

  def build_page_content
    build_flash_messages
    div id: "active_admin_content", class: main_content_classes do
      build_sidebar unless skip_sidebar? || right_sidebar?
      build_main_content_wrapper
      build_sidebar unless skip_sidebar? || left_sidebar?
    end
  end

  def build_sidebar
    if defined?(super)
      super
    else
      sidebar sidebar_sections_for_action, id: 'sidebar'
    end
  end

  def left_sidebar?
    assigns[:sidebar_options].try!(:[], :position) == :left
  end

  def collapsible_sidebar?
    left_sidebar? && !!assigns[:sidebar_options].try!(:[], :collapsed)
  end

  def sidebar_is_collapsed?
    !!assigns[:sidebar_options].try!(:[], :is_collapsed)
  end

  def right_sidebar?
     !left_sidebar?
  end

  def main_content_classes
    classes = Arbre::HTML::ClassList.new
    if skip_sidebar?
      classes << "without_sidebar"
    else
      classes << "with_sidebar"
      classes << "left_sidebar" if left_sidebar?
      if collapsible_sidebar?
        classes << "collapsible_sidebar"
        classes << "collapsed_sidebar" if sidebar_is_collapsed?
      end
    end
    classes
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_admin_sidebar-2.0.0 lib/active_admin_sidebar/activeadmin_views_pages_base.rb
active_admin_sidebar-1.2.0 lib/active_admin_sidebar/activeadmin_views_pages_base.rb
active_admin_sidebar-1.1.0 lib/active_admin_sidebar/activeadmin_views_pages_base.rb