Class: TaoUi::Components::Tree::ItemComponent

Inherits:
TaoOnRails::Components::Base
  • Object
show all
Defined in:
lib/tao_ui/components/tree/item_component.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, item, options = {}) ⇒ ItemComponent

Returns a new instance of ItemComponent.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tao_ui/components/tree/item_component.rb', line 9

def initialize view, item, options = {}
  super view, options
  @item = item
  @children_key = @options.delete(:children_key)
  @selectable = @options[:selectable] || false
  @depth = @options[:depth]

  init_remote
  init_children
  init_expanded
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def children
  @children
end

#children_keyObject (readonly)

Returns the value of attribute children_key.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def children_key
  @children_key
end

#depthObject (readonly)

Returns the value of attribute depth.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def depth
  @depth
end

#expandableObject (readonly)

Returns the value of attribute expandable.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def expandable
  @expandable
end

#expandedObject (readonly)

Returns the value of attribute expanded.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def expanded
  @expanded
end

#itemObject (readonly)

Returns the value of attribute item.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def item
  @item
end

#remoteObject (readonly)

Returns the value of attribute remote.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def remote
  @remote
end

#selectableObject (readonly)

Returns the value of attribute selectable.



6
7
8
# File 'lib/tao_ui/components/tree/item_component.rb', line 6

def selectable
  @selectable
end

Class Method Details

.component_nameObject



33
34
35
# File 'lib/tao_ui/components/tree/item_component.rb', line 33

def self.component_name
  :tree_item
end

Instance Method Details

#render(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tao_ui/components/tree/item_component.rb', line 21

def render &block
  view. tag_name, html_options do
    content = view. 'div', class: 'tao-tree-item-content' do
      render_padding + render_icon +
        render_checkbox + view.capture(item, self, &block)
    end

    children = render_children &block
    content + children
  end
end