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.



29
30
31
32
33
34
# File 'lib/active_admin/dashboards.rb', line 29

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



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

def clear_all_sections!
  @@sections = {}
end

.sections_for_namespace(namespace) ⇒ Object



37
38
39
# File 'lib/active_admin/dashboards.rb', line 37

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