Class: Para::Markup::ResourceTree
Instance Attribute Summary
Attributes inherited from Component
#view
Instance Method Summary
collapse
Methods inherited from Component
#initialize
Instance Method Details
#node_children(children, &block) ⇒ Object
31
32
33
|
# File 'lib/para/markup/resources_tree.rb', line 31
def node_children(children, &block)
tree_list(children, &block) if children.length > 0
end
|
#node_row(resource, label) ⇒ Object
25
26
27
28
29
|
# File 'lib/para/markup/resources_tree.rb', line 25
def node_row(resource, label)
content_tag(:div, class: 'node-row') do
label
end
end
|
#tree_list(resources, options = {}, &block) ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/para/markup/resources_tree.rb', line 4
def tree_list(resources, options = {}, &block)
options[:class] ||= ''
options[:class] << ' tree-list'
content_tag(:ul, options) do
resources.each do |resource|
block.call(resource)
end
end
end
|
#tree_node(resource: nil, label: nil, children: [], **options, &block) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/para/markup/resources_tree.rb', line 15
def tree_node(resource: nil, label: nil, children: [], **options, &block)
options[:class] ||= ''
options[:class] << ' node'
content_tag(:li, options) do
node_row(resource, label) +
node_children(children, &block)
end
end
|