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
Modules: DashboardController Classes: Section
Constant Summary
- @@sections =
{}
Class Method Summary (collapse)
-
+ (Object) add_section(name, options = {}, &block)
(also: section)
Add a new dashboard section to a namespace.
-
+ (Object) add_to_menu(namespace, menu)
Called from MenuBuilder to register dashboard to menu.
-
+ (Object) build(&block)
Eval an entire block in the context of this module to build dashboards quicker.
- + (Boolean) built?
- + (Object) clear_all_sections!
- + (Object) sections_for_namespace(namespace)
Class Method Details
+ (Object) add_section(name, options = {}, &block) 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.
39 40 41 42 43 44 |
# File 'lib/active_admin/dashboards.rb', line 39 def add_section(name, = {}, &block) namespace = .delete(:namespace) || ActiveAdmin.application.default_namespace || :root self.sections[namespace] ||= [] self.sections[namespace] << Section.new(namespace, name, , &block) self.sections[namespace].sort! end |
+ (Object) add_to_menu(namespace, menu)
Called from MenuBuilder to register dashboard to menu.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/active_admin/dashboards.rb', line 56 def (namespace, ) return unless ActiveAdmin::Dashboards.built? dashboard_path = namespace.root? ? :dashboard_path : "#{namespace.name}_dashboard_path".to_sym item = MenuItem.new :id => "dashboard", :label => proc{ I18n.t("active_admin.dashboard") }, :url => dashboard_path, :priority => 1 .add item end |
+ (Object) build(&block)
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 26 27 |
# File 'lib/active_admin/dashboards.rb', line 23 def build(&block) warn "DEPRECATION WARNING: ActiveAdmin::Dashboard is deprecated and will be removed in the next version" @built = true module_eval(&block) end |
+ (Boolean) built?
29 30 31 |
# File 'lib/active_admin/dashboards.rb', line 29 def built? !!@built end |
+ (Object) clear_all_sections!
51 52 53 |
# File 'lib/active_admin/dashboards.rb', line 51 def clear_all_sections! @@sections = {} end |
+ (Object) sections_for_namespace(namespace)
47 48 49 |
# File 'lib/active_admin/dashboards.rb', line 47 def sections_for_namespace(namespace) @@sections[namespace] || [] end |