CSR-530 Add routing for experiment-integration
This commit is contained in:
parent
ffad30387b
commit
cefd25399e
4 changed files with 300 additions and 235 deletions
15
src/layouts/test-one.vue
Normal file
15
src/layouts/test-one.vue
Normal 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
15
src/layouts/test-two.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<template>
|
||||||
|
Test2
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "test2",
|
||||||
|
methods: {
|
||||||
|
arePagePrerequisitesValid() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -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
|
let 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 ----------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,27 @@
|
||||||
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) {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
fmgPageValue: fmgPageValues.VEHICLE_YEAR,
|
fmgPageValue: fmgPageValues.VEHICLE_YEAR,
|
||||||
maps: [
|
maps: [
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.SELECTED_YEAR,
|
||||||
|
destinationFmgPageValue: "test1",
|
||||||
|
filter: store.getters.vehicle.year > 2010
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.SELECTED_YEAR,
|
||||||
|
destinationFmgPageValue: "test2",
|
||||||
|
filter: store.getters.vehicle.year <= 2010
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.SELECTED_YEAR,
|
||||||
|
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.SELECTED_YEAR,
|
scenario: navigationScenarios.SELECTED_YEAR,
|
||||||
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
|
destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE,
|
||||||
|
|
@ -231,6 +248,7 @@ const routingTable = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export { routingTable };
|
export { routingTable };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue