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
-
#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
-
#restart_nav_link(obj, path, confirm: nil, title: 'Restart') ⇒ 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.
50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/core_card_nav_items_helper.rb', line 50 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 |
#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.
35 36 37 38 39 40 |
# File 'app/helpers/core_card_nav_items_helper.rb', line 35 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
27 28 29 30 31 |
# File 'app/helpers/core_card_nav_items_helper.rb', line 27 def edit_nav_link(obj, path, title: 'Edit') return unless can?(:edit, obj) card_nav_item_link(path, title, 'edit') 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.
20 21 22 23 24 25 |
# File 'app/helpers/core_card_nav_items_helper.rb', line 20 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 |