Class: MyRoomsController
- Inherits:
-
BasePortalController
- Object
- ActionController::Base
- ApplicationController
- BasePortalController
- MyRoomsController
- Includes:
- Controllers::HeatLoss
- Defined in:
- app/controllers/my_rooms_controller.rb
Overview
Controller: my rooms.
Constant Summary
Constants included from HeatLossPathsHelper
HeatLossPathsHelper::HEAT_LOSS_ACTIONS
Constants included from Controllers::MasqueradeGuarded
Controllers::MasqueradeGuarded::DEFAULT_BLOCK_MESSAGE
Constants included from Controllers::AnalyticsEvents
Controllers::AnalyticsEvents::MAX_QUEUED_EVENTS, Controllers::AnalyticsEvents::SESSION_KEY
Constants included from Controllers::ErrorRendering
Controllers::ErrorRendering::NON_CONTENT_PATH_PREFIXES
Instance Method Summary collapse
-
#add_to_cart ⇒ void
Adds the room/heated space's quote to the customer's cart.
-
#apply_customer_pricing_on_login ⇒ void
Re-applies customer pricing to the room's first quote after login.
-
#cancel ⇒ void
Deletes or cancels the room/heated space depending on its state.
-
#cancel_design ⇒ void
Pulls a room/heated space out of design back to
more_information_required. -
#capture_measurements ⇒ void
Redirects to the measurement-capture flow matching the room's reception type.
-
#complete_redesign ⇒ void
Creates a room revision for a redesign request, requiring an explanatory note.
-
#complete_room_plan_tool ⇒ void
Completes the DesignTool2 room plan flow, generating the bill of materials.
-
#complete_upload ⇒ void
Saves an uploaded layout, clearing any existing floorplan, and finishes measurement.
-
#create ⇒ void
Creates a room/heated space from submitted params and routes to measurement capture.
-
#download_electrical_plan ⇒ void
Sends the electrical plan PDF for download.
-
#download_layout ⇒ void
Sends the room's original uploaded layout file for download.
-
#download_plan ⇒ void
Sends the installation plan PDF for download.
-
#duplicate ⇒ void
Duplicates the room/heated space and restarts measurement capture.
-
#edit ⇒ void
Renders the room/heated space edit form with its selectable options.
-
#electrical_plan_thumbnail ⇒ void
Redirects to a 304px-tall thumbnail of the electrical plan PDF.
-
#fetch_room_options ⇒ void
Loads the selectable room options (floor types, heating systems, voltages, and so on) used by the room form.
-
#finish_measurement ⇒ void
Sends the measured room/heated space to the design team, requiring login first.
-
#finish_move ⇒ void
Moves the room/heated space to the selected project.
-
#instant_quotes ⇒ Object
Legacy IQ actions - redirect to Quote Builder (deprecated in 2018).
-
#layout_small_thumbnail ⇒ void
Serves a 92x61 PNG thumbnail of the room's uploaded layout image.
-
#layout_thumbnail ⇒ void
Serves a 304px-tall PNG thumbnail of the room's uploaded layout image.
-
#mark_ready_for_design_on_login ⇒ void
Submits a draft room/heated space to the design team once the customer logs in.
-
#move ⇒ void
Renders the form for moving the room/heated space to another project.
-
#new ⇒ void
Builds a new room/heated space with default attributes for the current project.
-
#plan_small_thumbnail ⇒ void
Redirects to a 92x61 thumbnail of the installation plan PDF.
-
#plan_thumbnail ⇒ void
Redirects to a 304px-tall thumbnail of the installation plan PDF.
-
#redesign ⇒ void
Renders the redesign request form for the room/heated space.
-
#remove_from_cart ⇒ void
Removes the room/heated space from the customer's cart.
-
#request_design ⇒ void
Submits the room/heated space to the design team for an installation plan.
-
#select_project_details ⇒ void
Legacy IQ action — redirects project detail selection to the Quote Builder.
-
#set_report_errors_for ⇒ Object
protected
This controller instance set the model to use for detecting errors in the application_controller#write_flash_to_cookie method.
-
#set_variables ⇒ void
protected
Loads
@roomand@projectfrom params for each action, forcing authentication when neither can be found. -
#show ⇒ void
Displays a room/heated space quote, tracking the first view and optionally resetting a quote's discount.
-
#show_room_plan ⇒ void
Renders the room plan editor for the room, or 404 when no plan exists.
-
#update ⇒ void
Updates the room/heated space and project from submitted params.
-
#update_room_options ⇒ void
Refreshes the room option selects via Turbo Stream as form choices change.
-
#upload ⇒ void
Renders the layout upload form for a draft room/heated space.
Methods included from Controllers::HeatLoss
#ceiling_heat_loss_details, #complete_ceiling_heat_loss_details, #complete_doors_heat_loss_details, #complete_exterior_walls_heat_loss_details, #complete_heat_loss_info, #complete_room_heat_loss_details, #complete_skylights_heat_loss_details, #complete_under_floor_heat_loss_details, #complete_windows_heat_loss_details, #doors_heat_loss_details, #dupe_door_heat_loss_details, #dupe_exterior_wall_heat_loss_details, #dupe_skylight_heat_loss_details, #dupe_window_heat_loss_details, #enter_heat_loss_info, #exterior_walls_heat_loss_details, #heat_loss_details_summary, #projects_path_for, #remove_door_heat_loss_details, #remove_exterior_wall_heat_loss_details, #remove_skylight_heat_loss_details, #remove_window_heat_loss_details, #room_heat_loss_details, #set_ceiling_variables, #set_doors_variables, #set_exterior_walls_variables, #set_skylights_variables, #set_under_floor_variables, #set_windows_variables, #show_heat_loss, #show_heat_loss_path_for, #skylights_heat_loss_details, #under_floor_heat_loss_details, #update_ceiling_type, #update_door_type, #update_exterior_wall_type, #update_under_floor_type, #update_window_type, #windows_heat_loss_details
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
Methods inherited from BasePortalController
#current_ability, #portal_party, #set_catalog, #set_webpack
Methods included from Controllers::MasqueradeGuarded
block_while_masquerading, #masquerade_blocks?
Methods inherited from ApplicationController
#account_impersonated?, #add_to_flash, #after_sign_in_path_for, #bypass_forgery_protection?, #chat_enabled?, #cloudflare_cleared?, #default_catalog, #default_url_options, #enable_turbo_frames, #find_publication, #fix_invalid_accept_header, #init_js_utils, #is_globals_call?, #layout_by_resource, #locale_store, #redirect_to, #require_employee_for_crm, #set_base_host, #set_real_ip, #should_render_layout?, #skip_layout_for_turbo_frame?, #stamp_impersonation_context, #tab_frame_breakout_request?, #warmlyyours_canada_ip?, #warmlyyours_ip?, #y
Methods included from Controllers::ReturnPathHandling
#check_for_return_path, #redirect_to_return_path_or_default
Methods included from Controllers::AnalyticsEvents
#consume_queued_analytics_events, #registration_lead_type, #track_event
Methods included from Controllers::DeviceDetection
Methods included from Controllers::SubdomainDetection
#is_crm_request?, #is_www_request?, #json_request?
Methods included from Controllers::TurboSafeRedirect
Methods included from Controllers::TrackingDetection
#bot_request?, #gdpr_country?, #gdpr_country_data, #prevent_bots, #set_tracking_cookie, #track_visitor?
Methods included from Controllers::AcceleratedFileSending
#send_file_accelerated, #send_upload_accelerated
Methods included from Controllers::ErrorRendering
#excp_string, #mail_to_for_error_reporting, #render_400, #render_404, #render_406, #render_410, #render_500, #render_invalid_authenticity_token, #render_ip_spoof_error, #render_unpermitted_parameters, #safe_referer_or_fallback
Methods included from Controllers::TurnstileVerification
#load_turnstile_script_tag, #turnstile_lazy_widget, #turnstile_script_tag, #turnstile_widget, #validate_turnstile!
Methods included from Controllers::CloudflareCaching
edge_cached, #edge_cached_action?, #reset_cloudflare_cache, #set_cloudflare_cache, #skip_edge_cache!, #skip_session
Methods included from Controllers::Webpackable
#preload_webpack_fonts, #webpack_css_include, #webpack_css_url, #webpack_js_include, #wpd_is_running?
Methods included from Controllers::Localizable
#cloudflare_country_locale, #determine_request_locale, #geocoder_locale, #guest_user_locale_check, #locale_optional_www_auth_path?, #param_locale, #set_locale, #set_request_locale, #skip_localization?, #warmlyyours_ip_locale
Methods included from Controllers::Authenticable
#access_denied, #authenticate_account, #authenticate_account!, #authenticate_account_from_login_token!, #check_is_a_manager, #check_is_a_sales_manager, #check_is_an_admin, #check_is_an_employee, #check_party, #clear_mismatched_guest_user, #create_guest_user, #credentials?, #current_or_guest_user, #current_or_guest_user_id_read_only, #current_user, #devise_mapping, #fully_logged_in?, #generate_bot_id, #guest_user, #identifiable?, #init_current_user, #initialize_guest, #load_context_user, #logging_in, #resource, #resource_name, #restrict_access_for_non_employees, #scrubbed_request_path, #user_object, #warn_on_session_guest_id_leak
Methods included from UrlsHelper
#catalog_breadcrumb_links, #catalog_link, #catalog_link_for_product_line, #catalog_link_for_sku, #cms_link, #delocalized_path, #path_to_sales_product_sku, #path_to_sales_product_sku_for_product_line, #path_to_sales_product_sku_for_product_line_slug, #product_line_from_catalog_link, #protocol_neutral_url, #sanitize_external_url, #valid_external_url?
Instance Method Details
#add_to_cart ⇒ void
This method returns an undefined value.
Adds the room/heated space's quote to the customer's cart.
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'app/controllers/my_rooms_controller.rb', line 405 def add_to_cart @cart = @context_user.cart if @cart.room_configuration_ids.include? @room.id flash[:warning] = 'This room/heated space is already in your cart.' redirect_to_return_path_or_default my_cart_path elsif @room.in_design? flash[:warning] = "This room/heated space is in design and can't be added to your cart. To buy the room/heated space please cancel the design request and then add it to you cart. All orders with room/heated space layouts will ship with a free installation plan." redirect_to_return_path_or_default my_room_path(@room) elsif !@room.can_add_to_cart? flash[:warning] = "This room can't be added to your cart yet. It must have items and not be pending measurement or being designed." redirect_to_return_path_or_default my_room_path(@room) else track_event('Cart - Product Added', { quoteId: @room.id, roomType: @room.reception_type, value: @room.total }) quote = @room.quotes.completed_quotes.last || @room.quotes.pending.last quote ||= Quote.auto_quote_from_room(@room, force_single_origin: true) notice = "Your room/heated space #{@room.name} has been added to your cart. " flash[:info] = notice redirect_to add_to_cart_my_quote_path(quote, room_id: @room.id) end end |
#apply_customer_pricing_on_login ⇒ void
This method returns an undefined value.
Re-applies customer pricing to the room's first quote after login.
530 531 532 533 534 535 536 |
# File 'app/controllers/my_rooms_controller.rb', line 530 def apply_customer_pricing_on_login if @room && (q = @room.quotes.first) q.reset_discount flash[:info] = 'Quote and room/heated space were saved.' end redirect_to my_room_path(@room) end |
#cancel ⇒ void
This method returns an undefined value.
Deletes or cancels the room/heated space depending on its state.
446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'app/controllers/my_rooms_controller.rb', line 446 def cancel if @room.ok_to_delete? @room.destroy flash[:info] = "Room/heated space #{@room.name} was deleted" redirect_to_return_path_or_default my_project_path(@project) elsif @room.ok_to_customer_cancel? @room.cancel flash[:info] = "Room/heated space #{@room.name} was cancelled" redirect_to_return_path_or_default my_project_path(@project) else flash[:error] = "Room/heated space #{@room.name} is not in a state where it can be cancelled" redirect_to_return_path_or_default my_room_path(@room) end end |
#cancel_design ⇒ void
This method returns an undefined value.
Pulls a room/heated space out of design back to more_information_required.
274 275 276 277 278 279 280 281 282 |
# File 'app/controllers/my_rooms_controller.rb', line 274 def cancel_design if @room.in_design? flash[:info] = 'Your room/heated space was pulled out of design.' @room.more_information_required elsif !@room.draft? # already there flash[:error] = 'Your room/heated space cannot be pulled out of design in this state.' end redirect_to my_room_path(@room) end |
#capture_measurements ⇒ void
This method returns an undefined value.
Redirects to the measurement-capture flow matching the room's reception type.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'app/controllers/my_rooms_controller.rb', line 286 def capture_measurements @room ||= @project.room_configurations.find(params[:id]) @room.reception_type ||= 'DesignTool' redirect_path = case @room.reception_type when 'DesignTool2' if @room.room_plan edit_room_plan_path(@room.room_plan, room_configuration_id: @room.id) else new_room_plan_path(room_configuration_id: @room.id) end when 'QuickEstimator' when 'Fax' when 'Upload' upload_my_room_path(@room) when 'HeatLossCalculator' enter_heat_loss_info_my_room_path(@room) else my_room_path(@room) end redirect_to redirect_path end |
#complete_redesign ⇒ void
This method returns an undefined value.
Creates a room revision for a redesign request, requiring an explanatory note.
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'app/controllers/my_rooms_controller.rb', line 467 def complete_redesign @room.attributes = params[:room] new_note = @room.new_note @room.errors.add(:new_note, 'To ensure the best service possible, please provide a note explaining your redesign request.') if new_note.blank? if @room.errors.empty? copy_specs = @room.reception_type == 'Unspecified' @room = @room.create_revision(false, copy_specs, false) @room.new_note = new_note if @room.reception_type == 'Unspecified' # Automatic redesign if @room.send_to_engineering_and_create_crm_quote flash[:info] = "Room/heated space #{@room.name} with installation plan number: #{@room.reference_number} was submitted to our engineering team for design" else flash[:error] = "Could not request plan: #{@room.errors_to_s}, #{@room.quotes.last&.errors_to_s}" end redirect_to my_project_path(@project) else capture_measurements end else render :redesign, status: :unprocessable_content end end |
#complete_room_plan_tool ⇒ void
This method returns an undefined value.
Completes the DesignTool2 room plan flow, generating the bill of materials.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'app/controllers/my_rooms_controller.rb', line 352 def complete_room_plan_tool if @room.draft? if @room.room_plan # DesignTool2 will destroy the room's floorplan and line items @room.floorplan_xml = nil @room.reception_type = 'DesignTool2' @room.reception_date = Time.current insulation_sqft = @room.room_plan.room_area&.round(2) @room.insulation_surface = insulation_sqft if insulation_sqft # put nominal value here until we can calculate heated areas. This prevents weird validation issues of last square footage being larger than current insulation_surface @room.square_footage = @room.insulation_surface * 0.9 if @room.insulation_surface sqft = @room.room_plan.heated_sq_ft&.round(2) @room.square_footage = sqft if sqft && (sqft > 0) # DesignTool2 will destroy the room's floorplan and line items @room.floorplan_xml = nil if @room.save @room.generate_bill_of_materials finish_measurement else flash.now[:error] = "There was an error saving room/heated space! #{@room.errors.&.join(', ')}" render :show, status: :unprocessable_content end else redirect_to(my_room_path(@room), flash: { error: 'Room/heated space layout not found' }) end else redirect_to(my_room_path(@room), flash: { error: 'Room/heated space cannot receive a new layout in this state' }) end end |
#complete_upload ⇒ void
This method returns an undefined value.
Saves an uploaded layout, clearing any existing floorplan, and finishes measurement.
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'app/controllers/my_rooms_controller.rb', line 320 def complete_upload if @room.draft? @room.attributes = params[:room] @room.reception_type = 'Upload' @room.reception_date = Time.current # uploading will destroy the room's floorplan and line items @room.floorplan_xml = nil if @room.save finish_measurement else render :upload, status: :unprocessable_content end else redirect_to(my_room_path(@room), flash: { error: 'Room/heated space cannot receive a new layout in this state' }) end end |
#create ⇒ void
This method returns an undefined value.
Creates a room/heated space from submitted params and routes to measurement capture.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'app/controllers/my_rooms_controller.rb', line 181 def create @project.update(params[:opportunity]) if params[:opportunity].present? @room = @project.room_configurations.new(params[:room]) @room.currency = @context_user.customer.catalog.currency @room.reception_type ||= 'DesignTool' @room.name = @project.next_room_name(room_base_name: @room.name, room_type: @room.room_type, heating_system_product_line: @room.heating_system_product_line) if @room.save capture_measurements else @move_to_project_options = (@context_user || @party).opportunities.not_cancelled.to_a.push(@project).uniq.map { |p| [p.name, p.id] } render action: :new, status: :unprocessable_content end end |
#download_electrical_plan ⇒ void
This method returns an undefined value.
Sends the electrical plan PDF for download.
153 154 155 156 157 158 159 160 |
# File 'app/controllers/my_rooms_controller.rb', line 153 def download_electrical_plan ep = @room.electrical_plan_pdf if ep.present? send_upload_accelerated ep else render plain: 'File is missing', status: :not_found end end |
#download_layout ⇒ void
This method returns an undefined value.
Sends the room's original uploaded layout file for download.
95 96 97 98 99 100 101 102 103 |
# File 'app/controllers/my_rooms_controller.rb', line 95 def download_layout rf = @room.room_layout_image if rf.present? file_path = rf..path send_file_accelerated file_path, mime_type: rf.mime_type else render plain: 'File is missing', status: :not_found end end |
#download_plan ⇒ void
This method returns an undefined value.
Sends the installation plan PDF for download.
130 131 132 133 134 135 136 137 |
# File 'app/controllers/my_rooms_controller.rb', line 130 def download_plan ip = @room.installation_plan_pdf if ip.present? send_upload_accelerated ip else render plain: 'File is missing', status: :not_found end end |
#duplicate ⇒ void
This method returns an undefined value.
Duplicates the room/heated space and restarts measurement capture.
493 494 495 496 |
# File 'app/controllers/my_rooms_controller.rb', line 493 def duplicate @room = @room.create_revision(false, true, false) capture_measurements end |
#edit ⇒ void
This method returns an undefined value.
Renders the room/heated space edit form with its selectable options.
173 174 175 176 177 |
# File 'app/controllers/my_rooms_controller.rb', line 173 def edit @force_hlc = true if params[:force_hlc].to_s.downcase.index('t').present? @move_to_project_options = (@context_user || @party).opportunities.not_cancelled.order('opportunities.created_at DESC').to_a.push(@project).uniq.map { |p| [p.name, p.id] } end |
#electrical_plan_thumbnail ⇒ void
This method returns an undefined value.
Redirects to a 304px-tall thumbnail of the electrical plan PDF.
141 142 143 144 145 146 147 148 149 |
# File 'app/controllers/my_rooms_controller.rb', line 141 def electrical_plan_thumbnail plan = @room.electrical_plan_pdf if plan.present? expires_in 1.day redirect_to plan.pdf_thumbnail_url('x304>') else render plain: 'File is missing', status: :not_found end end |
#fetch_room_options ⇒ void
This method returns an undefined value.
Loads the selectable room options (floor types, heating systems, voltages,
and so on) used by the room form.
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'app/controllers/my_rooms_controller.rb', line 245 def @new_room = params[:id].nil? update_room_name = true update_room_name = false if params[:room_name_touched].present? || !@new_room result = GetRoomOptions.new.process(@context_user.customer.store.id, @room, room_params: params[:room], update_room_name: update_room_name, public: true, installation_postal_code: @installation_postal_code, room_quoting_method: params[:room_quoting_method] || 'engineering') # here we 'force' engineering as default since the instant quoting process is not via my_room form @room_type = result.room_type @environment = result.environment @sub_floor_type_options = result. @sub_floor_type = result.sub_floor_type @sub_floor_type_id = result.sub_floor_type_id @floor_type_options = result. @floor_type = result.floor_type @floor_type_id = result.floor_type_id @heating_system_product_line_options = result. @heating_system_product_line = result.heating_system_product_line @heating_system_product_line_id = result.heating_system_product_line_id @voltages = result. @voltage_id = result.voltage_id @require_cable_spacing = result.require_cable_spacing @cable_spacing = result.cable_spacing @default_cable_spacings = HeatingElementProductLineOption.default_cable_spacings @recommended_cable_spacings = HeatingElementProductLineOption.default_cable_spacings(@installation_postal_code, @sub_floor_type, @floor_type) @coverage_state = result.coverage_state @room_name = result.room_name logger.debug "fetch_room_options, result.inspect: #{result.inspect}" end |
#finish_measurement ⇒ void
This method returns an undefined value.
Sends the measured room/heated space to the design team, requiring login first.
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'app/controllers/my_rooms_controller.rb', line 384 def finish_measurement # remove BOM line items if EV Easy Mat and not ev2help @room.new_note = 'Customer requested EV2 help' if (@room.heating_system_type_name == 'Environ Easy Mat') && (params[:ev2help] == 'true') if current_account # if (@room.draft? and current_account and @room.reception_type != "DesignTool") or (@room.reception_type == "DesignTool" and (!@room.heated_areas_calculated? or params[:ev2help] == "true" or @room.heating_system_type_name == "Environ Easy Mat")) if @room.send_to_engineering_and_create_crm_quote flash[:info] = "Your room/heated space #{@room.name} with installation plan number: #{@room.reference_number} was submitted to our design team for an installation plan." else flash[:error] = "Your room/heated space #{@room.name} is not ready to send to our design team for an installation plan. #{@room.errors_to_s} #{@room.quotes.last&.errors_to_s}" end end if current_account redirect_to my_room_path(@room) else # puts "finish_measurement, request.fullpath: #{request.fullpath}, request.referer: #{request.referer}" authenticate_account(after_authenticate_path: mark_ready_for_design_on_login_my_room_path(@room)) end end |
#finish_move ⇒ void
This method returns an undefined value.
Moves the room/heated space to the selected project.
506 507 508 509 510 511 512 513 514 515 |
# File 'app/controllers/my_rooms_controller.rb', line 506 def finish_move if @room.update(params[:room]) flash[:info] = "Room/heated space was moved to #{@room.opportunity.name}." redirect_to_return_path_or_default my_room_path(@room) else flash.now[:error] = "Unable to move room/heated space. #{@room.errors_to_s}" @move_to_project_options = (@context_user || @party).opportunities.not_cancelled.to_a.push(@project).uniq.map { |p| [p.name, p.id] } render :move, status: :unprocessable_content end end |
#instant_quotes ⇒ Object
Legacy IQ actions - redirect to Quote Builder (deprecated in 2018)
518 519 520 |
# File 'app/controllers/my_rooms_controller.rb', line 518 def instant_quotes redirect_to quote_builder_path, allow_other_host: true end |
#layout_small_thumbnail ⇒ void
This method returns an undefined value.
Serves a 92x61 PNG thumbnail of the room's uploaded layout image.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/my_rooms_controller.rb', line 75 def layout_small_thumbnail rf = @room.room_layout_image if rf.present? && rf..present? expires_in 1.day if rf.is_image? file_path = rf..thumb('92x61>', frame: '0', format: 'png').path send_file_accelerated file_path, file_name: "layout_small_thumbnail_#{@room.id}.png", mime_type: 'image/png' elsif rf.is_pdf? redirect_to rf.pdf_thumbnail_url('92x61>') else file_path = Rails.public_path.join('images/no-thumb-250.jpg') send_file_accelerated file_path, mime_type: 'image/jpeg' end else render plain: 'File is missing', status: :not_found end end |
#layout_thumbnail ⇒ void
This method returns an undefined value.
Serves a 304px-tall PNG thumbnail of the room's uploaded layout image.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/my_rooms_controller.rb', line 56 def layout_thumbnail rf = @room.room_layout_image if rf.present? && rf..present? if rf.is_image? file_path = rf..thumb('x304>', frame: '0', format: 'png').path send_file_accelerated(file_path, mime_type: 'image/png') elsif rf.is_pdf? redirect_to rf.pdf_thumbnail_url('x304>') else file_path = Rails.public_path.join('images/no-thumb-250.jpg') send_file_accelerated(file_path, mime_type: 'image/jpeg') end else render plain: 'File is missing', status: :not_found end end |
#mark_ready_for_design_on_login ⇒ void
This method returns an undefined value.
Submits a draft room/heated space to the design team once the customer logs in.
339 340 341 342 343 344 345 346 347 348 |
# File 'app/controllers/my_rooms_controller.rb', line 339 def mark_ready_for_design_on_login if @room&.draft? && current_account && (@room.reception_type != 'DesignTool') if @room.send_to_engineering_and_create_crm_quote flash[:info] = "Your room/heated space #{@room.name} with installation plan reference number: #{@room.reference_number} was submitted to our design team for an installation plan." else flash[:error] = "Your room/heated space #{@room.name} is not ready to send to our design team for an installation plan. #{@room.errors_to_s} #{@room.quotes.last&.errors_to_s}" end end redirect_to my_room_path(@room) end |
#move ⇒ void
This method returns an undefined value.
Renders the form for moving the room/heated space to another project.
500 501 502 |
# File 'app/controllers/my_rooms_controller.rb', line 500 def move @move_to_project_options = (@context_user || @party).opportunities.not_cancelled.to_a.push(@project).uniq.map { |p| [p.name, p.id] } end |
#new ⇒ void
This method returns an undefined value.
Builds a new room/heated space with default attributes for the current project.
164 165 166 167 168 169 |
# File 'app/controllers/my_rooms_controller.rb', line 164 def new @room = @project.room_configurations.new(RoomConfiguration.default_attributes(@project.customer.store.id).merge(name: 'My Room', reception_type: params[:reception_type] || 'DesignTool')) @move_to_project_options = (@context_user || @party).opportunities.not_cancelled.to_a.push(@project).uniq.map { |p| [p.name, p.id] } @room.name = @room_name end |
#plan_small_thumbnail ⇒ void
This method returns an undefined value.
Redirects to a 92x61 thumbnail of the installation plan PDF.
118 119 120 121 122 123 124 125 126 |
# File 'app/controllers/my_rooms_controller.rb', line 118 def plan_small_thumbnail plan = @room.installation_plan_pdf if plan.present? expires_in 1.day redirect_to plan.pdf_thumbnail_url('92x61>') else render plain: 'File is missing', status: :not_found end end |
#plan_thumbnail ⇒ void
This method returns an undefined value.
Redirects to a 304px-tall thumbnail of the installation plan PDF.
107 108 109 110 111 112 113 114 |
# File 'app/controllers/my_rooms_controller.rb', line 107 def plan_thumbnail plan = @room.installation_plan_pdf if plan.present? redirect_to plan.pdf_thumbnail_url('x304>') else render plain: 'File is missing', status: :not_found end end |
#redesign ⇒ void
This method returns an undefined value.
Renders the redesign request form for the room/heated space.
463 |
# File 'app/controllers/my_rooms_controller.rb', line 463 def redesign; end |
#remove_from_cart ⇒ void
This method returns an undefined value.
Removes the room/heated space from the customer's cart.
433 434 435 436 437 438 439 440 441 442 |
# File 'app/controllers/my_rooms_controller.rb', line 433 def remove_from_cart @cart = @context_user.cart res_hash = @cart.remove_room_configuration(@room) if res_hash[:status] flash[:info] = res_hash[:message] else flash[:error] = res_hash[:message] end redirect_to_return_path_or_default my_room_path(@room) end |
#request_design ⇒ void
This method returns an undefined value.
Submits the room/heated space to the design team for an installation plan.
198 199 200 201 202 203 204 205 206 |
# File 'app/controllers/my_rooms_controller.rb', line 198 def request_design @room.attributes = params[:room] if @room.send_to_engineering_and_create_crm_quote flash[:info] = "Your room/heated space #{@room.name} with installation plan number: #{@room.reference_number} was submitted to our design team for an installation plan and bill of materials." else flash[:error] = "Your room/heated space #{@room.name} is not ready to send to our design team for an installation plan. #{@room.errors_to_s} #{@room.quotes.last&.errors_to_s}" end redirect_to_return_path_or_default my_room_path(@room) end |
#select_project_details ⇒ void
This method returns an undefined value.
Legacy IQ action — redirects project detail selection to the Quote Builder.
524 525 526 |
# File 'app/controllers/my_rooms_controller.rb', line 524 def select_project_details redirect_to quote_builder_path, allow_other_host: true end |
#set_report_errors_for ⇒ Object (protected)
This controller instance set the model to use for detecting errors in the application_controller#write_flash_to_cookie method.
541 542 543 544 |
# File 'app/controllers/my_rooms_controller.rb', line 541 def set_report_errors_for @report_errors_for ||= [] @report_errors_for << @room end |
#set_variables ⇒ void (protected)
This method returns an undefined value.
Loads @room and @project from params for each action, forcing
authentication when neither can be found.
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
# File 'app/controllers/my_rooms_controller.rb', line 549 def set_variables if params[:id].present? @room = begin RoomConfiguration.find(params[:id]) rescue StandardError nil end # @room = @context_user.customer.room_configurations.find(params[:id]) rescue nil @project = @room.opportunity if @room elsif params[:my_project_id].present? @project = begin @context_user.customer.opportunities.find(params[:my_project_id]) rescue StandardError nil end end @installation_postal_code = @project&.installation_postal_code return if @room || @project flash[:error] = 'Room/heated space or Project not found or not authorized' authenticate_account! # this should never happen... end |
#show ⇒ void
This method returns an undefined value.
Displays a room/heated space quote, tracking the first view and optionally
resetting a quote's discount.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/my_rooms_controller.rb', line 18 def show if @room track_event('My Account - Quote Viewed', { quoteId: @room.id, roomType: @room.reception_type }) unless @room.first_view_date @first_view = @room.first_view_date.nil? @room.update_attribute!(:first_view_date, Time.current) if @first_view @room_configuration = @room if params[:update_discount_for_quote_id].present? q = begin @room.quotes.find(params[:update_discount_for_quote_id]) rescue StandardError nil end q&.reset_discount end respond_to do |format| format.html format.json do render json: @room_configuration end end else redirect_to(my_projects_path, flash: { error: 'Sorry, we cannot find this room/heated space' }) end end |
#show_room_plan ⇒ void
This method returns an undefined value.
Renders the room plan editor for the room, or 404 when no plan exists.
45 46 47 48 49 50 51 52 |
# File 'app/controllers/my_rooms_controller.rb', line 45 def show_room_plan @room_plan = @room.room_plan if @room if @room_plan.present? render layout: 'www/design_tool' else render plain: 'Plan is missing', status: :not_found end end |
#update ⇒ void
This method returns an undefined value.
Updates the room/heated space and project from submitted params.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'app/controllers/my_rooms_controller.rb', line 210 def update @room.room_type_id @room.floor_type_id @room.heating_system_product_line_id nil edit_fp = nil params[:room][:name] = @project.next_room_name(room_base_name: params[:room][:name]) # puts "my_rooms/update: OLD room_type: #{old_room_type_id}, floor_type: #{old_floor_type_id}" if @room.update(params[:room]) && (params[:opportunity].blank? || @project.update(params[:opportunity])) redirect_to capture_measurements_my_room_path(@room, edit_fp: edit_fp) else flash[:error] = "There was a problem updating your room/heated space. #{@room.errors_to_s} #{@project.errors_to_s}" @move_to_project_options = (@context_user || @party).opportunities.not_cancelled.to_a.push(@project).uniq.map { |p| [p.name, p.id] } render action: :edit, status: :unprocessable_content end end |
#update_room_options ⇒ void
This method returns an undefined value.
Refreshes the room option selects via Turbo Stream as form choices change.
231 232 233 234 235 236 237 238 239 240 |
# File 'app/controllers/my_rooms_controller.rb', line 231 def respond_to do |format| format.html do # the only way this happens is if the session ends while editing the room, and they sign in again, so go back to editing the room redirect_to edit_my_room_path(@room) end format.turbo_stream end end |
#upload ⇒ void
This method returns an undefined value.
Renders the layout upload form for a draft room/heated space.
310 311 312 313 314 315 316 |
# File 'app/controllers/my_rooms_controller.rb', line 310 def upload if @room redirect_to(my_room_path(@room), flash: { error: 'Room/heated space cannot receive a new layout in this state' }) unless @room.draft? else redirect_to(my_projects_path, flash: { error: 'Sorry we cannot find this room/heated space' }) end end |