class Voom::Presenters::DSL::Components::Lists::Line

Constants

CHECKBOX_ATTRIBUTES

Attributes

components[RW]
selectable[RW]
selected[RW]

Public Class Methods

new(**attribs_, &block) click to toggle source
# 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

Public Instance Methods

action(**attribs, &block)
Alias for: actions
actions(**attribs, &block) click to toggle source
# 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
Also aliased as: action
avatar(avatar = nil, **attribs, &block) click to toggle source
# 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
body(*text, **attribs, &block) click to toggle source
# 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
checkbox(**attributes, &block) click to toggle source
# File lib/voom/presenters/dsl/components/lists/line.rb, line 69
def checkbox(**attributes, &block)
  return @checkbox if locked?

  # Append [] if the list is selectable and the checkbox's name
  # doesn't already include brackets:
  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
hidden_field(**attributes, &block) click to toggle source
# 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
icon(icon=nil, **attribs, &block) click to toggle source
# 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
info(*text, **attribs, &block) click to toggle source
# 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
menu(**attributes, &block) click to toggle source
subtitle(*text, **attribs, &block) click to toggle source
# 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
text(*text, **attribs, &block) click to toggle source
# 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
Also aliased as: title
title(*text, **attribs, &block)
Alias for: text