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(&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
75 76 77 78 79 80 81 82 83 84 |
# File 'app/helpers/core_dropdown_helper.rb', line 75 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
57 58 59 60 61 |
# File 'app/helpers/core_dropdown_helper.rb', line 57 def current_job_dropdown_item(obj, path) return unless can? :view, obj dropdown_item(path, 'hourglass-2', 'Current Job') end |
#dashboard_dropdown_item(obj, path, name: 'Show') ⇒ Object
45 46 47 48 49 |
# File 'app/helpers/core_dropdown_helper.rb', line 45 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
69 70 71 72 73 |
# File 'app/helpers/core_dropdown_helper.rb', line 69 def delete_dropdown_item(obj, path) return unless can? :delete, obj dropdown_item(path, 'delete-bin', 'Delete', method: :delete, confirm: 'are you sure?') end |
#demote_dropdown_item(obj, path) ⇒ Object
33 34 35 36 37 |
# File 'app/helpers/core_dropdown_helper.rb', line 33 def demote_dropdown_item(obj, path) return unless can? :edit, obj dropdown_item(path, 'thumb-down', '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 |
# 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(:a, class: classes.join(' '), href: path, data: data) do concat((icon_name)) concat(action_name) end end |
#dropdown_menu(&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 (&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(remix_icon('more-2')) end) concat(content_tag(:div, class: 'dropdown-menu') { yield block }) end end |
#edit_dropdown_item(obj, path) ⇒ Object
63 64 65 66 67 |
# File 'app/helpers/core_dropdown_helper.rb', line 63 def edit_dropdown_item(obj, path) return unless can? :edit, obj dropdown_item(path, 'pencil', 'Edit') end |
#info_dropdown_item(obj, path, name: 'Info') ⇒ Object
39 40 41 42 43 |
# File 'app/helpers/core_dropdown_helper.rb', line 39 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
51 52 53 54 55 |
# File 'app/helpers/core_dropdown_helper.rb', line 51 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
92 93 94 95 96 |
# File 'app/helpers/core_dropdown_helper.rb', line 92 def replay_dropdown_item(obj, path, confirm: nil, title: 'Replay') return unless can? :read, obj dropdown_item(path, 'reset-left', title, confirm: confirm) end |
#run_dropdown_item(obj, path, method: :get, title: 'Run') ⇒ Object
86 87 88 89 90 |
# File 'app/helpers/core_dropdown_helper.rb', line 86 def run_dropdown_item(obj, path, method: :get, title: 'Run') return unless can? :read, obj dropdown_item(path, 'run', title, method: method) end |