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?'- NEW_BUTTON_CLASS =
'btn text-truncate btn-outline-application'
Instance Method Summary collapse
- #aside_link_to(*args, &block) ⇒ Object
- #button_class(type, addicional_class = nil) ⇒ Object
- #destroy_confirm_message ⇒ Object
- #link_to_back(url) ⇒ Object
- #link_to_default(type, url, html_options = {}) ⇒ Object
- #link_to_destroy(url, html_options = {}) ⇒ Object
- #link_to_edit(url) ⇒ Object
- #link_to_modal(text, url = '#', html_options = {}) ⇒ Object
- #link_to_new(resource, url) ⇒ Object
- #link_to_show(url) ⇒ Object
Instance Method Details
#aside_link_to(*args, &block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/interage/link_to_helper.rb', line 10 def aside_link_to(*args, &block) = args.last.is_a?(Hash) ? args.pop : {} [:class] = "#{ASIDE_DEFAULT_CLASS} #{options[:class]}" [:title] = (args.first) if block.blank? args.push() link_to(*args, &block) end |
#button_class(type, addicional_class = nil) ⇒ Object
59 60 61 |
# File 'lib/interage/link_to_helper.rb', line 59 def (type, addicional_class = nil) "#{PREFIX_BUTTON_CLASS}#{type} #{addicional_class}" end |
#destroy_confirm_message ⇒ Object
63 64 65 |
# File 'lib/interage/link_to_helper.rb', line 63 def t('application.destroy_confirm_message', default: DESTROY_CONFIRM_MESSAGE) end |
#link_to_back(url) ⇒ Object
35 36 37 |
# File 'lib/interage/link_to_helper.rb', line 35 def link_to_back(url) link_to_default(:back, url, class: ('secondary')) end |
#link_to_default(type, url, html_options = {}) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/interage/link_to_helper.rb', line 51 def link_to_default(type, url, = {}) text = t("menu.links.#{type}") = .merge(title: (text), data: { tooltip: 'top' }) link_to(app_icon_text(t("menu.icons.#{type}"), text), url, ) end |
#link_to_destroy(url, html_options = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/interage/link_to_helper.rb', line 43 def link_to_destroy(url, = {}) .merge!(method: :delete, 'data-confirm' => , class: ('danger', [:class])) link_to_default(:destroy, url, ) end |
#link_to_edit(url) ⇒ Object
31 32 33 |
# File 'lib/interage/link_to_helper.rb', line 31 def link_to_edit(url) link_to_default(:edit, url, class: ('info')) end |
#link_to_modal(text, url = '#', html_options = {}) ⇒ Object
19 20 21 |
# File 'lib/interage/link_to_helper.rb', line 19 def link_to_modal(text, url = '#', = {}) link_to text, url, .merge('data-toggle': 'modal') end |
#link_to_new(resource, url) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/interage/link_to_helper.rb', line 23 def link_to_new(resource, url) text = t('menu.links.new', model: tm(resource).downcase) link_to url, title: (text), class: NEW_BUTTON_CLASS do app_icon_text(t('menu.icons.new'), text) end end |
#link_to_show(url) ⇒ Object
39 40 41 |
# File 'lib/interage/link_to_helper.rb', line 39 def link_to_show(url) link_to_default(:show, url, class: ('dark')) end |