Sha256: 424582e512408c795d667a9d86a5b30f5e970b6de646ac58acd866abb6da8092

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

module ActiveAdminSidebar
  module Positions
    def left_sidebar!(options = {})
      @sidebar_options = { position: :left }
      if options.fetch(:collapsed, false)
        collapsed_sidebar
        @sidebar_options.merge!(
          is_collapsed: session[:collapsed_sidebar],
          collapsed: true
        )
      end
    end

    def right_sidebar!
      @sidebar_options = { position: :right }
    end

    def collapsed_sidebar
      if request.xhr?
        if params[:collapsed_sidebar].present?
          collapsed = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include? params[:collapsed_sidebar]
          session[:collapsed_sidebar] = collapsed
          render json: { collapsed_sidebar: collapsed } and return
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_admin_sidebar-0.1.0.rc3 lib/active_admin_sidebar/positions.rb