Module: CoreTableActionHelper

Defined in:
app/helpers/core_table_action_helper.rb

Instance Method Summary collapse

Instance Method Details

#table_action_archive_tag(record, path, options = {}) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'app/helpers/core_table_action_helper.rb', line 84

def table_action_archive_tag(record, path, options = {})
  return unless can?(:destroy, record) && record.archive_able?

  options[:tool_tip] ||= 'Archive'
  options[:classes] ||=  %i[text-danger]
  options[:icon_name] ||= :archive
  options[:method] ||= :delete
  options[:confirm] ||= "Are you sure you want to archive this #{record.class.name.humanize}?"
  table_action_tag(path, options)
end

#table_action_delete_tag(record, path, options = {}) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'app/helpers/core_table_action_helper.rb', line 73

def table_action_delete_tag(record, path, options = {})
  return unless can?(:destroy, record)

  options[:tool_tip] ||= 'Delete'
  options[:classes] ||=  %i[text-danger]
  options[:icon_name] ||= :delete
  options[:method] ||= :delete
  options[:confirm] ||= "Are you sure you want to delete this #{record.class.name.humanize}?"
  table_action_tag(path, options)
end

#table_action_demote_tag(record, path, options = {}) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'app/helpers/core_table_action_helper.rb', line 62

def table_action_demote_tag(record, path, options = {})
  return unless can?(:update, record)

  options[:tool_tip] ||= 'Demote'
  options[:classes] ||=  %i[text-warning]
  options[:icon_name] ||= 'thumb-down'
  options[:method] ||= :delete
  options[:confirm] ||= "Are you sure you want to demote this #{record.class.name.humanize}?"
  table_action_tag(path, options)
end

#table_action_deploy_tag(record, path, options = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'app/helpers/core_table_action_helper.rb', line 35

def table_action_deploy_tag(record, path, options = {})
  return unless can?(:edit, record) && record.deploy_able?

  options[:tool_tip] ||= 'Deploy'
  options[:icon_name] ||= :deploy
  table_action_tag(path, options)
end

#table_action_download_tag(record, options = {}) ⇒ Object



95
96
97
98
99
100
101
102
# File 'app/helpers/core_table_action_helper.rb', line 95

def table_action_download_tag(record, options = {})
  return unless can?(:read, record)

  link_classes = tooltip_data(options, 'Download')
  (:a, href: download_polymorphic_path(record), class: link_classes.join(' ')) do
    svg_icon('download', type: options[:type] || :outline)
  end
end

#table_action_edit_tag(record, path, options = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/core_table_action_helper.rb', line 19

def table_action_edit_tag(record, path, options = {})
  return unless can?(:edit, record) && record.edit_able?

  options[:tool_tip] ||= 'Edit'
  options[:icon_name] ||= :edit
  table_action_tag(path, options)
end

#table_action_replay_tag(record, path, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
# File 'app/helpers/core_table_action_helper.rb', line 53

def table_action_replay_tag(record, path, options = {})
  return unless can?(:update, record)

  options[:tool_tip] ||= 'Replay'
  options[:icon_name] ||= :repeat
  options[:confirm] ||= "Are you sure you want to restart this #{record.class.name.humanize}?"
  table_action_tag(path, options)
end

#table_action_restore_tag(record, path, options = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'app/helpers/core_table_action_helper.rb', line 27

def table_action_restore_tag(record, path, options = {})
  return unless can?(:edit, record) && record.restore_able?

  options[:tool_tip] ||= 'Restore'
  options[:icon_name] ||= :restore
  table_action_tag(path, options)
end

#table_action_revoke_tag(record, path, options = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'app/helpers/core_table_action_helper.rb', line 43

def table_action_revoke_tag(record, path, options = {})
  return unless can?(:edit, record) && record.revoke_able?

  options[:tool_tip] ||= 'Revoke'
  options[:classes] ||=  %w[text-danger]
  options[:icon_name] ||= :revoke
  options[:confirm] ||= "Are you sure you want to revoke this #{record.class.name.humanize}?"
  table_action_tag(path, options)
end

#table_action_run_tag(record, path, options = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'app/helpers/core_table_action_helper.rb', line 11

def table_action_run_tag(record, path, options = {})
  return unless can?(:manage, record) && record.edit_able?

  options[:tool_tip] ||= 'Run'
  options[:icon_name] ||= :run
  table_action_tag(path, options)
end

#table_action_show_tag(record, path, options = {}) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/core_table_action_helper.rb', line 3

def table_action_show_tag(record, path, options = {})
  return unless can?(:read, record)

  options[:title] ||= 'Show'
  options[:icon_name] ||= :info
  table_action_tag(path, options)
end