Class: ActiveAdmin::Views::IndexAsTree

Inherits:
Component
  • Object
show all
Defined in:
app/models/active_admin/views/index_as_tree.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.index_nameObject



25
26
27
# File 'app/models/active_admin/views/index_as_tree.rb', line 25

def self.index_name
  "Tree"
end

Instance Method Details

#build(page_presenter, collection) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/active_admin/views/index_as_tree.rb', line 5

def build(page_presenter, collection)
  @collection = collection
  @origin_ids_to_display = @collection.map(&:id)
  instance_exec &page_presenter.block if page_presenter.block

  # Get Root Elements to display
  @root_elements = @collection.map(&:root).uniq

  # Get all Element IDs and their parent_ids (path_ids) to display
  @items_to_display = @collection.map(&:path_ids).flatten.uniq

  # Start With root elements and display all children
  # which ar in @items_to_display
  @root_elements.each do |item|
    ul :class=> "item_tree" do
      show_subtree_of_item(item)
    end
  end
end

#options(methods = []) ⇒ Object

Setter method for the configuration of the title

possible values in array: [:preview, :view, :edit, :new, :destroy]



48
49
50
51
# File 'app/models/active_admin/views/index_as_tree.rb', line 48

def options(methods = [])
  @options = methods
  @options
end

#title(method = nil, &block) ⇒ Object

Setter method for the configuration of the title



30
31
32
33
34
35
# File 'app/models/active_admin/views/index_as_tree.rb', line 30

def title(method = nil, &block)
  if block_given? || method
    @title = block_given? ? block : method
  end
  @title
end

#value(method = nil, &block) ⇒ Object

Setter method for the configuration of optional value



38
39
40
41
42
43
# File 'app/models/active_admin/views/index_as_tree.rb', line 38

def value(method = nil, &block)
  if block_given? || method
    @value = block_given? ? block : method
  end
  @value
end