Module: Elabs::LinksHelper
- Defined in:
- app/helpers/elabs/links_helper.rb
Instance Method Summary collapse
- #entity_nested_resource_url(entity, nested_type) ⇒ Object
- #namespace_destroy_link(namespace, singular_model, entity, confirm = true) ⇒ Object
- #namespace_edit_link(namespace, singular_model, entity) ⇒ Object
- #namespace_show_link(namespace, singular_model, entity) ⇒ Object
- #related_content_show_all_link(amount, link) ⇒ Object
- #show_online_link(entity) ⇒ Object
Instance Method Details
#entity_nested_resource_url(entity, nested_type) ⇒ Object
45 46 47 48 |
# File 'app/helpers/elabs/links_helper.rb', line 45 def entity_nested_resource_url(entity, nested_type) entity_type = singular_type_name entity send "#{entity_type}_#{nested_type}_url", entity end |
#namespace_destroy_link(namespace, singular_model, entity, confirm = true) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/elabs/links_helper.rb', line 33 def namespace_destroy_link(namespace, singular_model, entity, confirm = true) link_params = { title: _('Destroy'), method: :delete, class: 'btn btn--small btn--destroy' } link_params[:data] = { confirm: _('Are you sure?') } if confirm link_to send("#{namespace}_#{singular_model}_path".to_sym, entity), link_params do icon('trash', ['fw']) end end |
#namespace_edit_link(namespace, singular_model, entity) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/helpers/elabs/links_helper.rb', line 25 def namespace_edit_link(namespace, singular_model, entity) link_to send("edit_#{namespace}_#{singular_model}_path", entity), title: _('Edit'), class: 'btn btn--small btn--edit' do icon('pencil-alt', ['fw']) end end |
#namespace_show_link(namespace, singular_model, entity) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/helpers/elabs/links_helper.rb', line 17 def namespace_show_link(namespace, singular_model, entity) link_to send("#{namespace}_#{singular_model}_path", entity), title: _('View'), class: 'btn btn--small btn--warning' do icon('eye', ['fw']) end end |
#related_content_show_all_link(amount, link) ⇒ Object
50 51 52 53 54 55 56 |
# File 'app/helpers/elabs/links_helper.rb', line 50 def (amount, link) if amount.positive? link_to(_('Show all'), link, class: 'btn btn--small btn--link btn--primary') else content_tag('a', _('Show all'), disabled: true, class: 'btn btn--small btn--link') end end |
#show_online_link(entity) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/elabs/links_helper.rb', line 3 def show_online_link(entity) = { title: _('View online'), class: 'btn btn--small btn--show' } if entity.respond_to?(:publicly_visible?) && !entity.publicly_visible? [:disabled] = true return content_tag 'a', icon('eye', ['fw']), end link_to entity, do icon('eye', ['fw']) end end |