Module: LotusAdmin::LinkHelpers

Defined in:
app/helpers/lotus_admin/link_helpers.rb

Instance Method Summary collapse

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


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
    (: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?
    (:li) { destroy_link(resource) }
  end
end


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
    (: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?
    (:li) { edit_link(resource) }
  end
end


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
    (: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?
    (: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


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
    (: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?
    (:li) { view_link(resource) }
  end
end