Module: Interage::CocoonHelper

Included in:
ApplicationHelper
Defined in:
lib/interage/cocoon_helper.rb

Constant Summary collapse

DEFAULT_BTN_CLASS =
'btn btn-sm btn-outline-'

Instance Method Summary collapse

Instance Method Details

#cocoon_default_btn_class(type) ⇒ Object



27
28
29
30
31
32
# File 'lib/interage/cocoon_helper.rb', line 27

def cocoon_default_btn_class(type)
  default_btn_class =
    ENV.fetch('DEFAULT_COCOON_BTN_CLASS', DEFAULT_BTN_CLASS)

  "#{default_btn_class}#{type} text-truncate"
end


7
8
9
10
11
12
13
14
# File 'lib/interage/cocoon_helper.rb', line 7

def cocoon_link_to_add_association(form, association, options = {})
  label = options[:label] || t('buttons.cocoon.add.text')
  html_class = options[:html_class] || cocoon_default_btn_class('success')

  link_to_add_association(form, association, class: html_class) do
    app_icon_text(t('buttons.cocoon.add.icon'), label)
  end
end


16
17
18
19
20
21
22
23
24
25
# File 'lib/interage/cocoon_helper.rb', line 16

def cocoon_link_to_remove_association(form, label = nil)
  label ||= t('buttons.cocoon.remove.text')
  html_class = cocoon_default_btn_class('danger')

   :div, class: 'cocoon-link-to-remove' do
    link_to_remove_association(form, class: html_class, title: label) do
      app_icon_text(t('buttons.cocoon.remove.icon'), label)
    end
  end
end