Class: Voom::Presenters::DSL::Components::List

Inherits:
Base
  • Object
show all
Includes:
Mixins::Append, Mixins::Attaches, Mixins::Content, Mixins::Event
Defined in:
lib/voom/presenters/dsl/components/list.rb

Instance Attribute Summary collapse

Attributes included from Mixins::Event

#events

Attributes inherited from Base

#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type

Instance Method Summary collapse

Methods included from Mixins::Event

#event

Methods included from Mixins::Attaches

#attach

Methods included from Namespace

#_expand_namespace_

Methods included from Mixins::Append

#<<, #yield_to

Methods included from Mixins::Content

#content

Methods inherited from Base

#expand!

Methods included from Pluggable

#include_plugins, #plugin, #plugin_module

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

#initialize(**attribs_, &block) ⇒ List

Returns a new instance of List.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/voom/presenters/dsl/components/list.rb', line 14

def initialize(**attribs_, &block)
  super(type: :list, **attribs_, &block)
  @color  = attribs.delete(:color) { nil }
  @border = attribs.delete(:border) { nil }

  @lines_only = attribs.delete(:lines_only) { false }
  @selectable = attribs.delete(:selectable) { false }
  @dense = attribs.delete(:dense) { false }
  @lines = []
  @components = []
  @total_lines = attribs.delete(:total_lines) || 0
  add_select_control!( attribs.fetch(:select_control_label) { 'Select All' } )
  expand!
end

Instance Attribute Details

#borderObject (readonly)

Returns the value of attribute border.



11
12
13
# File 'lib/voom/presenters/dsl/components/list.rb', line 11

def border
  @border
end

#colorObject (readonly)

Returns the value of attribute color.



11
12
13
# File 'lib/voom/presenters/dsl/components/list.rb', line 11

def color
  @color
end

#componentsObject

Returns the value of attribute components.



12
13
14
# File 'lib/voom/presenters/dsl/components/list.rb', line 12

def components
  @components
end

#denseObject (readonly)

Returns the value of attribute dense.



11
12
13
# File 'lib/voom/presenters/dsl/components/list.rb', line 11

def dense
  @dense
end

#linesObject (readonly)

Returns the value of attribute lines.



11
12
13
# File 'lib/voom/presenters/dsl/components/list.rb', line 11

def lines
  @lines
end

#lines_onlyObject (readonly)

Returns the value of attribute lines_only.



11
12
13
# File 'lib/voom/presenters/dsl/components/list.rb', line 11

def lines_only
  @lines_only
end

#selectableObject (readonly)

Returns the value of attribute selectable.



11
12
13
# File 'lib/voom/presenters/dsl/components/list.rb', line 11

def selectable
  @selectable
end

#total_linesObject (readonly)

Returns the value of attribute total_lines.



11
12
13
# File 'lib/voom/presenters/dsl/components/list.rb', line 11

def total_lines
  @total_lines
end

Instance Method Details

#add_select_control!(text) ⇒ Object



29
30
31
32
33
34
# File 'lib/voom/presenters/dsl/components/list.rb', line 29

def add_select_control!(text)
  return unless @selectable && !@lines_only
  @lines << Lists::Header.new(parent: self,
                              total_lines: @total_lines,
                              checkbox: {text: text, dirtyable: false})
end

#line(text = nil, **attribs, &block) ⇒ Object



36
37
38
# File 'lib/voom/presenters/dsl/components/list.rb', line 36

def line(text=nil, **attribs, &block)
  @lines << Lists::Line.new(parent:self, text: text, selectable: selectable, **attribs, &block)
end

#separator(**attribs, &block) ⇒ Object



40
41
42
# File 'lib/voom/presenters/dsl/components/list.rb', line 40

def separator(**attribs, &block)
  @lines << Lists::Separator.new(parent:self, **attribs, &block)
end