Class: ActiveAdmin::Page

Inherits:
Object
  • Object
show all
Includes:
Base, Resource::ActionItems, Resource::Controllers, Resource::Menu, Resource::Naming, Resource::PagePresenters, Resource::Routes, Resource::Sidebars
Defined in:
lib/active_admin/page.rb

Overview

Page is the primary data storage for page configuration in Active Admin

When you register a page (ActiveAdmin.register_page “Status”) you are actually creating a new Page instance within the given Namespace.

The instance of the current page is available in PageController and views by calling the #active_admin_config method.

Defined Under Namespace

Modules: Base

Instance Attribute Summary collapse

Attributes included from Resource::Menu

#menu_item

Instance Method Summary collapse

Methods included from Resource::Routes

#route_batch_action_path, #route_builder, #route_collection_path, #route_edit_instance_path, #route_instance_path, #route_member_action_path, #route_prefix

Methods included from Resource::Naming

#param_key, #resource_label

Methods included from Resource::Menu

#add_to_menu, #include_in_menu?, #menu_item_options, #menu_item_options=, #navigation_menu, #navigation_menu_name, #navigation_menu_name=

Methods included from Resource::ActionItems

#action_items, #action_items?, #action_items_for, #add_action_item, #clear_action_items!, #initialize, #remove_action_item

Methods included from Resource::Sidebars

#clear_sidebar_sections!, #sidebar_sections, #sidebar_sections?, #sidebar_sections_for

Methods included from Resource::PagePresenters

#default_index_class, #find_index_class, #get_page_presenter, #page_presenters, #set_index_presenter, #set_page_presenter

Methods included from Resource::Controllers

#controller

Methods included from Base

#initialize

Instance Attribute Details

Set breadcrumb builder



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

def breadcrumb
  @breadcrumb
end

#nameObject (readonly)

The name of the page



17
18
19
# File 'lib/active_admin/page.rb', line 17

def name
  @name
end

#namespaceObject (readonly)

The namespace this config belongs to



14
15
16
# File 'lib/active_admin/page.rb', line 14

def namespace
  @namespace
end

#page_actionsObject (readonly)

An array of custom actions defined for this page



20
21
22
# File 'lib/active_admin/page.rb', line 20

def page_actions
  @page_actions
end

Instance Method Details

#add_default_action_itemsObject



77
78
# File 'lib/active_admin/page.rb', line 77

def add_default_action_items
end

#add_default_sidebar_sectionsObject



80
81
# File 'lib/active_admin/page.rb', line 80

def add_default_sidebar_sections
end

#belongs_to(target, options = {}) ⇒ Object



88
89
90
91
92
# File 'lib/active_admin/page.rb', line 88

def belongs_to(target, options = {})
  @belongs_to = Resource::BelongsTo.new(self, target, options)
  self.navigation_menu_name = target unless @belongs_to.optional?
  controller.send :belongs_to, target, options.dup
end

#belongs_to?Boolean

Do we belong to another resource?

Returns:

  • (Boolean)


99
100
101
# File 'lib/active_admin/page.rb', line 99

def belongs_to?
  !!belongs_to_config
end

#belongs_to_configObject



94
95
96
# File 'lib/active_admin/page.rb', line 94

def belongs_to_config
  @belongs_to
end

#camelized_resource_nameObject



56
57
58
# File 'lib/active_admin/page.rb', line 56

def camelized_resource_name
  underscored_resource_name.camelize
end

#clear_page_actions!Object

Clears all the custom actions this page knows about



84
85
86
# File 'lib/active_admin/page.rb', line 84

def clear_page_actions!
  @page_actions = []
end

#controller_nameObject



68
69
70
# File 'lib/active_admin/page.rb', line 68

def controller_name
  [namespace.module_name, camelized_resource_name + "Controller"].compact.join("::")
end

#default_menu_optionsObject



64
65
66
# File 'lib/active_admin/page.rb', line 64

def default_menu_options
  super.merge(id: resource_name)
end

#namespace_nameObject



60
61
62
# File 'lib/active_admin/page.rb', line 60

def namespace_name
  namespace.name.to_s
end

#order_clauseObject



107
108
109
# File 'lib/active_admin/page.rb', line 107

def order_clause
  @order_clause || namespace.order_clause
end

#plural_resource_labelObject

label is singular



44
45
46
# File 'lib/active_admin/page.rb', line 44

def plural_resource_label
  name
end

#resource_nameObject



48
49
50
# File 'lib/active_admin/page.rb', line 48

def resource_name
  @resource_name ||= Resource::Name.new(nil, name)
end

#route_uncountable?Boolean

Override from ‘ActiveAdmin::Resource::Controllers`

Returns:

  • (Boolean)


73
74
75
# File 'lib/active_admin/page.rb', line 73

def route_uncountable?
  false
end

#underscored_resource_nameObject



52
53
54
# File 'lib/active_admin/page.rb', line 52

def underscored_resource_name
  resource_name.to_s.parameterize.underscore
end