Module: FluxBase::BulmaHelpers
- Defined in:
- app/helpers/flux_base/bulma_helpers.rb
Instance Method Summary collapse
-
#actions_fieldset(title = '') ⇒ Object
Add controls in the block passed to this method.
-
#create_message(title, options = {}) ⇒ Object
Creates a Bulma message with the given title and options.
- #display_alert ⇒ Object
-
#display_errors(record) ⇒ Object
Replaces the auto-generated errors div for record forms.
- #display_notice ⇒ Object
Instance Method Details
#actions_fieldset(title = '') ⇒ Object
Add controls in the block passed to this method.
6 7 8 9 10 11 12 |
# File 'app/helpers/flux_base/bulma_helpers.rb', line 6 def actions_fieldset(title = '') field_set_tag(title) do content_tag(:div, class: 'field has-addons') do yield end end.concat(tag(:hr)) end |
#create_message(title, options = {}) ⇒ Object
Creates a Bulma message with the given title and options. Use a block to define the message body.
45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/flux_base/bulma_helpers.rb', line 45 def (title, = {}) content_tag(:article, class: 'message ' + .delete(:class), **) do header = content_tag(:div, title, class: 'message-header') body = content_tag(:div, class: 'message-body') do yield end header.concat(body) end end |
#display_alert ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/helpers/flux_base/bulma_helpers.rb', line 22 def display_alert return unless alert.present? content_tag(:div, class: 'notification is-danger') do alert end end |
#display_errors(record) ⇒ Object
Replaces the auto-generated errors div for record forms.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/helpers/flux_base/bulma_helpers.rb', line 31 def display_errors(record) return unless record.errors.any? title = "#{pluralize(record.errors.count, 'error')} prohibited this #{record.class.name.downcase} from being saved:" (title, class: 'is-danger') do content_tag(:ul) do record.errors..map do |msg| content_tag(:li, msg) end.inject(&:concat) end end end |
#display_notice ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/helpers/flux_base/bulma_helpers.rb', line 14 def display_notice return unless notice.present? content_tag(:div, class: 'notification is-info') do notice end end |