Module: Controllers::HeatLoss
- Extended by:
- ActiveSupport::Concern
- Includes:
- HeatLossPathsHelper
- Included in:
- MyRoomsController, RoomConfigurationsController
- Defined in:
- app/concerns/controllers/heat_loss.rb
Overview
ActiveSupport::Concern mixin: heat loss.
Constant Summary
Constants included from HeatLossPathsHelper
HeatLossPathsHelper::HEAT_LOSS_ACTIONS
Instance Method Summary collapse
-
#ceiling_heat_loss_details ⇒ void
Renders the ceiling heat loss details step of the wizard.
-
#complete_ceiling_heat_loss_details ⇒ void
Saves ceiling details and advances to the summary step, or re-renders with errors.
-
#complete_doors_heat_loss_details ⇒ void
Saves door details and advances to the summary step, or re-renders with errors.
-
#complete_exterior_walls_heat_loss_details ⇒ void
Saves exterior wall details and advances to the summary step, or re-renders with errors.
-
#complete_heat_loss_info ⇒ void
Calculates the room's heat loss and redirects to the report, or re-renders the wizard with errors.
-
#complete_room_heat_loss_details ⇒ void
Saves room-level details and advances to the under-floor step, or re-renders with errors.
-
#complete_skylights_heat_loss_details ⇒ void
Saves skylight details and advances to the summary step, or re-renders with errors.
-
#complete_under_floor_heat_loss_details ⇒ void
Saves under-floor details and advances to the ceiling step, or re-renders with errors.
-
#complete_windows_heat_loss_details ⇒ void
Saves window details and advances to the summary step, or re-renders with errors.
-
#doors_heat_loss_details ⇒ void
Renders the doors heat loss details step, starting a new door when none is selected.
-
#dupe_door_heat_loss_details ⇒ void
Duplicates the selected door and returns to the summary step.
-
#dupe_exterior_wall_heat_loss_details ⇒ void
Duplicates the selected exterior wall and returns to the summary step.
-
#dupe_skylight_heat_loss_details ⇒ void
Duplicates the selected skylight and returns to the summary step.
-
#dupe_window_heat_loss_details ⇒ void
Duplicates the selected window and returns to the summary step.
-
#enter_heat_loss_info ⇒ void
Starts the heat loss wizard for an indoor room; redirects or flashes an error otherwise.
-
#exterior_walls_heat_loss_details ⇒ void
Renders the exterior walls heat loss details step, starting a new wall when none is selected.
-
#heat_loss_details_summary ⇒ void
Renders the heat loss details summary step of the wizard.
-
#projects_path_for(room, subdomain) ⇒ String
URL of the projects listing for the given subdomain.
-
#remove_door_heat_loss_details ⇒ void
Destroys the selected door and returns to the summary step.
-
#remove_exterior_wall_heat_loss_details ⇒ void
Destroys the selected exterior wall and returns to the summary step.
-
#remove_skylight_heat_loss_details ⇒ void
Destroys the selected skylight and returns to the summary step.
-
#remove_window_heat_loss_details ⇒ void
Destroys the selected window and returns to the summary step.
-
#room_heat_loss_details ⇒ void
Renders the room-level heat loss details step of the wizard.
-
#set_ceiling_variables ⇒ void
Builds a default ceiling when missing and loads insulation type options for the form.
-
#set_doors_variables ⇒ void
Loads the exterior wall and door being edited plus their form child indexes from params.
-
#set_exterior_walls_variables ⇒ void
Loads the exterior wall being edited and its form child index from params.
-
#set_skylights_variables ⇒ void
Loads the skylight being edited and its form child index from params.
-
#set_under_floor_variables ⇒ void
Builds a default under-floor when missing and loads insulation type options for the form.
-
#set_windows_variables ⇒ void
Loads the exterior wall and window being edited plus their form child indexes from params.
-
#show_heat_loss ⇒ void
Shows the room's heat loss report as HTML or PDF, optionally saving the PDF as a room attachment.
-
#show_heat_loss_path_for(room, subdomain) ⇒ String
URL of the heat loss report page for the given subdomain.
-
#skylights_heat_loss_details ⇒ void
Renders the skylights heat loss details step, starting a new skylight when none is selected.
-
#under_floor_heat_loss_details ⇒ void
Renders the under-floor heat loss details step of the wizard.
-
#update_ceiling_type ⇒ void
Refreshes ceiling insulation type options when the ceiling type changes.
-
#update_door_type ⇒ void
Refreshes door type, core type, and frame type ids when the door type changes.
-
#update_exterior_wall_type ⇒ void
Refreshes exterior wall insulation type options when the exterior wall type changes.
-
#update_under_floor_type ⇒ void
Refreshes under-floor insulation type options when the under-floor type changes.
-
#update_window_type ⇒ void
Refreshes window type, glass type, and frame type ids when the window type changes.
-
#windows_heat_loss_details ⇒ void
Renders the windows heat loss details step, starting a new window when none is selected.
Methods included from HeatLossPathsHelper
#crm_request?, #enter_heat_loss_info_path_for_room, #format_errors_as_list, #heat_loss_path, #hl_btn_submit_class, #hl_card_class, #hl_card_col_class, #hl_card_content_class, #hl_card_header_class, #hl_card_title_class, #room_path_for_room, #show_heat_loss_path_for_room
Instance Method Details
#ceiling_heat_loss_details ⇒ void
This method returns an undefined value.
Renders the ceiling heat loss details step of the wizard
209 210 211 212 213 214 215 |
# File 'app/concerns/controllers/heat_loss.rb', line 209 def ceiling_heat_loss_details set_ceiling_variables respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#complete_ceiling_heat_loss_details ⇒ void
This method returns an undefined value.
Saves ceiling details and advances to the summary step, or re-renders with errors
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'app/concerns/controllers/heat_loss.rb', line 219 def complete_ceiling_heat_loss_details if @room.update(params[:room]) respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end else set_ceiling_variables set_validation_errors_flash(@room) respond_to do |format| format.turbo_stream { render action: :ceiling_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end end |
#complete_doors_heat_loss_details ⇒ void
This method returns an undefined value.
Saves door details and advances to the summary step, or re-renders with errors
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'app/concerns/controllers/heat_loss.rb', line 449 def complete_doors_heat_loss_details if @room.update(params[:room]) respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end else set_doors_variables @exterior_wall = @room.exterior_walls.to_a[@exterior_wall_child_index.to_i] if @door.nil? @door = @exterior_wall.doors.to_a[@child_index.to_i] @child_index = nil end set_validation_errors_flash(@room) respond_to do |format| format.turbo_stream { render action: :doors_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end end |
#complete_exterior_walls_heat_loss_details ⇒ void
This method returns an undefined value.
Saves exterior wall details and advances to the summary step, or re-renders with errors
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'app/concerns/controllers/heat_loss.rb', line 318 def complete_exterior_walls_heat_loss_details if @room.update(params[:room]) respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end else set_exterior_walls_variables if @exterior_wall.nil? @exterior_wall = @room.exterior_walls.to_a[@child_index.to_i] @child_index = nil end set_validation_errors_flash(@room) respond_to do |format| format.turbo_stream { render action: :exterior_walls_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end end |
#complete_heat_loss_info ⇒ void
This method returns an undefined value.
Calculates the room's heat loss and redirects to the report, or re-renders the wizard with errors
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/concerns/controllers/heat_loss.rb', line 67 def complete_heat_loss_info if @room.floor_type&.is_indoors? res = @room.can_calculate_heat_loss? if res[:status] == :ok @heat_loss = @room.calculate_heat_loss redirect_to(show_heat_loss_path_for(@room, request.subdomain), flash: { notice: "Room's heat loss was calculated." }) else flash[:error] = "Can't calculate heat loss yet: #{res[:errors].join(', ')}." @room.enter_heat_loss_info = true render action: :enter_heat_loss_info end else flash[:error] = 'Heat Loss Calculation is only for indoor rooms.' render action: :show end end |
#complete_room_heat_loss_details ⇒ void
This method returns an undefined value.
Saves room-level details and advances to the under-floor step, or re-renders with errors
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'app/concerns/controllers/heat_loss.rb', line 144 def complete_room_heat_loss_details @room.enter_heat_loss_info = true if @room.update(params[:room]) set_under_floor_variables respond_to do |format| format.turbo_stream { render action: :under_floor_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end else set_validation_errors_flash(@room) respond_to do |format| format.turbo_stream { render action: :room_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end end |
#complete_skylights_heat_loss_details ⇒ void
This method returns an undefined value.
Saves skylight details and advances to the summary step, or re-renders with errors
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'app/concerns/controllers/heat_loss.rb', line 255 def complete_skylights_heat_loss_details if @room.update(params[:room]) respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end else set_skylights_variables if @skylight.nil? @skylight = @room.ceiling.skylights.to_a[@child_index.to_i] @child_index = nil end set_validation_errors_flash(@room) respond_to do |format| format.turbo_stream { render action: :skylights_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end end |
#complete_under_floor_heat_loss_details ⇒ void
This method returns an undefined value.
Saves under-floor details and advances to the ceiling step, or re-renders with errors
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'app/concerns/controllers/heat_loss.rb', line 181 def complete_under_floor_heat_loss_details if @room.update(params[:room]) set_ceiling_variables respond_to do |format| format.turbo_stream { render action: :ceiling_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end else set_under_floor_variables set_validation_errors_flash(@room) flash.now[:error] ||= 'Could not save...' respond_to do |format| format.turbo_stream { render action: :under_floor_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end end |
#complete_windows_heat_loss_details ⇒ void
This method returns an undefined value.
Saves window details and advances to the summary step, or re-renders with errors
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'app/concerns/controllers/heat_loss.rb', line 383 def complete_windows_heat_loss_details if @room.update(params[:room]) respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end else set_windows_variables @exterior_wall = @room.exterior_walls.to_a[@exterior_wall_child_index.to_i] if @window.nil? @window = @exterior_wall.windows.to_a[@child_index.to_i] @child_index = nil end set_validation_errors_flash(@room) respond_to do |format| format.turbo_stream { render action: :windows_heat_loss_details } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end end |
#doors_heat_loss_details ⇒ void
This method returns an undefined value.
Renders the doors heat loss details step, starting a new door when none is selected
438 439 440 441 442 443 444 445 |
# File 'app/concerns/controllers/heat_loss.rb', line 438 def doors_heat_loss_details set_doors_variables @door ||= @exterior_wall.doors.new respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#dupe_door_heat_loss_details ⇒ void
This method returns an undefined value.
Duplicates the selected door and returns to the summary step
472 473 474 475 476 477 478 479 480 |
# File 'app/concerns/controllers/heat_loss.rb', line 472 def dupe_door_heat_loss_details set_doors_variables new_door = @door.dup flash[:error] = "Door could not be duplicated: #{new_door.errors_to_s}" unless new_door.save respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#dupe_exterior_wall_heat_loss_details ⇒ void
This method returns an undefined value.
Duplicates the selected exterior wall and returns to the summary step
340 341 342 343 344 345 346 347 348 |
# File 'app/concerns/controllers/heat_loss.rb', line 340 def dupe_exterior_wall_heat_loss_details set_exterior_walls_variables new_exterior_wall = @exterior_wall.dup flash[:error] = "Ext. Wall could not be duplicated: #{new_exterior_wall.errors_to_s}" unless new_exterior_wall.save respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#dupe_skylight_heat_loss_details ⇒ void
This method returns an undefined value.
Duplicates the selected skylight and returns to the summary step
277 278 279 280 281 282 283 284 285 |
# File 'app/concerns/controllers/heat_loss.rb', line 277 def dupe_skylight_heat_loss_details set_skylights_variables new_skylight = @skylight.dup flash[:error] = "Skylight could not be duplicated: #{new_skylight.errors_to_s}" unless new_skylight.save respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#dupe_window_heat_loss_details ⇒ void
This method returns an undefined value.
Duplicates the selected window and returns to the summary step
406 407 408 409 410 411 412 413 414 |
# File 'app/concerns/controllers/heat_loss.rb', line 406 def dupe_window_heat_loss_details set_windows_variables new_window = @window.dup flash[:error] = "Window could not be duplicated: #{new_window.errors_to_s}" unless new_window.save respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#enter_heat_loss_info ⇒ void
This method returns an undefined value.
Starts the heat loss wizard for an indoor room; redirects or flashes an error otherwise
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/concerns/controllers/heat_loss.rb', line 52 def enter_heat_loss_info if @room.present? if @room.floor_type&.is_indoors? @room.enter_heat_loss_info = true else flash[:error] = 'Heat Loss Calculation is only for indoor rooms.' render action: :show end else redirect_to(projects_path_for(@room, request.subdomain), flash: { error: 'Sorry we cannot find this room' }) end end |
#exterior_walls_heat_loss_details ⇒ void
This method returns an undefined value.
Renders the exterior walls heat loss details step, starting a new wall when none is selected
307 308 309 310 311 312 313 314 |
# File 'app/concerns/controllers/heat_loss.rb', line 307 def exterior_walls_heat_loss_details set_exterior_walls_variables @exterior_wall ||= @room.exterior_walls.new respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#heat_loss_details_summary ⇒ void
This method returns an undefined value.
Renders the heat loss details summary step of the wizard
125 126 127 128 129 130 |
# File 'app/concerns/controllers/heat_loss.rb', line 125 def heat_loss_details_summary respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#projects_path_for(room, subdomain) ⇒ String
URL of the projects listing for the given subdomain
595 596 597 598 599 600 601 602 |
# File 'app/concerns/controllers/heat_loss.rb', line 595 def projects_path_for(room, subdomain) case subdomain when 'crm' customer_opportunities_path(room.customer) else my_projects_path end end |
#remove_door_heat_loss_details ⇒ void
This method returns an undefined value.
Destroys the selected door and returns to the summary step
484 485 486 487 488 489 490 491 |
# File 'app/concerns/controllers/heat_loss.rb', line 484 def remove_door_heat_loss_details set_doors_variables @door.destroy respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#remove_exterior_wall_heat_loss_details ⇒ void
This method returns an undefined value.
Destroys the selected exterior wall and returns to the summary step
352 353 354 355 356 357 358 359 |
# File 'app/concerns/controllers/heat_loss.rb', line 352 def remove_exterior_wall_heat_loss_details set_exterior_walls_variables @exterior_wall.destroy respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#remove_skylight_heat_loss_details ⇒ void
This method returns an undefined value.
Destroys the selected skylight and returns to the summary step
289 290 291 292 293 294 295 296 |
# File 'app/concerns/controllers/heat_loss.rb', line 289 def remove_skylight_heat_loss_details set_skylights_variables @skylight.destroy respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#remove_window_heat_loss_details ⇒ void
This method returns an undefined value.
Destroys the selected window and returns to the summary step
418 419 420 421 422 423 424 425 |
# File 'app/concerns/controllers/heat_loss.rb', line 418 def remove_window_heat_loss_details set_windows_variables @window.destroy respond_to do |format| format.turbo_stream { render action: :heat_loss_details_summary } format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#room_heat_loss_details ⇒ void
This method returns an undefined value.
Renders the room-level heat loss details step of the wizard
134 135 136 137 138 139 140 |
# File 'app/concerns/controllers/heat_loss.rb', line 134 def room_heat_loss_details @room.insulation_surface ||= @room.area respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#set_ceiling_variables ⇒ void
This method returns an undefined value.
Builds a default ceiling when missing and loads insulation type options for the form
201 202 203 204 205 |
# File 'app/concerns/controllers/heat_loss.rb', line 201 def set_ceiling_variables @room.build_ceiling(area: @room.area, height: 9.0) if @room.ceiling.blank? @ceiling_insulation_type_options = CeilingInsulationType.(@room.ceiling.ceiling_type_id, @room) @ceiling_insulation_type_id = @room.ceiling.ceiling_insulation_type_id if @room.ceiling.present? end |
#set_doors_variables ⇒ void
This method returns an undefined value.
Loads the exterior wall and door being edited plus their form child indexes from params
429 430 431 432 433 434 |
# File 'app/concerns/controllers/heat_loss.rb', line 429 def set_doors_variables @exterior_wall = @room.exterior_walls.find(params[:exterior_wall_id]) @exterior_wall_child_index = params[:exterior_wall_child_index] @door = @exterior_wall.doors.find(params[:door_id]) if params[:door_id].present? @child_index = params[:child_index] end |
#set_exterior_walls_variables ⇒ void
This method returns an undefined value.
Loads the exterior wall being edited and its form child index from params
300 301 302 303 |
# File 'app/concerns/controllers/heat_loss.rb', line 300 def set_exterior_walls_variables @exterior_wall = @room.exterior_walls.find_by(id: params[:exterior_wall_id]) if params[:exterior_wall_id].present? @child_index = params[:child_index] end |
#set_skylights_variables ⇒ void
This method returns an undefined value.
Loads the skylight being edited and its form child index from params
237 238 239 240 |
# File 'app/concerns/controllers/heat_loss.rb', line 237 def set_skylights_variables @skylight = @room.ceiling.skylights.find(params[:skylight_id]) if params[:skylight_id].present? @child_index = params[:child_index] end |
#set_under_floor_variables ⇒ void
This method returns an undefined value.
Builds a default under-floor when missing and loads insulation type options for the form
163 164 165 166 167 |
# File 'app/concerns/controllers/heat_loss.rb', line 163 def set_under_floor_variables @room.build_under_floor(area: @room.area, under_floor_type_id: @room.guess_under_floor_type_id) if @room.under_floor.blank? @under_floor_insulation_type_options = UnderFloorInsulationType.(@room.under_floor.under_floor_type_id, @room) @under_floor_insulation_type_id = @room.under_floor.under_floor_insulation_type_id if @room.under_floor.present? end |
#set_windows_variables ⇒ void
This method returns an undefined value.
Loads the exterior wall and window being edited plus their form child indexes from params
363 364 365 366 367 368 |
# File 'app/concerns/controllers/heat_loss.rb', line 363 def set_windows_variables @exterior_wall = @room.exterior_walls.find(params[:exterior_wall_id]) @exterior_wall_child_index = params[:exterior_wall_child_index] @window = @exterior_wall.windows.find(params[:window_id]) if params[:window_id].present? @child_index = params[:child_index] end |
#show_heat_loss ⇒ void
This method returns an undefined value.
Shows the room's heat loss report as HTML or PDF, optionally saving the PDF as a room attachment
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/concerns/controllers/heat_loss.rb', line 86 def show_heat_loss if @room.present? if @room.floor_type&.is_indoors? res = @room.can_calculate_heat_loss? @heat_loss = @room.last_heat_loss.presence || @room.calculate_heat_loss if res[:status] == :ok if @heat_loss && @heat_loss['hlc_by_object']&.any? respond_to do |format| format.html # show.html.erb format.pdf do result = Pdf::Document::HeatLossReport.call(@room) if params[:save_to_room].to_b @room.uploads.where(category: 'heat_loss_report').find_each(&:destroy) # Clean up before new ones are uploaded Upload.uploadify_from_data(file_name: result.file_name, data: result.pdf, category: 'heat_loss_report', resource: @room) flash[:info] = 'The Heat Loss report was saved and can be found in the attachments for this room' redirect_to room_configuration_path(@room, anchor: "attachments") else send_data result.pdf, filename: result.file_name, type: 'application/pdf', disposition: 'inline' end end end else flash[:error] = "Can't calculate heat loss yet: #{res[:errors].join(', ')}." @room.enter_heat_loss_info = true redirect_to enter_heat_loss_info_path_for_room(@room) end else flash[:error] = 'Heat Loss Calculation is only for indoor rooms.' render action: :show end else redirect_to(projects_path_for(@room, request.subdomain), flash: { error: 'Sorry we cannot find this room' }) end end |
#show_heat_loss_path_for(room, subdomain) ⇒ String
URL of the heat loss report page for the given subdomain
582 583 584 585 586 587 588 589 |
# File 'app/concerns/controllers/heat_loss.rb', line 582 def show_heat_loss_path_for(room, subdomain) case subdomain when 'crm' show_heat_loss_room_configuration_path(room) else show_heat_loss_my_room_path(room) end end |
#skylights_heat_loss_details ⇒ void
This method returns an undefined value.
Renders the skylights heat loss details step, starting a new skylight when none is selected
244 245 246 247 248 249 250 251 |
# File 'app/concerns/controllers/heat_loss.rb', line 244 def skylights_heat_loss_details set_skylights_variables @skylight ||= @room.ceiling.skylights.new respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#under_floor_heat_loss_details ⇒ void
This method returns an undefined value.
Renders the under-floor heat loss details step of the wizard
171 172 173 174 175 176 177 |
# File 'app/concerns/controllers/heat_loss.rb', line 171 def under_floor_heat_loss_details set_under_floor_variables respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#update_ceiling_type ⇒ void
This method returns an undefined value.
Refreshes ceiling insulation type options when the ceiling type changes
507 508 509 510 511 512 513 514 515 |
# File 'app/concerns/controllers/heat_loss.rb', line 507 def update_ceiling_type ceiling_type_id = params[:room].try(:[], :ceiling_attributes).try(:[], :ceiling_type_id).try(:to_i) @ceiling_insulation_type_options = CeilingInsulationType.(ceiling_type_id, @room) @ceiling_insulation_type_id = @room.ceiling.try(:ceiling_insulation_type_id) respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#update_door_type ⇒ void
This method returns an undefined value.
Refreshes door type, core type, and frame type ids when the door type changes
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'app/concerns/controllers/heat_loss.rb', line 558 def update_door_type @door_child_index = params[:child_index].to_i unless params[:child_index].nil? @exterior_wall_child_index = params[:exterior_wall_child_index].to_i if (door_attributes = params[:room].try(:[], :exterior_walls_attributes).try(:[], @exterior_wall_child_index.to_s).try(:[], :doors_attributes).try(:[], @door_child_index.to_s)) @door_type_id = door_attributes[:door_type_id].to_i @door_core_type_id = door_attributes[:door_core_type_id].to_i @door_frame_type_id = door_attributes[:door_frame_type_id].to_i end if (door = @room.exterior_walls.try(:[], @exterior_wall_child_index).try(:doors).try(:[], @door_child_index)) @door_type_id ||= door.door_type_id @door_core_type_id ||= door.door_core_type_id @door_frame_type_id ||= door.door_frame_type_id end respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#update_exterior_wall_type ⇒ void
This method returns an undefined value.
Refreshes exterior wall insulation type options when the exterior wall type changes
519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'app/concerns/controllers/heat_loss.rb', line 519 def update_exterior_wall_type @exterior_wall_child_index = params[:child_index].try(:to_i) @exterior_wall_type_id = params[:room].try(:[], :exterior_walls_attributes).try(:[], @exterior_wall_child_index.to_s).try(:[], :exterior_wall_type_id).try(:to_i) @exterior_wall_type_id ||= @room.try(:exterior_walls).try(:[], @exterior_wall_child_index).try(:exterior_wall_type_id) @exterior_wall_insulation_type_options = ExteriorWallInsulationType.(@exterior_wall_type_id, @room) @exterior_wall_insulation_type_id = @room.exterior_walls.try(:[], @exterior_wall_child_index).try(:exterior_wall_insulation_type_id) respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#update_under_floor_type ⇒ void
This method returns an undefined value.
Refreshes under-floor insulation type options when the under-floor type changes
495 496 497 498 499 500 501 502 503 |
# File 'app/concerns/controllers/heat_loss.rb', line 495 def update_under_floor_type under_floor_type_id = params.dig(:room, :under_floor_attributes, :under_floor_type_id)&.to_i @under_floor_insulation_type_options = UnderFloorInsulationType.(under_floor_type_id, @room) @under_floor_insulation_type_id = @room.try(:under_floor).try(:under_floor_insulation_type_id) respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#update_window_type ⇒ void
This method returns an undefined value.
Refreshes window type, glass type, and frame type ids when the window type changes
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'app/concerns/controllers/heat_loss.rb', line 534 def update_window_type @window_child_index = params[:child_index].try(:to_i) @exterior_wall_child_index = params[:exterior_wall_child_index].to_i if (window_attributes = params[:room].try(:[], :exterior_walls_attributes).try(:[], @exterior_wall_child_index.to_s).try(:[], :windows_attributes).try(:[], @window_child_index.to_s)) @window_type_id = window_attributes[:window_type_id].to_i @window_glass_type_id = window_attributes[:window_glass_type_id].to_i @window_frame_type_id = window_attributes[:window_frame_type_id].to_i end if (window = @room.exterior_walls.try(:[], @exterior_wall_child_index).try(:windows).try(:[], @window_child_index)) @window_type_id ||= window.window_type_id @window_glass_type_id ||= window.window_glass_type_id @window_frame_type_id ||= window.window_frame_type_id end respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |
#windows_heat_loss_details ⇒ void
This method returns an undefined value.
Renders the windows heat loss details step, starting a new window when none is selected
372 373 374 375 376 377 378 379 |
# File 'app/concerns/controllers/heat_loss.rb', line 372 def windows_heat_loss_details set_windows_variables @window ||= @exterior_wall.windows.new respond_to do |format| format.turbo_stream format.html { redirect_to enter_heat_loss_info_path_for_room(@room) } end end |