Module: CoreCardNavItemsHelper

Defined in:
app/helpers/core_card_nav_items_helper.rb

Overview

Help with nav items at the top of cards

Instance Method Summary collapse

Instance Method Details

This method is abstract.

The work horse for the card nav item

Returns HTML - The HTML for the given tag.



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/helpers/core_card_nav_items_helper.rb', line 75

def card_nav_item_link(path, title, icon_name, confirm: nil, method: :get, btn_class: 'btn-primary')
  data = { method: method, turbo_method: method }
  if confirm.present?
    data[:confirm] = confirm
    data[:turbo_confirm] = confirm
  end
  (:li, class: 'nav-item me-2') do
    link_to path, class: "#{btn_class} btn nav-link active", data: data do
      concat(svg_icon(icon_name, classes: ['me-2']))
      concat((:span, class: 'd-none d-md-inline') { title })
    end
  end
end

#card_nav_items(&block) ⇒ Object

This method is abstract.

Yield the main block for card nav items



8
9
10
11
12
# File 'app/helpers/core_card_nav_items_helper.rb', line 8

def card_nav_items(&block)
  (:ul, class: 'nav nav-pills float-end') do
    yield block
  end
end
This method is abstract.

Link to the jobs icon

Returns HTML - The HTML for the given tag.



24
25
26
27
28
# File 'app/helpers/core_card_nav_items_helper.rb', line 24

def current_job_nav_link(obj, path, title: 'Current')
  return unless can?(:view, obj)

  card_nav_item_link(path, title, 'run')
end
This method is abstract.

Link to delete an object

Returns HTML - The HTML for the given tag.



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

def delete_nav_link(obj, path, confirm: nil, title: 'Delete')
  return unless can?(:manage, obj)

  confirm ||= "Are you sure you want to delete this #{obj.class_title}?"
  card_nav_item_link(path, title, :delete, confirm: confirm, method: :delete, btn_class: 'btn-danger')
end


52
53
54
55
56
# File 'app/helpers/core_card_nav_items_helper.rb', line 52

def edit_nav_link(obj, path, title: 'Edit')
  return unless can?(:edit, obj)

  card_nav_item_link(path, title, 'edit')
end
This method is abstract.

Link to the jobs icon

Returns HTML - The HTML for the given tag.



16
17
18
19
20
# File 'app/helpers/core_card_nav_items_helper.rb', line 16

def jobs_nav_link(obj, path, title: 'Jobs')
  return unless can?(:view, obj)

  card_nav_item_link(path, title, 'stack-overflow')
end
This method is abstract.

Link to restart, replay a given object

Returns HTML - The HTML for the given tag.



45
46
47
48
49
50
# File 'app/helpers/core_card_nav_items_helper.rb', line 45

def restart_nav_link(obj, path, confirm: nil, title: 'Restart')
  return unless can?(:edit, obj)

  confirm ||= "Are you sure you want to restart this #{obj.class_title}?"
  card_nav_item_link(path, title, :replay, confirm: confirm)
end
This method is abstract.

Link to the jobs icon

Returns HTML - The HTML for the given tag.



32
33
34
35
36
37
# File 'app/helpers/core_card_nav_items_helper.rb', line 32

def start_job_nav_link(obj, path, title: 'Start', confirm: nil)
  return unless can?(:view, obj)

  confirm ||= "Are you sure you want to start this #{obj.class_title} job?"
  card_nav_item_link(path, title, :play, btn_class: 'btn-success', confirm: confirm, method: :post)
end