Class: TaoUi::Components::Table::RowBuilder

Inherits:
BaseBuilder
  • Object
show all
Defined in:
lib/tao_ui/components/table/row_builder.rb

Instance Attribute Summary

Attributes inherited from BaseBuilder

#expandable, #options, #selectable, #view

Instance Method Summary collapse

Methods inherited from BaseBuilder

#merge_options

Constructor Details

#initialize(view, options = {}) ⇒ RowBuilder

Returns a new instance of RowBuilder.



7
8
9
10
# File 'lib/tao_ui/components/table/row_builder.rb', line 7

def initialize view, options = {}
  super
  reset_cell_count
end

Instance Method Details

#cell(content_or_options = nil, cell_options = nil, &block) ⇒ Object



12
13
14
15
# File 'lib/tao_ui/components/table/row_builder.rb', line 12

def cell content_or_options = nil, cell_options = nil, &block
  @cell_count += 1
  view. 'td', content_or_options, cell_options, &block
end

#content(content_options = {}, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/tao_ui/components/table/row_builder.rb', line 17

def content content_options = {}, &block
  raise 'content method requires expandable option set to true' unless expandable
  content_options = merge_options({
    class: 'expandable'
  }, content_options)
  row_content = view.capture(self, &block)
  row_content = selectable_td + row_content if selectable
  row_content = expandable_td + row_content if expandable
  view. 'tr', row_content, content_options
end

#panel(panel_options = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/tao_ui/components/table/row_builder.rb', line 28

def panel panel_options = {}, &block
  raise 'panel method requires expandable option set to true' unless expandable
  view. 'tr', class: 'expandable-panel' do
    view. 'td', colspan: @cell_count do
      view. 'div', panel_options, &block
    end
  end
end

#reset_cell_countObject



37
38
39
40
41
# File 'lib/tao_ui/components/table/row_builder.rb', line 37

def reset_cell_count
  @cell_count = 0
  @cell_count += 1 if selectable
  @cell_count += 1 if expandable
end