created routing table logic
This commit is contained in:
parent
f19870cdaa
commit
d82c21c744
2 changed files with 25 additions and 7 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import { createWebHistory, createRouter } from "vue-router";
|
||||
import { storeActions } from "@/constants/store-actions.js";
|
||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||
import { routingTable } from "@/router/router-constants/routing-table.js";
|
||||
import { fmgPageValues } from '@/router/router-constants/fmgPage-values.js';
|
||||
import ComponentTest from "@/layouts/component-test/component-test.vue";
|
||||
import LoaderDemo from "@/layouts/loader-demo/loader-demo.vue";
|
||||
import NotFound from "@/layouts/not-found/not-found.vue";
|
||||
|
|
@ -65,22 +67,37 @@ const routes = [
|
|||
},
|
||||
];
|
||||
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory("/fmg/"),
|
||||
routes,
|
||||
});
|
||||
|
||||
router.navigate = (scenario, optionalQuery, optionalParams) =>
|
||||
{
|
||||
router.navigate = (scenario, currentRoute, optionalQuery, optionalParams) => {
|
||||
if (!scenario) {
|
||||
console.error("No scenario provided, navigating to 404 page.");
|
||||
}
|
||||
|
||||
// Match our maps up and navigate if we have a destination.
|
||||
const matchingScenarioMap = router.getNavigationMap(scenario, currentRoute);
|
||||
|
||||
if (matchingScenarioMap.destinationFmgPageValue !== undefined) {
|
||||
router.push({
|
||||
path: '/', query: Object.assign(currentRoute.query, { fmgPage: matchingScenarioMap.destinationFmgPageValue })
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
router.getNavigationMap = (scenario, currentRoute) =>
|
||||
{
|
||||
router.getNavigationMap = (scenario, currentRoute) => {
|
||||
const fmgPageValue = currentRoute.query.fmgPage;
|
||||
|
||||
const matchedQueryValue = routingTable.filter(item => (item.fmgPageValue === fmgPageValue) && item.maps.filter(map => map.scenario === scenario).length > 0).map(m => m.maps.filter(map => map.scenario === scenario));
|
||||
return matchedQueryValue[0][0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Get route information by page name.
|
||||
// This will reach out to the Cms and there is a 1:1 relationship between page names and route names.
|
||||
function GetRouteInfoFromPageName(pageName) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { fmgPageValues } from '@/router/router-constants/fmg-page-values';
|
||||
import { fmgPageValues } from '@/router/router-constants/fmgPage-values';
|
||||
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
|
||||
|
||||
const routingTable = [
|
||||
|
|
@ -7,7 +7,8 @@ const routingTable = [
|
|||
maps: [
|
||||
{ scenario: navigationScenarios.SELECTED_YEAR, destinationFmgPageValue: fmgPageValues.VEHICLE_MAKE }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
export { routingTable };
|
||||
Loading…
Reference in a new issue