Module: ActiveAdmin::Dashboards

Defined in:
lib/active_admin/dashboards.rb,
lib/active_admin/dashboards/section.rb,
lib/active_admin/dashboards/dashboard_controller.rb

Defined Under Namespace

Classes: DashboardController, Section

Constant Summary collapse

@@sections =
{}

Class Method Summary collapse

Class Method Details

.add_section(name, options = {}, &block) ⇒ Object Also known as: section

Add a new dashboard section to a namespace. If no namespace is given it will be added to the default namespace.

Options include:

:namespace => only display for specified namespace.
:if        => specify a method or block to determine whether the section is rendered at run time.


33
34
35
36
37
38
# File 'lib/active_admin/dashboards.rb', line 33

def add_section(name, options = {}, &block)
  namespace = options.delete(:namespace) || ActiveAdmin.application.default_namespace || :root
  self.sections[namespace] ||= [] 
  self.sections[namespace] << Section.new(namespace, name, options, &block)
  self.sections[namespace].sort!
end

.build(&block) ⇒ Object

Eval an entire block in the context of this module to build dashboards quicker.

Example:

ActiveAdmin::Dashboards.build do
  section "Recent Post" do
    # return a list of posts
  end
end


23
24
25
# File 'lib/active_admin/dashboards.rb', line 23

def build(&block)
  module_eval(&block)
end

.clear_all_sections!Object



45
46
47
# File 'lib/active_admin/dashboards.rb', line 45

def clear_all_sections!
  @@sections = {}
end

.sections_for_namespace(namespace) ⇒ Object



41
42
43
# File 'lib/active_admin/dashboards.rb', line 41

def sections_for_namespace(namespace)
  @@sections[namespace] || []
end