Module: LotusAdmin::LinkHelpers
- Defined in:
- app/helpers/lotus_admin/link_helpers.rb
Instance Method Summary collapse
- #default_table_actions_column(resource) ⇒ Object
- #destroy_link(resource) ⇒ Object
- #destroy_resource_item(resource) ⇒ Object
- #edit_link(resource) ⇒ Object
- #edit_resource_item(resource) ⇒ Object
- #new_link(parent = nil) ⇒ Object
- #new_resource_item(parent = nil) ⇒ Object
- #undecorated(resource) ⇒ Object
- #view_link(resource) ⇒ Object
- #view_resource_item(resource) ⇒ Object
Instance Method Details
#default_table_actions_column(resource) ⇒ Object
3 4 5 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 3 def default_table_actions_column(resource) render 'lotus_admin/shared/table/actions', resource: resource end |
#destroy_link(resource) ⇒ Object
53 54 55 56 57 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 53 def destroy_link(resource) link_to lotus_admin.polymorphic_path(undecorated(resource)), title: 'Delete', data: { method: :delete, confirm: "Are you sure you want to remove this #{ resource.model_name.human }?" } do content_tag(:i, nil, class: 'zmdi zmdi-delete') end end |
#destroy_resource_item(resource) ⇒ Object
29 30 31 32 33 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 29 def destroy_resource_item(resource) if policy(resource).destroy? content_tag(:li) { destroy_link(resource) } end end |
#edit_link(resource) ⇒ Object
47 48 49 50 51 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 47 def edit_link(resource) link_to lotus_admin.edit_polymorphic_path(undecorated(resource)), title: 'Edit' do content_tag(:i, nil, class: 'zmdi zmdi-edit') end end |
#edit_resource_item(resource) ⇒ Object
23 24 25 26 27 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 23 def edit_resource_item(resource) if policy(resource).edit? content_tag(:li) { edit_link(resource) } end end |
#new_link(parent = nil) ⇒ Object
41 42 43 44 45 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 41 def new_link(parent = nil) link_to lotus_admin.new_polymorphic_path([parent, resource_class].compact), title: 'New' do content_tag(:i, nil, class: 'zmdi zmdi-plus-circle') end end |
#new_resource_item(parent = nil) ⇒ Object
17 18 19 20 21 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 17 def new_resource_item(parent = nil) if policy(resource_class).new? content_tag(:li) { new_link(parent) } end end |
#undecorated(resource) ⇒ Object
7 8 9 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 7 def undecorated(resource) resource.try(:object).presence || resource end |
#view_link(resource) ⇒ Object
35 36 37 38 39 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 35 def view_link(resource) link_to lotus_admin.polymorphic_path(undecorated(resource)), title: 'View Details' do content_tag(:i, nil, class: 'zmdi zmdi-eye') end end |
#view_resource_item(resource) ⇒ Object
11 12 13 14 15 |
# File 'app/helpers/lotus_admin/link_helpers.rb', line 11 def view_resource_item(resource) if policy(resource).show? content_tag(:li) { view_link(resource) } end end |