Class: Layered::Ui::ModalHelper::ModalBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/layered/ui/modal_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, title:, id:, heading_level: :h3) ⇒ ModalBuilder

Returns a new instance of ModalBuilder.



57
58
59
60
61
62
# File 'app/helpers/layered/ui/modal_helper.rb', line 57

def initialize(view, title:, id:, heading_level: :h3)
  @view = view
  @title = title
  @id = id
  @heading_level = heading_level
end

Instance Attribute Details

#heading_levelObject (readonly)

Returns the value of attribute heading_level.



55
56
57
# File 'app/helpers/layered/ui/modal_helper.rb', line 55

def heading_level
  @heading_level
end

#idObject (readonly)

Returns the value of attribute id.



55
56
57
# File 'app/helpers/layered/ui/modal_helper.rb', line 55

def id
  @id
end

#titleObject (readonly)

Returns the value of attribute title.



55
56
57
# File 'app/helpers/layered/ui/modal_helper.rb', line 55

def title
  @title
end

#trigger_htmlObject (readonly)

Returns the value of attribute trigger_html.



55
56
57
# File 'app/helpers/layered/ui/modal_helper.rb', line 55

def trigger_html
  @trigger_html
end

Instance Method Details

#trigger(**options, &block) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
# File 'app/helpers/layered/ui/modal_helper.rb', line 64

def trigger(**options, &block)
  options = options.deep_dup
  options[:type] ||= "button"
  data = options[:data] || {}
  existing_action = data.delete(:action) || data.delete("action")
  data[:action] = [existing_action, "l-ui--modal#open"].compact.reject(&:empty?).join(" ")
  options[:data] = data
  content = @view.capture(&block)
  @trigger_html = @view.tag.button(content, **options)
  nil
end