Class: Voom::Presenters::DSL::Components::Lists::Line
Direct Known Subclasses
Header
Constant Summary
collapse
- CHECKBOX_ATTRIBUTES =
%i[name value checked dirtyable value off_value].freeze
Instance Attribute Summary collapse
Attributes inherited from EventBase
#event_parent_id
#events
Attributes inherited from Base
#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type
Instance Method Summary
collapse
-
#actions(**attribs, &block) ⇒ Object
(also: #action)
-
#avatar(avatar = nil, **attribs, &block) ⇒ Object
-
#body(*text, **attribs, &block) ⇒ Object
-
#checkbox(**attributes, &block) ⇒ Object
-
#hidden_field(**attributes, &block) ⇒ Object
-
#icon(icon = nil, **attribs, &block) ⇒ Object
-
#info(*text, **attribs, &block) ⇒ Object
-
#initialize(**attribs_, &block) ⇒ Line
constructor
-
#menu(**attributes, &block) ⇒ Object
-
#subtitle(*text, **attribs, &block) ⇒ Object
-
#text(*text, **attribs, &block) ⇒ Object
(also: #title)
#dialog
#tooltip
#event
Methods inherited from Base
#expand!
Methods included from Pluggable
#include_plugins, #plugin, #plugin_module
#yield_to
Methods included from Serializer
#to_hash
Methods included from Lockable
#locked?
Constructor Details
permalink
#initialize(**attribs_, &block) ⇒ Line
Returns a new instance of Line.
[View source]
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 15
def initialize(**attribs_, &block)
super(type: :line, **attribs_, &block)
@selected = attribs.delete(:selected) {false}
@selectable = attribs.delete(:selectable) {false}
self.text(attribs.delete(:text), attribs) if attribs[:text]
self.subtitle(attribs.delete(:subtitle)) if attribs[:subtitle]
self.info(attribs.delete(:info)) if attribs[:info]
self.body(attribs.delete(:body)) if attribs[:body]
self.avatar(attribs.delete(:avatar)) if attribs.key?(:avatar)
self.icon(attribs.delete(:icon)) if attribs.key?(:icon)
if @selectable
self.checkbox(attribs.slice(*CHECKBOX_ATTRIBUTES))
elsif attribs.key?(:checkbox)
self.checkbox(attribs.delete(:checkbox))
end
@components = []
@actions = []
expand!
end
|
Instance Attribute Details
permalink
#components ⇒ Object
Returns the value of attribute components.
13
14
15
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 13
def components
@components
end
|
permalink
#selectable ⇒ Object
Returns the value of attribute selectable.
13
14
15
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 13
def selectable
@selectable
end
|
permalink
#selected ⇒ Object
Returns the value of attribute selected.
13
14
15
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 13
def selected
@selected
end
|
Instance Method Details
permalink
#actions(**attribs, &block) ⇒ Object
Also known as:
action
[View source]
94
95
96
97
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 94
def actions(**attribs, &block)
return @actions if locked?
Lists::Actions.new(@actions, parent: self, **attribs, &block)
end
|
permalink
#avatar(avatar = nil, **attribs, &block) ⇒ Object
[View source]
57
58
59
60
61
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 57
def avatar(avatar = nil, **attribs, &block)
return @avatar if locked?
@avatar = Avatar.new(parent: self, avatar: avatar,
**attribs, &block)
end
|
permalink
#body(*text, **attribs, &block) ⇒ Object
[View source]
52
53
54
55
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 52
def body(*text, **attribs, &block)
return @body if locked?
@body = Components::Typography.new(parent: self, type: :body, text: text, **attribs, &block)
end
|
permalink
#checkbox(**attributes, &block) ⇒ Object
[View source]
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 69
def checkbox(**attributes, &block)
return @checkbox if locked?
field_name = attributes.delete(:name).to_s
field_name += '[]' if @selectable && !field_name.include?('[')
@checkbox = Components::Checkbox.new(parent: self,
name: field_name,
**attributes,
&block)
end
|
permalink
#hidden_field(**attributes, &block) ⇒ Object
[View source]
83
84
85
86
87
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 83
def hidden_field(**attributes, &block)
return @hidden_field if locked?
@hidden_field = Components::HiddenField.new(parent: self, **attributes, &block)
end
|
permalink
#icon(icon = nil, **attribs, &block) ⇒ Object
[View source]
63
64
65
66
67
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 63
def icon(icon=nil, **attribs, &block)
return @icon if locked?
@icon = Icon.new(parent: self, icon: icon,
**attribs, &block)
end
|
permalink
#info(*text, **attribs, &block) ⇒ Object
[View source]
47
48
49
50
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 47
def info(*text, **attribs, &block)
return @info if locked?
@info = Components::Typography.new(parent: self, type: :info, text: text, **attribs, &block)
end
|
[View source]
89
90
91
92
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 89
def (**attributes, &block)
return @menu if locked?
@menu = Components::Menu.new(parent: self, **attributes, &block)
end
|
permalink
#subtitle(*text, **attribs, &block) ⇒ Object
[View source]
42
43
44
45
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 42
def subtitle(*text, **attribs, &block)
return @subtitle if locked?
@subtitle = Components::Typography.new(parent: self, type: :subtitle, text: text, **attribs, &block)
end
|
permalink
#text(*text, **attribs, &block) ⇒ Object
Also known as:
title
[View source]
36
37
38
39
|
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 36
def text(*text, **attribs, &block)
return @text if locked?
@text = Components::Typography.new(parent: self, type: :text, text: text, **attribs, &block)
end
|