Module: LinksHelper
- Defined in:
- app/helpers/links_helper.rb
Instance Method Summary collapse
- #link_to_back(url, html_options = {}) ⇒ Object
- #link_to_destroy(model, url, html_options = {}) ⇒ Object
- #link_to_edit(model, url, html_options = {}) ⇒ Object
- #link_to_menu(model, url) ⇒ Object
- #link_to_new(model, url, html_options = {}) ⇒ Object
- #link_to_show(model, url, html_options = {}) ⇒ Object
- #submit_button(form, value = nil) ⇒ Object
- #submit_or_edit_button(form, edit_path, is_edition) ⇒ Object
Instance Method Details
#link_to_back(url, html_options = {}) ⇒ Object
55 56 57 58 |
# File 'app/helpers/links_helper.rb', line 55 def link_to_back(url, = {}) .reverse_merge!(class: 'btn btn-default') link_to t('back'), url, end |
#link_to_destroy(model, url, html_options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/links_helper.rb', line 42 def link_to_destroy(model, url, = {}) = 'btn btn-danger glyphicon glyphicon-trash' .reverse_merge!({class: , "data-target" => "#delete-confirmation", "data-toggle" => "modal"}) = :destroy, model, , if model.present? if link_to '', url, else content_tag(:div, class: 'tooltip-wrapper', "data-title" => I18n.t('not_authorized')) do link_to t('destroy'), url, end end end |
#link_to_edit(model, url, html_options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/links_helper.rb', line 16 def link_to_edit(model, url, = {}) = 'btn btn-default btn-sm' .reverse_merge!(class: ) = :update, model, , if model.present? if link_to t('edit'), url, else content_tag(:div, class: 'tooltip-wrapper', "data-title" => I18n.t('not_authorized')) do link_to t('edit'), url, end end end |
#link_to_menu(model, url) ⇒ Object
60 61 62 |
# File 'app/helpers/links_helper.rb', line 60 def (model, url) link_to model.model_name.human.pluralize, url end |
#link_to_new(model, url, html_options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/links_helper.rb', line 3 def link_to_new(model, url, = {}) = 'btn btn-default btn-lg' .reverse_merge!(class: ) = :create, model, , if model.present? if link_to t('new', model: model.model_name.human), url, else content_tag(:div, class: 'tooltip-wrapper', "data-title" => I18n.t('not_authorized')) do link_to t('new', model: model.model_name.human), url, end end end |
#link_to_show(model, url, html_options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/links_helper.rb', line 29 def link_to_show(model, url, = {}) = 'btn btn-default btn-sm' .reverse_merge!(class: ) = :read, model, , if model.present? if link_to t('show'), url, else content_tag(:div, class: 'tooltip-wrapper', "data-title" => I18n.t('not_authorized')) do link_to t('show'), url, end end end |
#submit_button(form, value = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'app/helpers/links_helper.rb', line 72 def (form, value = nil) if value form.submit value, class: "btn btn-primary btn-lg" else form.submit t('save'), class: "btn btn-primary btn-lg" end end |
#submit_or_edit_button(form, edit_path, is_edition) ⇒ Object
64 65 66 67 68 69 70 |
# File 'app/helpers/links_helper.rb', line 64 def (form, edit_path, is_edition) if is_edition && params[:action] != 'new' link_to_edit form.object, edit_path, class: "btn btn-primary btn-lg" else (form) end end |