From 08f722c6d6d2328edf96d589af386d9ed4ca9e90 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Thu, 8 Dec 2022 10:40:19 -0500 Subject: [PATCH 1/3] CSR-803: fix navigate back scenarios involving multiple -questions pages --- src/mixins/vehicle-questions-mixin.js | 38 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index ede86dff5..493c5ef17 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -459,23 +459,31 @@ export default { }, // Can't use `this` because navigateForward is also called from quote navigateBack(vm) { - const self = vm ?? this; - const partsOrQuestions = ( - self.$store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS) ?? - self.$store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS) ?? - self.$store.getters.pageData(fmgPageValues.VEHICLE_PARTS) ?? - self.$store.getters.pageData(fmgPageValues.PART_QUESTIONS) - )?.partsOrQuestions; - const hasPartQuestions = this.hasPartQuestions(partsOrQuestions); - const hasGlassLocationWithMultipleParts = - this.hasGlassLocationWithMultipleParts(partsOrQuestions); - const hasChildPartQuestions = this.hasChildPartQuestions(partsOrQuestions); - const hasCapabilityQuestions = this.hasCapabilityQuestions(partsOrQuestions); - let backNavigationScenario = self.$store.getters.vehicle.vin - ? navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS - : navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS; + const self = vm ?? this; const currentPage = self.$route.query.fmgPage; + + const pageDataCapabilityQuestions = self.$store.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS); + const pageDataMoldingQuestions = self.$store.getters.pageData(fmgPageValues.MOLDING_QUESTIONS); + const pageDataVehicleParts = self.$store.getters.pageData(fmgPageValues.VEHICLE_PARTS); + const pageDataPartQuestions = self.$store.getters.pageData(fmgPageValues.PART_QUESTIONS); + + const currentPartsOrQuestions = ( + (currentPage !== fmgPageValues.CAPABILITY_QUESTIONS ? pageDataCapabilityQuestions : null) ?? + (currentPage !== fmgPageValues.MOLDING_QUESTIONS ? pageDataMoldingQuestions : null) ?? + (currentPage !== fmgPageValues.VEHICLE_PARTS ? pageDataVehicleParts : null) ?? + (currentPage !== fmgPageValues.PARTS_QUESTIONS ? pageDataPartQuestions : null) + )?.partsOrQuestions; + + const hasPartQuestions = this.hasPartQuestions(currentPartsOrQuestions); + const hasGlassLocationWithMultipleParts = this.hasGlassLocationWithMultipleParts(currentPartsOrQuestions); + const hasChildPartQuestions = this.hasChildPartQuestions(currentPartsOrQuestions); + const hasCapabilityQuestions = this.hasCapabilityQuestions(currentPartsOrQuestions); + + let backNavigationScenario = self.$store.getters.vehicle.vin + ? navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS + : navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS; + if ( hasCapabilityQuestions && this.currentPageComesAfterPage(currentPage, fmgPageValues.CAPABILITY_QUESTIONS) From 326429657c24f53ebe3a89fbe955bdedb61d5897 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Fri, 9 Dec 2022 10:03:57 -0500 Subject: [PATCH 2/3] CSR-803: refactoring for readability --- src/mixins/vehicle-questions-mixin.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 2ae850a6c..73f9103a8 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -472,16 +472,17 @@ export default { fmgPageValues.PART_QUESTIONS ); - const currentPartsOrQuestions = ( - (currentPage !== fmgPageValues.CAPABILITY_QUESTIONS - ? pageDataCapabilityQuestions - : null) ?? - (currentPage !== fmgPageValues.MOLDING_QUESTIONS - ? pageDataMoldingQuestions - : null) ?? - (currentPage !== fmgPageValues.VEHICLE_PARTS ? pageDataVehicleParts : null) ?? - (currentPage !== fmgPageValues.PARTS_QUESTIONS ? pageDataPartQuestions : null) - )?.partsOrQuestions; + let currentPartsOrQuestions = null; + + if (currentPage !== fmgPageValues.CAPABILITY_QUESTIONS && !!pageDataCapabilityQuestions) { + currentPartsOrQuestions = pageDataCapabilityQuestions?.partsOrQuestions; + } else if (currentPage !== fmgPageValues.MOLDING_QUESTIONS && !!pageDataMoldingQuestions) { + currentPartsOrQuestions = pageDataMoldingQuestions?.partsOrQuestions; + } else if (currentPage !== fmgPageValues.VEHICLE_PARTS && !!pageDataVehicleParts) { + currentPartsOrQuestions = pageDataVehicleParts?.partsOrQuestions; + } else if (currentPage !== fmgPageValues.PARTS_QUESTIONS && !!pageDataPartQuestions) { + currentPartsOrQuestions = pageDataPartQuestions?.partsOrQuestions; + } const hasPartQuestions = this.hasPartQuestions(currentPartsOrQuestions); const hasGlassLocationWithMultipleParts = From 2340a5da3be6fee77b5554a63cd45cc50c57b5ab Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Fri, 9 Dec 2022 11:04:46 -0500 Subject: [PATCH 3/3] wonderful prettier formatting changes... --- src/mixins/vehicle-questions-mixin.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 73f9103a8..8c5a5ae26 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -474,9 +474,15 @@ export default { let currentPartsOrQuestions = null; - if (currentPage !== fmgPageValues.CAPABILITY_QUESTIONS && !!pageDataCapabilityQuestions) { + if ( + currentPage !== fmgPageValues.CAPABILITY_QUESTIONS && + !!pageDataCapabilityQuestions + ) { currentPartsOrQuestions = pageDataCapabilityQuestions?.partsOrQuestions; - } else if (currentPage !== fmgPageValues.MOLDING_QUESTIONS && !!pageDataMoldingQuestions) { + } else if ( + currentPage !== fmgPageValues.MOLDING_QUESTIONS && + !!pageDataMoldingQuestions + ) { currentPartsOrQuestions = pageDataMoldingQuestions?.partsOrQuestions; } else if (currentPage !== fmgPageValues.VEHICLE_PARTS && !!pageDataVehicleParts) { currentPartsOrQuestions = pageDataVehicleParts?.partsOrQuestions;