Merge pull request #621 from Safelite/feature/CSR-530

Feature/csr 530
This commit is contained in:
katieoh-safelite 2022-07-20 09:39:30 -04:00 committed by GitHub
commit c400ee5a7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 295 additions and 235 deletions

15
src/layouts/test-one.vue Normal file
View file

@ -0,0 +1,15 @@
<template>
Test1
</template>
<script>
export default {
name: "test1",
methods: {
arePagePrerequisitesValid() {
return true;
}
}
}
</script>

15
src/layouts/test-two.vue Normal file
View file

@ -0,0 +1,15 @@
<template>
Test2
</template>
<script>
export default {
name: "test2",
methods: {
arePagePrerequisitesValid() {
return true;
}
}
}
</script>

View file

@ -19,7 +19,24 @@ import eventBus from "@/helpers/event-bus/event-bus";
import store from "@/store"; import store from "@/store";
import analyticsMixin from "@/mixins/analytics-mixin"; import analyticsMixin from "@/mixins/analytics-mixin";
import TestOne from "@/layouts/test-one";
import TestTwo from "@/layouts/test-two";
const routes = [ const routes = [
{
path: "/test1",
name: "test1",
components: {
default: TestOne
}
},
{
path: "/test2",
name: "test2",
components: {
default: TestTwo
}
},
{ {
path: "/", path: "/",
name: "root", name: "root",
@ -53,7 +70,6 @@ const routes = [
return next(false); return next(false);
} }
// Assign our fmgPage so it will load normally like the other pages. // Assign our fmgPage so it will load normally like the other pages.
to.query.fmgPage = pageToRedirectTo; to.query.fmgPage = pageToRedirectTo;
} }
@ -180,15 +196,16 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
// Get navigation map depending on the scenario and the current 'page' you're on. // Get navigation map depending on the scenario and the current 'page' you're on.
function getNavigationMap(scenario, currentRoute) { function getNavigationMap(scenario, currentRoute) {
const fmgPageValue = currentRoute.query.fmgPage; const fmgPageValue = currentRoute.query.fmgPage;
const matchedQueryValue = routingTable const matchedQueryValue = routingTable(store)
.filter( .filter(
(item) => (item) =>
item.fmgPageValue === fmgPageValue && item.fmgPageValue === fmgPageValue &&
item.maps.filter((map) => map.scenario === scenario).length > 0 item.maps.filter((map) => map.scenario === scenario).length > 0
) )
.map((m) => m.maps.filter((map) => map.scenario === scenario)); .map((m) => m.maps.filter((map) => map.scenario === scenario))[0]
.filter(x => x.filter === true || x.filter === undefined);
return matchedQueryValue[0][0]; return matchedQueryValue[0];
} }
//---------------------------------------------------------- Private Functions ---------------------------------------------------------- //---------------------------------------------------------- Private Functions ----------------------------------------------------------

View file

@ -1,236 +1,249 @@
import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
const routingTable = [ // Get store from router/index.js instead of importing it here to get updated values
{ const routingTable = function(store) {
fmgPageValue: fmgPageValues.VEHICLE_YEAR, return [
maps: [ {
{ fmgPageValue: fmgPageValues.VEHICLE_YEAR,
scenario: navigationScenarios.SELECTED_YEAR, maps: [
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE, {
}, scenario: navigationScenarios.SELECTED_YEAR,
], destinationFmgPageValue: "test1",
}, filter: store.getters.vehicle.year === 2010
{ },
fmgPageValue: fmgPageValues.VEHICLE_MAKE, {
maps: [ scenario: navigationScenarios.SELECTED_YEAR,
{ destinationFmgPageValue: "test2",
scenario: navigationScenarios.SELECTED_MAKE, filter: store.getters.vehicle.year < 1954
destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL, },
}, {
{ scenario: navigationScenarios.SELECTED_YEAR,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
destinationFmgPageValue: fmgPageValues.VEHICLE_YEAR, },
}, ],
], },
}, {
{ fmgPageValue: fmgPageValues.VEHICLE_MAKE,
fmgPageValue: fmgPageValues.VEHICLE_MODEL, maps: [
maps: [ {
{ scenario: navigationScenarios.SELECTED_MAKE,
scenario: navigationScenarios.SELECTED_MODEL, destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL,
destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, },
}, {
{ scenario: navigationScenarios.CLICKED_BACK,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_YEAR,
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE, },
}, ],
], },
}, {
{ fmgPageValue: fmgPageValues.VEHICLE_MODEL,
fmgPageValue: fmgPageValues.VEHICLE_STYLE, maps: [
maps: [ {
{ scenario: navigationScenarios.SELECTED_MODEL,
scenario: navigationScenarios.SELECTED_STYLE, destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE,
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, },
}, {
{ scenario: navigationScenarios.CLICKED_BACK,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL, },
}, ],
], },
}, {
{ fmgPageValue: fmgPageValues.VEHICLE_STYLE,
fmgPageValue: fmgPageValues.VEHICLE_DAMAGE, maps: [
maps: [ {
{ scenario: navigationScenarios.SELECTED_STYLE,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE, },
}, {
{ scenario: navigationScenarios.CLICKED_BACK,
scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN, destinationFmgPageValue: fmgPageValues.VEHICLE_MODEL,
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, },
}, ],
{ },
scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN, {
destinationFmgPageValue: fmgPageValues.ESTIMATE, fmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
}, maps: [
], {
}, scenario: navigationScenarios.CLICKED_BACK,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_STYLE,
fmgPageValue: fmgPageValues.VEHICLE_PARTS, },
maps: [ {
{ scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, },
}, {
{ scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
scenario: navigationScenarios.SELECTED_PARTS, destinationFmgPageValue: fmgPageValues.ESTIMATE,
destinationFmgPageValue: fmgPageValues.QUOTE, },
}, ],
{ },
scenario: navigationScenarios.CLICKED_FORWARD, {
destinationFmgPageValue: fmgPageValues.REVEAL, fmgPageValue: fmgPageValues.VEHICLE_PARTS,
}, maps: [
], {
}, scenario: navigationScenarios.CLICKED_BACK,
{ destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
fmgPageValue: fmgPageValues.REVEAL, },
maps: [ {
{ scenario: navigationScenarios.SELECTED_PARTS,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.QUOTE,
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, },
}, {
{ scenario: navigationScenarios.CLICKED_FORWARD,
scenario: navigationScenarios.SELECTED_PARTS, destinationFmgPageValue: fmgPageValues.REVEAL,
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, },
}, ],
], },
}, {
{ fmgPageValue: fmgPageValues.REVEAL,
fmgPageValue: fmgPageValues.VIN_LOOKUP, maps: [
maps: [ {
{ scenario: navigationScenarios.CLICKED_BACK,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
destinationFmgPageValue: fmgPageValues.ESTIMATE, },
}, {
{ scenario: navigationScenarios.SELECTED_PARTS,
scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, },
}, ],
{ },
scenario: navigationScenarios.CLICKED_BACK_WITH_VIN, {
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, fmgPageValue: fmgPageValues.VIN_LOOKUP,
}, maps: [
{ {
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS destinationFmgPageValue: fmgPageValues.ESTIMATE,
}, },
{ {
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
} },
], {
}, scenario: navigationScenarios.CLICKED_BACK_WITH_VIN,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
fmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP, },
maps: [ {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
destinationFmgPageValue: fmgPageValues.ESTIMATE, },
}, {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
scenario: navigationScenarios.CLICKED_FORWARD, destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, }
}, ],
{ },
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, {
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS fmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP,
}, maps: [
{ {
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS destinationFmgPageValue: fmgPageValues.ESTIMATE,
} },
], {
}, scenario: navigationScenarios.CLICKED_FORWARD,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
fmgPageValue: fmgPageValues.ADDRESS_LOOKUP, },
maps: [ {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
destinationFmgPageValue: fmgPageValues.ESTIMATE, },
}, {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
scenario: navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
destinationFmgPageValue: fmgPageValues.ADDRESS_VEHICLES, }
}, ],
{ },
scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, {
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, fmgPageValue: fmgPageValues.ADDRESS_LOOKUP,
}, maps: [
{ {
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS destinationFmgPageValue: fmgPageValues.ESTIMATE,
}, },
{ {
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, scenario: navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS destinationFmgPageValue: fmgPageValues.ADDRESS_VEHICLES,
} },
], {
}, scenario: navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS,
{ destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
fmgPageValue: fmgPageValues.ADDRESS_VEHICLES, },
maps: [ {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP, },
}, {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
scenario: navigationScenarios.CLICKED_FORWARD, destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, }
}, ],
{ },
scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, {
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS fmgPageValue: fmgPageValues.ADDRESS_VEHICLES,
}, maps: [
{ {
scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP,
}, },
{ {
scenario: navigationScenarios.SELECTED_PROVIDE_VIN_DIFFERENT_WAY, scenario: navigationScenarios.CLICKED_FORWARD,
destinationFmgPageValue: fmgPageValues.ESTIMATE destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
} },
], {
}, scenario: navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS,
{ destinationFmgPageValue: fmgPageValues.PART_QUESTIONS
fmgPageValue: fmgPageValues.ESTIMATE, },
maps: [ {
{ scenario: navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE, },
}, {
{ scenario: navigationScenarios.SELECTED_PROVIDE_VIN_DIFFERENT_WAY,
scenario: navigationScenarios.SELECTED_MANUAL_VIN, destinationFmgPageValue: fmgPageValues.ESTIMATE
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP, }
}, ],
{ },
scenario: navigationScenarios.SELECTED_LICENSE_PLATE, {
destinationFmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP, fmgPageValue: fmgPageValues.ESTIMATE,
}, maps: [
{ {
scenario: navigationScenarios.SELECTED_HOME_ADDRESS, scenario: navigationScenarios.CLICKED_BACK,
destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP, destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
}, },
], {
}, scenario: navigationScenarios.SELECTED_MANUAL_VIN,
{ destinationFmgPageValue: fmgPageValues.VIN_LOOKUP,
fmgPageValue: fmgPageValues.PART_QUESTIONS, },
maps: [ {
{ scenario: navigationScenarios.SELECTED_LICENSE_PLATE,
scenario: navigationScenarios.CLICKED_BACK, destinationFmgPageValue: fmgPageValues.LICENSE_PLATE_LOOKUP,
destinationFmgPageValue: fmgPageValues.VIN_LOOKUP },
}, {
{ scenario: navigationScenarios.SELECTED_HOME_ADDRESS,
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS, destinationFmgPageValue: fmgPageValues.ADDRESS_LOOKUP,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS },
}, ],
{ },
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_SINGLE_PART, {
destinationFmgPageValue: fmgPageValues.QUOTE, fmgPageValue: fmgPageValues.PART_QUESTIONS,
}, maps: [
] {
}, scenario: navigationScenarios.CLICKED_BACK,
]; destinationFmgPageValue: fmgPageValues.VIN_LOOKUP
},
{
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS,
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS
},
{
scenario: navigationScenarios.ANSWERED_QUESTIONS_WITH_SINGLE_PART,
destinationFmgPageValue: fmgPageValues.QUOTE,
},
]
},
];
}
export { routingTable }; export { routingTable };