Module: CoreDropdownHelper
- Defined in:
- app/helpers/core_dropdown_helper.rb
Overview
Helpful methods rendering tables
Instance Method Summary collapse
- #cancel_dropdown_item(obj, path, confirm: 'Are you sure?', method: :delete) ⇒ Object
- #current_job_dropdown_item(obj, path) ⇒ Object
- #dashboard_dropdown_item(obj, path, name: 'Show') ⇒ Object
- #delete_dropdown_item(obj, path) ⇒ Object
- #demote_dropdown_item(obj, path) ⇒ Object
- #dropdown_item(path, icon_name, action_name, method: :get, confirm: nil, classes: []) ⇒ Object
- #dropdown_menu(icon_size: 24, &block) ⇒ Object abstract
- #edit_dropdown_item(obj, path) ⇒ Object
- #info_dropdown_item(obj, path, name: 'Info') ⇒ Object
- #jobs_dropdown_item(obj, path, name: 'Jobs') ⇒ Object
- #replay_dropdown_item(obj, path, confirm: nil, title: 'Replay') ⇒ Object
- #run_dropdown_item(obj, path, method: :get, title: 'Run') ⇒ Object
Instance Method Details
#cancel_dropdown_item(obj, path, confirm: 'Are you sure?', method: :delete) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'app/helpers/core_dropdown_helper.rb', line 77 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
59 60 61 62 63 |
# File 'app/helpers/core_dropdown_helper.rb', line 59 def current_job_dropdown_item(obj, path) return unless can? :view, obj dropdown_item(path, :hourglass, 'Current Job') end |
#dashboard_dropdown_item(obj, path, name: 'Show') ⇒ Object
47 48 49 50 51 |
# File 'app/helpers/core_dropdown_helper.rb', line 47 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
71 72 73 74 75 |
# File 'app/helpers/core_dropdown_helper.rb', line 71 def delete_dropdown_item(obj, path) return unless can? :delete, obj dropdown_item(path, :delete, 'Delete', method: :delete, confirm: 'are you sure?') end |
#demote_dropdown_item(obj, path) ⇒ Object
35 36 37 38 39 |
# File 'app/helpers/core_dropdown_helper.rb', line 35 def demote_dropdown_item(obj, path) return unless can? :edit, obj dropdown_item(path, :demote, 'Demote') end |
#dropdown_item(path, icon_name, action_name, method: :get, confirm: nil, classes: []) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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, turbo_method: method } if confirm.present? data[:confirm] = confirm data[:turbo_confirm] = confirm end classes << 'dropdown-item' content_tag(:li) do concat(content_tag(:a, class: classes.join(' '), href: path, data: data) do concat(svg_icon(icon_name)) concat(action_name) end) end end |
#dropdown_menu(icon_size: 24, &block) ⇒ Object
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 (icon_size: 24, &block) content_tag(:div, class: 'dropdown') do concat(content_tag(:button, class: 'btn p-0 dropdown-toggle hide-arrow', type: :button, data: { 'bs-toggle': :dropdown }) do concat(svg_icon(:more_menu, size: icon_size)) end) concat(content_tag(:div, class: 'dropdown-menu') { yield block }) end end |
#edit_dropdown_item(obj, path) ⇒ Object
65 66 67 68 69 |
# File 'app/helpers/core_dropdown_helper.rb', line 65 def edit_dropdown_item(obj, path) return unless can? :edit, obj dropdown_item(path, :edit, 'Edit') end |
#info_dropdown_item(obj, path, name: 'Info') ⇒ Object
41 42 43 44 45 |
# File 'app/helpers/core_dropdown_helper.rb', line 41 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
53 54 55 56 57 |
# File 'app/helpers/core_dropdown_helper.rb', line 53 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
94 95 96 97 98 |
# File 'app/helpers/core_dropdown_helper.rb', line 94 def replay_dropdown_item(obj, path, confirm: nil, title: 'Replay') return unless can? :read, obj dropdown_item(path, :repeat, title, confirm: confirm) end |
#run_dropdown_item(obj, path, method: :get, title: 'Run') ⇒ Object
88 89 90 91 92 |
# File 'app/helpers/core_dropdown_helper.rb', line 88 def run_dropdown_item(obj, path, method: :get, title: 'Run') return unless can? :read, obj dropdown_item(path, :run, title, method: method) end |