module RailsModalManager::ModalHelper
def rmm_footer_buttons(buttons)
-
(Array- Formatted footer buttons)
Parameters:
-
buttons(Array) -- Array of button definitions
def rmm_footer_buttons(buttons) buttons.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
def rmm_icon(name)
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
def rmm_modal(modal_id, options = {}, &block)
- Example: Full-featured modal -
Example: Basic modal -
Returns:
-
(String)- Rendered modal HTML
Other tags:
- Yield: - Modal content block
Parameters:
-
options(Hash) -- Modal options -
modal_id(String) -- Unique modal identifier
def rmm_modal(modal_id, options = {}, &block) content = block_given? ? capture(&block) : nil render( partial: "rails_modal_manager/modal", locals: options.merge(modal_id: modal_id, block_content: content) ) end
def rmm_open_button(modal_id, label, options = {})
-
(String)- Button HTML
Parameters:
-
options(Hash) -- Button HTML options -
label(String) -- Button label -
modal_id(String) -- The modal ID to open
def rmm_open_button(modal_id, label, options = {}) options[:type] ||= "button" options[:data] ||= {} options[:data][:action] = "click->rmm-modal#open" options[:data][:rmm_modal_id] = modal_id content_tag(:button, label, options) end
def rmm_open_link(modal_id, label, options = {})
-
(String)- Link HTML
Parameters:
-
options(Hash) -- Link HTML options -
label(String) -- Link label -
modal_id(String) -- The modal ID to open
def rmm_open_link(modal_id, label, options = {}) options[:href] ||= "#" options[:data] ||= {} options[:data][:action] = "click->rmm-modal#open" options[:data][:rmm_modal_id] = modal_id content_tag(:a, label, options) end
def rmm_sidebar_items(items)
- Example: With panel and submenu linking -
Example: Basic sidebar -
Returns:
-
(Array- Formatted sidebar items)
Parameters:
-
items(Array) -- Array of item definitions
def rmm_sidebar_items(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
def rmm_submenu_items(items)
- Example: AJAX mode (with url) -
Example: Preload mode (with panel_id) -
Returns:
-
(Array- Formatted submenu items)
Parameters:
-
items(Array) -- Array of item definitions
def rmm_submenu_items(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
def rmm_taskbar
- Example: In layout -
Returns:
-
(String)- Rendered taskbar HTML
def rmm_taskbar render partial: "rails_modal_manager/taskbar" end