Module: RailsModalManager::ModalHelper
- Defined in:
- app/helpers/rails_modal_manager/modal_helper.rb
Defined Under Namespace
Modules: Icons
Instance Method Summary collapse
-
#rmm_footer_buttons(buttons) ⇒ Array<Hash>
Helper to create footer buttons array.
-
#rmm_icon(name) ⇒ Object
Helper method to get icon SVG.
-
#rmm_modal(modal_id, options = {}) { ... } ⇒ String
Render a modal component.
-
#rmm_open_button(modal_id, label, options = {}) ⇒ String
Generate a button that opens a modal.
-
#rmm_open_link(modal_id, label, options = {}) ⇒ String
Generate a link that opens a modal.
-
#rmm_sidebar_items(items) ⇒ Array<Hash>
Helper to create sidebar items array.
-
#rmm_taskbar ⇒ String
Render the global taskbar component Should be included once in the layout, typically at the end of body.
Instance Method Details
#rmm_footer_buttons(buttons) ⇒ Array<Hash>
Helper to create footer buttons array
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 127 def () .map do |btn| { id: btn[:id], label: btn[:label], variant: btn[:variant] || "secondary", disabled: btn[:disabled] || false, loading: btn[:loading] || false, action: btn[:action] } end end |
#rmm_icon(name) ⇒ Object
Helper method to get icon SVG
208 209 210 211 212 213 214 215 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 208 def rmm_icon(name) method_name = name.to_s.downcase if RailsModalManager::ModalHelper::Icons.respond_to?(method_name) RailsModalManager::ModalHelper::Icons.send(method_name).html_safe else "" end end |
#rmm_modal(modal_id, options = {}) { ... } ⇒ String
Render a modal component
37 38 39 40 41 42 43 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 37 def rmm_modal(modal_id, = {}, &block) render( partial: "rails_modal_manager/modal", locals: .merge(modal_id: modal_id), &block ) end |
#rmm_open_button(modal_id, label, options = {}) ⇒ String
Generate a button that opens a modal
67 68 69 70 71 72 73 74 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 67 def (modal_id, label, = {}) [:type] ||= "button" [:data] ||= {} [:data][:action] = "click->rmm-modal#open" [:data][:rmm_modal_id] = modal_id content_tag(:button, label, ) end |
#rmm_open_link(modal_id, label, options = {}) ⇒ String
Generate a link that opens a modal
83 84 85 86 87 88 89 90 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 83 def rmm_open_link(modal_id, label, = {}) [:href] ||= "#" [:data] ||= {} [:data][:action] = "click->rmm-modal#open" [:data][:rmm_modal_id] = modal_id content_tag(:a, label, ) end |
#rmm_sidebar_items(items) ⇒ Array<Hash>
Helper to create sidebar items array
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 103 def (items) items.map do |item| { id: item[:id], label: item[:label], icon_svg: item[:icon_svg] || item[:icon], badge: item[:badge], active: item[:active] || false, disabled: item[:disabled] || false } end end |
#rmm_taskbar ⇒ String
Render the global taskbar component Should be included once in the layout, typically at the end of body
53 54 55 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 53 def render partial: "rails_modal_manager/taskbar" end |