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
65 66 67 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 65 def crm_request? request.subdomain =~ /^crm/ end |
#enter_heat_loss_info_path_for_room(room) ⇒ Object
Convenience method for enter_heat_loss_info path
79 80 81 82 83 84 85 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 79 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
125 126 127 128 129 130 131 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 125 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
53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 53 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
118 119 120 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 118 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
98 99 100 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 98 def hl_card_class crm_request? ? 'card' : 'my-account-card' end |
#hl_card_col_class ⇒ Object
114 115 116 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 114 def hl_card_col_class crm_request? ? 'col-12' : 'col-12 col-my-account-card' end |
#hl_card_content_class ⇒ Object
110 111 112 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 110 def hl_card_content_class crm_request? ? 'card-body' : 'my-account-card-content' end |
#hl_card_header_class ⇒ Object
102 103 104 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 102 def hl_card_header_class crm_request? ? 'card-header' : 'my-account-card-header' end |
#hl_card_title_class ⇒ Object
106 107 108 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 106 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)
88 89 90 91 92 93 94 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 88 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
70 71 72 73 74 75 76 |
# File 'app/helpers/heat_loss_paths_helper.rb', line 70 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 |