Class: ActiveAdmin::Views::IndexAsSortableTable

Inherits:
IndexAsTable
  • Object
show all
Defined in:
lib/activeadmin_draggable/sortable_tree.rb

Overview

An index page component, which allows both list and tree reordering It has full interface-wise compatibility with IndexAsTable component Example usage:

index :as => :sortable_table, :tree => true

Defined Under Namespace

Classes: IndexSortableTableFor

Instance Method Summary collapse

Instance Method Details

#build(page_presenter, collection) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/activeadmin_draggable/sortable_tree.rb', line 11

def build(page_presenter, collection)
  table_options = {

    :id => active_admin_config.resource_name.plural,
    :sortable => false,
    :class => "index_table list",
    :i18n => active_admin_config.resource_class,
    :paginator => false
  }

  if is_tree = page_presenter.options[:tree]
    table_options[:class] += " tree"
  end

  table_for collection, table_options do |t|
    table_config_block = page_presenter.block || default_table
    instance_exec(t, &table_config_block)
  end
end

#table_for(*args, &block) ⇒ Object



31
32
33
# File 'lib/activeadmin_draggable/sortable_tree.rb', line 31

def table_for(*args, &block)
  insert_tag IndexSortableTableFor, *args, &block
end