Module: Interage::LinkToHelper

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

Constant Summary collapse

ASIDE_DEFAULT_CLASS =
'list-group-item'
PREFIX_BUTTON_CLASS =
'btn btn-sm btn-outline-'
DESTROY_CONFIRM_MESSAGE =
'Tem certeza que deseja apagar?'

Instance Method Summary collapse

Instance Method Details



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

def aside_link_to(text, url = '#', html_options = {})
  html_options[:class] = "#{ASIDE_DEFAULT_CLASS} #{html_options[:class]}"
  html_options[:title] = strip_tags(text)

  link_to text, url, html_options
end

#button_class(type, addicional_class = nil) ⇒ Object



56
57
58
# File 'lib/interage/link_to_helper.rb', line 56

def button_class(type, addicional_class = nil)
  "#{PREFIX_BUTTON_CLASS}#{type} #{addicional_class}"
end

#destroy_confirm_messageObject



60
61
62
# File 'lib/interage/link_to_helper.rb', line 60

def destroy_confirm_message
  t('application.destroy_confirm_message', default: DESTROY_CONFIRM_MESSAGE)
end


32
33
34
# File 'lib/interage/link_to_helper.rb', line 32

def link_to_back(url)
  link_to_default(:back, url, class: button_class('secondary'))
end


48
49
50
51
52
53
54
# File 'lib/interage/link_to_helper.rb', line 48

def link_to_default(type, url, html_options = {})
  text = t("menu.links.#{type}")
  html_options = html_options.merge(title: strip_tags(text),
                                    data: { tooltip: 'top' })

  link_to(app_icon_text(t("menu.icons.#{type}"), text), url, html_options)
end


40
41
42
43
44
45
46
# File 'lib/interage/link_to_helper.rb', line 40

def link_to_destroy(url, html_options = {})
  html_options.merge!(method: :delete,
                      'data-confirm' => destroy_confirm_message,
                      class: button_class('danger', html_options[:class]))

  link_to_default(:destroy, url, html_options)
end


28
29
30
# File 'lib/interage/link_to_helper.rb', line 28

def link_to_edit(url)
  link_to_default(:edit, url, class: button_class('info'))
end


16
17
18
# File 'lib/interage/link_to_helper.rb', line 16

def link_to_modal(text, url = '#', html_options = {})
  link_to text, url, html_options.merge('data-toggle': 'modal')
end


20
21
22
23
24
25
26
# File 'lib/interage/link_to_helper.rb', line 20

def link_to_new(resource, url)
  text = t('menu.links.new', model: tm(resource).downcase)

  link_to url, title: strip_tags(text), class: 'btn btn-outline-primary' do
    app_icon_text(t('menu.icons.new'), text)
  end
end


36
37
38
# File 'lib/interage/link_to_helper.rb', line 36

def link_to_show(url)
  link_to_default(:show, url, class: button_class('dark'))
end