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
-
#card_nav_item_link(path, title, icon_name, confirm: nil, method: :get, btn_class: 'btn-primary') ⇒ Object
abstract
HTML - The HTML for the given tag.
- #card_nav_items(&block) ⇒ Object abstract
-
#current_job_nav_link(obj, path, title: 'Current') ⇒ Object
abstract
HTML - The HTML for the given tag.
-
#delete_nav_link(obj, path, confirm: nil, title: 'Delete') ⇒ Object
abstract
HTML - The HTML for the given tag.
- #edit_nav_link(obj, path, title: 'Edit') ⇒ Object
-
#jobs_nav_link(obj, path, title: 'Jobs') ⇒ Object
abstract
HTML - The HTML for the given tag.
-
#restart_nav_link(obj, path, confirm: nil, title: 'Restart') ⇒ Object
abstract
HTML - The HTML for the given tag.
-
#start_job_nav_link(obj, path, title: 'Start', confirm: nil) ⇒ Object
abstract
HTML - The HTML for the given tag.
Instance Method Details
#card_nav_item_link(path, title, icon_name, confirm: nil, method: :get, btn_class: 'btn-primary') ⇒ Object
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 |
# 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 } data[:confirm] = confirm if confirm.present? content_tag(:li, class: 'nav-item me-2') do link_to path, class: "#{btn_class} btn nav-link active", data: data do concat(remix_icon(icon_name, classes: ['me-2'], tooltip_text: title)) concat(content_tag(: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) content_tag(:ul, class: 'nav nav-pills float-end') do yield block end end |
#current_job_nav_link(obj, path, title: 'Current') ⇒ Object
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 |
#delete_nav_link(obj, path, confirm: nil, title: 'Delete') ⇒ Object
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-bin', confirm: confirm, method: :delete, btn_class: 'btn-danger') end |
#edit_nav_link(obj, path, title: 'Edit') ⇒ Object
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 |
#jobs_nav_link(obj, path, title: 'Jobs') ⇒ Object
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 |
#restart_nav_link(obj, path, confirm: nil, title: 'Restart') ⇒ Object
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, 'delete-bin', confirm: confirm) end |
#start_job_nav_link(obj, path, title: 'Start', confirm: nil) ⇒ Object
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 restart this #{obj.class_title} job?" card_nav_item_link(path, title, 'play', btn_class: 'btn-success', confirm: confirm, method: :post) end |