Class: TinyAdmin::Views::Components::Flash

Inherits:
BasicComponent
  • Object
show all
Defined in:
lib/tiny_admin/views/components/flash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasicComponent

#update_attributes

Instance Attribute Details

#messagesObject

Returns the value of attribute messages.



7
8
9
# File 'lib/tiny_admin/views/components/flash.rb', line 7

def messages
  @messages
end

Instance Method Details

#view_templateObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tiny_admin/views/components/flash.rb', line 9

def view_template
  @messages ||= {}
  notices = messages[:notices]
  warnings = messages[:warnings]
  errors = messages[:errors]

  div(class: 'flash') {
    div(class: 'notices alert alert-success', role: 'alert') { notices.join(', ') } if notices&.any?
    div(class: 'notices alert alert-warning', role: 'alert') { warnings.join(', ') } if warnings&.any?
    div(class: 'notices alert alert-danger', role: 'alert') { errors.join(', ') } if errors&.any?
  }
end