Module: HeatLossPathsHelper
- Included in:
- Controllers::HeatLoss
- Defined in:
- app/helpers/heat_loss_paths_helper.rb
Overview
Provides subdomain-aware path helpers for heat loss functionality.
These helpers work on both WWW (my_rooms) and CRM (room_configurations).
Usage in views:
heat_loss_path(:complete_heat_loss_info, @room)
heat_loss_path(:exterior_walls_heat_loss_details, @room, exterior_wall_id: @wall)
Constant Summary collapse
- HEAT_LOSS_ACTIONS =
Map of action names to their path method suffixes
%w[ complete_heat_loss_info heat_loss_details_summary room_heat_loss_details complete_room_heat_loss_details under_floor_heat_loss_details complete_under_floor_heat_loss_details ceiling_heat_loss_details complete_ceiling_heat_loss_details skylights_heat_loss_details complete_skylights_heat_loss_details dupe_skylight_heat_loss_details remove_skylight_heat_loss_details exterior_walls_heat_loss_details complete_exterior_walls_heat_loss_details dupe_exterior_wall_heat_loss_details remove_exterior_wall_heat_loss_details windows_heat_loss_details complete_windows_heat_loss_details dupe_window_heat_loss_details remove_window_heat_loss_details doors_heat_loss_details complete_doors_heat_loss_details dupe_door_heat_loss_details remove_door_heat_loss_details update_under_floor_type update_ceiling_type update_exterior_wall_type update_window_type update_door_type ].freeze
Instance Method Summary collapse
-
#crm_request? ⇒ Boolean
Check if we're on the CRM subdomain.
-
#enter_heat_loss_info_path_for_room(room) ⇒ Object
Convenience method for enter_heat_loss_info path.
-
#format_errors_as_list(errors) ⇒ String
Format validation errors as an HTML bullet list for flash messages.
-
#heat_loss_path(action, room, options = {}) ⇒ String
Returns the correct path for a heat loss action based on current subdomain.
- #hl_btn_submit_class ⇒ Object
-
#hl_card_class ⇒ Object
CSS class helpers for context-aware styling Returns appropriate CSS classes for cards based on context.
- #hl_card_col_class ⇒ Object
- #hl_card_content_class ⇒ Object
- #hl_card_header_class ⇒ Object
- #hl_card_title_class ⇒ Object
-
#room_path_for_room(room) ⇒ Object
Convenience method for room path (back to room details).
-
#show_heat_loss_path_for_room(room) ⇒ Object
Convenience method for show_heat_loss path.
Instance Method Details
#crm_request? ⇒ Boolean
Check if we're on the CRM subdomain
62 63 64 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 62 def crm_request? request.subdomain =~ /^crm/ end |
#enter_heat_loss_info_path_for_room(room) ⇒ Object
Convenience method for enter_heat_loss_info path
76 77 78 79 80 81 82 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 76 def enter_heat_loss_info_path_for_room(room) if crm_request? enter_heat_loss_info_room_configuration_path(room) else enter_heat_loss_info_my_room_path(room) end end |
#format_errors_as_list(errors) ⇒ String
Format validation errors as an HTML bullet list for flash messages
122 123 124 125 126 127 128 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 122 def format_errors_as_list(errors) return '' if errors.blank? tag.ul(class: 'mb-0 ps-3') do safe_join(errors.map { |msg| tag.li(msg) }) end.to_s end |
#heat_loss_path(action, room, options = {}) ⇒ String
Returns the correct path for a heat loss action based on current subdomain
50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 50 def heat_loss_path(action, room, = {}) action = action.to_s raise ArgumentError, "Unknown heat loss action: #{action}" unless HEAT_LOSS_ACTIONS.include?(action) if crm_request? send("#{action}_room_configuration_path", room, ) else send("#{action}_my_room_path", room, ) end end |
#hl_btn_submit_class ⇒ Object
115 116 117 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 115 def hl_btn_submit_class crm_request? ? 'btn btn-success' : 'btn btn-success btn-block btn-my-account-card' end |
#hl_card_class ⇒ Object
CSS class helpers for context-aware styling
Returns appropriate CSS classes for cards based on context
95 96 97 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 95 def hl_card_class crm_request? ? 'card' : 'my-account-card' end |
#hl_card_col_class ⇒ Object
111 112 113 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 111 def hl_card_col_class crm_request? ? 'col-12' : 'col-12 col-my-account-card' end |
#hl_card_content_class ⇒ Object
107 108 109 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 107 def hl_card_content_class crm_request? ? 'card-body' : 'my-account-card-content' end |
#hl_card_header_class ⇒ Object
99 100 101 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 99 def hl_card_header_class crm_request? ? 'card-header' : 'my-account-card-header' end |
#hl_card_title_class ⇒ Object
103 104 105 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 103 def hl_card_title_class crm_request? ? 'card-title mb-0' : 'my-account-card-title' end |
#room_path_for_room(room) ⇒ Object
Convenience method for room path (back to room details)
85 86 87 88 89 90 91 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 85 def room_path_for_room(room) if crm_request? room_configuration_path(room) else my_room_path(room) end end |
#show_heat_loss_path_for_room(room) ⇒ Object
Convenience method for show_heat_loss path
67 68 69 70 71 72 73 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 67 def show_heat_loss_path_for_room(room) if crm_request? show_heat_loss_room_configuration_path(room) else show_heat_loss_my_room_path(room) end end |