Module: LinksHelper
- Includes:
- Jabysoft::AuthorisationService
- 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
Methods included from Jabysoft::AuthorisationService
Instance Method Details
#link_to_back(url, html_options = {}) ⇒ Object
57 58 59 60 |
# File 'app/helpers/links_helper.rb', line 57 def link_to_back(url, = {}) .reverse_merge!(class: 'btn btn-default btn-lg') 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 54 55 |
# File 'app/helpers/links_helper.rb', line 42 def link_to_destroy(model, url, = {}) style = 'btn btn-danger glyphicon glyphicon-trash' resource_id = [:resource_id].presence .reverse_merge!({"data-target" => "#delete-confirmation#{resource_id}", "data-toggle" => "modal"}) (:destroy, model: model, style: style, options: ) do || 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 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, = {}) (:update, model: model, style: 'btn btn-default glyphicon glyphicon-pencil', options: ) do || if link_to '', url, else content_tag(:div, class: 'tooltip-wrapper', "data-title" => I18n.t('not_authorized')) do link_to t('edit'), url, end end end end |
#link_to_menu(model, url) ⇒ Object
62 63 64 |
# File 'app/helpers/links_helper.rb', line 62 def (model, url) link_to model.model_name.human.pluralize, url end |
#link_to_new(model, url, html_options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/links_helper.rb', line 4 def link_to_new(model, url, = {}) (:create, model: model, style: 'btn btn-primary btn-lg', options: ) do || 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 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, = {}) style = 'btn btn-default glyphicon glyphicon-zoom-in' (:show, model: model, style: style, options: ) do || if link_to '', url, else content_tag(:div, class: 'tooltip-wrapper', "data-title" => I18n.t('not_authorized')) do link_to t('show'), url, end end end end |
#submit_button(form, value = nil) ⇒ Object
74 75 76 77 78 79 80 |
# File 'app/helpers/links_helper.rb', line 74 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
66 67 68 69 70 71 72 |
# File 'app/helpers/links_helper.rb', line 66 def (form, edit_path, is_edition) if is_edition && params[:action] != 'new' link_to_edit form.object, edit_path, class: "btn btn-primary glyphicon glyphicon-pencil" else (form) end end |