Module: CoreDropdownHelper

Defined in:
app/helpers/core_dropdown_helper.rb

Overview

Helpful methods rendering tables

Instance Method Summary collapse

Instance Method Details

#cancel_dropdown_item(obj, path, confirm: 'Are you sure?', method: :delete) ⇒ Object



72
73
74
75
76
# File 'app/helpers/core_dropdown_helper.rb', line 72

def cancel_dropdown_item(obj, path, confirm: 'Are you sure?', method: :delete)
  return unless can? :edit, obj

  dropdown_item(path, 'close-circle', 'Cancel', method: method, confirm: confirm, classes: %w(text-danger))
end

#current_job_dropdown_item(obj, path) ⇒ Object



54
55
56
57
58
# File 'app/helpers/core_dropdown_helper.rb', line 54

def current_job_dropdown_item(obj, path)
  return unless can? :view, obj

  dropdown_item(path, 'hourglass-2', 'Current Job')
end

#dashboard_dropdown_item(obj, path, name: 'Show') ⇒ Object



42
43
44
45
46
# File 'app/helpers/core_dropdown_helper.rb', line 42

def dashboard_dropdown_item(obj, path, name: 'Show')
  return unless can? :view, obj

  dropdown_item(path, 'dashboard', name)
end

#delete_dropdown_item(obj, path) ⇒ Object



66
67
68
69
70
# File 'app/helpers/core_dropdown_helper.rb', line 66

def delete_dropdown_item(obj, path)
  return unless can? :delete, obj

  dropdown_item(path, 'delete-bin', 'Delete', method: :delete, confirm: 'are you sure?')
end

#demote_dropdown_item(obj, path) ⇒ Object



30
31
32
33
34
# File 'app/helpers/core_dropdown_helper.rb', line 30

def demote_dropdown_item(obj, path)
  return unless can? :edit, obj

  dropdown_item(path, 'thumb-down', 'Demote')
end


20
21
22
23
24
25
26
27
28
# File 'app/helpers/core_dropdown_helper.rb', line 20

def dropdown_item(path, icon_name, action_name, method: :get, confirm: nil, classes: [])
  data = { method: method }
  data[:confirm] = confirm if confirm.present?
  classes << 'dropdown-item'
  (:a, class: classes.join(' '), href: path, data: data) do
    concat(menu_remix_icon(icon_name))
    concat(action_name)
  end
end
This method is abstract.

Drop down menu for actions



8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/core_dropdown_helper.rb', line 8

def dropdown_menu(&block)
  (:div, class: 'dropdown') do
    concat((:button,
                       class: 'btn p-0 dropdown-toggle hide-arrow',
                       type: :button,
                       data: { 'bs-toggle': :dropdown }) do
      concat(remix_icon('more-2'))
    end)
    concat((:div, class: 'dropdown-menu') { yield block })
  end
end

#edit_dropdown_item(obj, path) ⇒ Object



60
61
62
63
64
# File 'app/helpers/core_dropdown_helper.rb', line 60

def edit_dropdown_item(obj, path)
  return unless can? :edit, obj

  dropdown_item(path, 'pencil', 'Edit')
end

#info_dropdown_item(obj, path, name: 'Info') ⇒ Object



36
37
38
39
40
# File 'app/helpers/core_dropdown_helper.rb', line 36

def info_dropdown_item(obj, path, name: 'Info')
  return unless can? :view, obj

  dropdown_item(path, 'information', name)
end

#jobs_dropdown_item(obj, path, name: 'Jobs') ⇒ Object



48
49
50
51
52
# File 'app/helpers/core_dropdown_helper.rb', line 48

def jobs_dropdown_item(obj, path, name: 'Jobs')
  return unless can? :view, obj

  dropdown_item(path, 'file-list', name)
end

#replay_dropdown_item(obj, path, confirm: nil, title: 'Replay') ⇒ Object



84
85
86
87
88
# File 'app/helpers/core_dropdown_helper.rb', line 84

def replay_dropdown_item(obj, path, confirm: nil, title: 'Replay')
  return unless can? :read, obj

  dropdown_item(path, 'reset-left', title, confirm: confirm)
end

#run_dropdown_item(obj, path, method: :get, title: 'Run') ⇒ Object



78
79
80
81
82
# File 'app/helpers/core_dropdown_helper.rb', line 78

def run_dropdown_item(obj, path, method: :get, title: 'Run')
  return unless can? :read, obj

  dropdown_item(path, 'run', title, method: method)
end