Class: ActiveAdmin::Views::Pages::Index
- Inherits:
-
Base
- Object
- Arbre::HTML::Element
- Arbre::HTML::Tag
- Arbre::HTML::Document
- Base
- ActiveAdmin::Views::Pages::Index
- Defined in:
- lib/active_admin/views/pages/index.rb
Constant Summary
Constants included from Arbre::HTML
Arbre::HTML::AUTO_BUILD_ELEMENTS, Arbre::HTML::HTML5_ELEMENTS
Instance Attribute Summary
Attributes inherited from Arbre::HTML::Tag
Attributes inherited from Arbre::HTML::Element
Instance Method Summary collapse
- #build_scopes ⇒ Object protected
- #config ⇒ Object
-
#default_index_config ⇒ Object
protected
Creates a default configuration for the resource class.
-
#find_index_renderer_class(symbol_or_class) ⇒ Object
protected
Returns the actual class for renderering the main content on the index page.
-
#main_content ⇒ Object
Render’s the index configuration that was set in the controller.
- #title ⇒ Object
Methods inherited from Base
Methods inherited from Arbre::HTML::Document
#build, #build_body, #build_head, #doctype, #document, #tag_name, #to_html
Methods inherited from Arbre::HTML::Tag
#add_class, #build, #class_list, #class_names, #get_attribute, #has_attribute?, #id, #id!, #id=, #initialize, #remove_attribute, #remove_class, #set_attribute, #to_html
Methods inherited from Arbre::HTML::Element
#+, #<<, #add_child, #assigns, #build, builder_method, #content, #content=, #document, #each, #get_elements_by_tag_name, #helpers, #html_safe, #indent_level, #initialize, #parent?, #remove_child, #tag_name, #to_ary, #to_html, #to_s, #to_str
Methods included from Arbre::HTML::BuilderMethods
#build_tag, #current_dom_context, #insert_tag, #insert_text_node_if_string, #with_current_dom_context
Methods included from Arbre::HTML
#current_dom_context, #helpers, #method_missing
Constructor Details
This class inherits a constructor from Arbre::HTML::Tag
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Arbre::HTML
Instance Method Details
#build_scopes ⇒ Object (protected)
39 40 41 42 43 |
# File 'lib/active_admin/views/pages/index.rb', line 39 def build_scopes if active_admin_config.scopes.any? scopes_renderer active_admin_config.scopes end end |
#config ⇒ Object
11 12 13 |
# File 'lib/active_admin/views/pages/index.rb', line 11 def config index_config || default_index_config end |
#default_index_config ⇒ Object (protected)
Creates a default configuration for the resource class. This is a table with each column displayed as well as all the default actions
47 48 49 50 51 52 53 54 55 |
# File 'lib/active_admin/views/pages/index.rb', line 47 def default_index_config @default_index_config ||= ::ActiveAdmin::PageConfig.new(:as => :table) do |display| id_column resource_class.content_columns.each do |col| column col.name.to_sym end default_actions end end |
#find_index_renderer_class(symbol_or_class) ⇒ Object (protected)
Returns the actual class for renderering the main content on the index page. To set this, use the :as option in the page_config block.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/active_admin/views/pages/index.rb', line 59 def find_index_renderer_class(symbol_or_class) case symbol_or_class when Symbol ::ActiveAdmin::Views.const_get("IndexAs" + symbol_or_class.to_s.camelcase) when Class symbol_or_class else raise ArgumentError, "'as' requires a class or a symbol" end end |
#main_content ⇒ Object
Render’s the index configuration that was set in the controller. Defaults to rendering the ActiveAdmin::Pages::Index::Table
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_admin/views/pages/index.rb', line 18 def main_content build_scopes renderer_class = find_index_renderer_class(config[:as]) if collection.any? paginated_collection(collection, :entry_name => active_admin_config.resource_name) do div :class => 'index_content' do insert_tag(renderer_class, config, collection) end end else if controller.action_methods.include?('new') insert_tag(view_factory.blank_slate, active_admin_config.resource_name.pluralize, new_resource_path) else insert_tag(view_factory.blank_slate, active_admin_config.resource_name.pluralize) end end end |
#title ⇒ Object
7 8 9 |
# File 'lib/active_admin/views/pages/index.rb', line 7 def title active_admin_config.plural_resource_name end |