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_submenu_items(items) ⇒ Array<Hash>
Helper to create submenu 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
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 135 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
248 249 250 251 252 253 254 255 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 248 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) content = block_given? ? capture(&block) : nil render( partial: "rails_modal_manager/modal", locals: .merge(modal_id: modal_id, block_content: content) ) 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
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 109 def (items) items.map do |item| { id: item[:id], label: item[:label], icon_svg: item[:icon_svg] || item[:icon], badge: item[:badge], panel_id: item[:panel_id], submenu_id: item[:submenu_id], active: item[:active] || false, disabled: item[:disabled] || false } end end |
#rmm_submenu_items(items) ⇒ Array<Hash>
Helper to create submenu items array
166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'app/helpers/rails_modal_manager/modal_helper.rb', line 166 def (items) items.map do |item| { id: item[:id], label: item[:label], icon_svg: item[:icon_svg] || item[:icon], panel_id: item[:panel_id], url: item[:url], 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 |