Module: Dbwatcher::ApplicationHelper
- Includes:
- FormattingHelper, SessionHelper
- Defined in:
- app/helpers/dbwatcher/application_helper.rb
Overview
rubocop:disable Metrics/ModuleLength
Instance Method Summary collapse
-
#action_button(text, path, color: "blue") ⇒ Object
Create action buttons with consistent styling.
-
#empty_state(message, icon: nil) ⇒ Object
Create empty state message.
-
#format_count(value) ⇒ Object
Format count with proper fallback.
-
#safe_value(data, key, fallback = "N/A") ⇒ Object
Safe value extraction with fallback.
-
#stats_icon(type) ⇒ Object
Create icon HTML for stats cards.
Methods included from SessionHelper
#display_session_id, #display_session_name, #session_active?, #session_change_count
Methods included from FormattingHelper
#format_cell_value, #format_cell_value_simple, #truncate_cell_value
Instance Method Details
#action_button(text, path, color: "blue") ⇒ Object
Create action buttons with consistent styling
108 109 110 |
# File 'app/helpers/dbwatcher/application_helper.rb', line 108 def (text, path, color: "blue") link_to text, path, class: "px-3 py-1 text-xs bg-#{color}-600 text-white rounded hover:bg-#{color}-700" end |
#empty_state(message, icon: nil) ⇒ Object
Create empty state message
125 126 127 128 129 130 131 132 |
# File 'app/helpers/dbwatcher/application_helper.rb', line 125 def empty_state(, icon: nil) content_tag(:div, class: "text-center py-8 text-gray-500") do content = [] content << icon if icon content << content_tag(:p, , class: "text-xs") content.join.html_safe end end |
#format_count(value) ⇒ Object
Format count with proper fallback
120 121 122 |
# File 'app/helpers/dbwatcher/application_helper.rb', line 120 def format_count(value) value.to_i.to_s end |
#safe_value(data, key, fallback = "N/A") ⇒ Object
Safe value extraction with fallback
113 114 115 116 117 |
# File 'app/helpers/dbwatcher/application_helper.rb', line 113 def safe_value(data, key, fallback = "N/A") return fallback unless data.is_a?(Hash) data[key] || data[key.to_s] || fallback end |
#stats_icon(type) ⇒ Object
Create icon HTML for stats cards
12 13 14 15 |
# File 'app/helpers/dbwatcher/application_helper.rb', line 12 def stats_icon(type) icon_html = icon_definitions[type.to_sym] icon_html&.html_safe end |