Class: ActiveAdmin::Views::IndexAsTable::IndexTableFor

Inherits:
TableFor show all
Defined in:
lib/active_admin/views/index_as_table.rb

Overview

Extend the default ActiveAdmin::Views::TableFor with some methods for quickly displaying items on the index page

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

Attributes inherited from Arbre::HTML::Element

#children, #parent

Instance Method Summary collapse

Methods inherited from TableFor

#build, #column, #sortable?, #tag_name, #visible_columns

Methods inherited from Arbre::HTML::Table

#initialize

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::Table

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Arbre::HTML

Instance Method Details

#default_actions(options = {}) ⇒ Object

Adds links to View, Edit and Delete



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_admin/views/index_as_table.rb', line 35

def default_actions(options = {})
  options = {
    :name => ""
  }.merge(options)
  column options[:name] do |resource|
    links = link_to I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link"
    links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
    links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'), :class => "member_link delete_link"
    links
  end
end

#id_columnObject

Display a column for the id



30
31
32
# File 'lib/active_admin/views/index_as_table.rb', line 30

def id_column
  column('ID', :sortable => :id){|resource| link_to resource.id, resource_path(resource), :class => "resource_id_link"}
end

#status_tag(*args, &block) ⇒ Object

Display A Status Tag Column

index do |i|
  i.status_tag :state
end

index do |i|
  i.status_tag "State", :status_name
end

index do |i|
  i.status_tag do |post|
    post.published? ? 'published' : 'draft'
  end
end


63
64
65
66
67
68
69
70
# File 'lib/active_admin/views/index_as_table.rb', line 63

def status_tag(*args, &block)
  col = Column.new(*args, &block)
  data = col.data
  col.data = proc do |resource|
    status_tag call_method_or_proc_on(resource, data)
  end
  add_column col
end