improvements
This commit is contained in:
parent
d82c21c744
commit
43c6aed0a2
3 changed files with 23 additions and 14 deletions
|
|
@ -4,9 +4,7 @@ import store from "@/store";
|
|||
|
||||
export function fetchCmsContentForPage(fmgPage) {
|
||||
return store.dispatch(storeActions.GET_PAGE_DATA, { pageName: fmgPage }).then((response) => {
|
||||
const pageDataFromCms = {
|
||||
isCmsContentReady: false
|
||||
};
|
||||
const pageDataFromCms = {};
|
||||
|
||||
response.data.Result.forEach((widget) => {
|
||||
if (Object.values(widgetNames).includes(widget.Type)) {
|
||||
|
|
@ -20,9 +18,6 @@ export function fetchCmsContentForPage(fmgPage) {
|
|||
}
|
||||
});
|
||||
|
||||
// Our 'Page' is ready because we have data now
|
||||
pageDataFromCms.isCmsContentReady = true;
|
||||
|
||||
return pageDataFromCms;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<template v-if="isCmsContentReady">
|
||||
<template>
|
||||
<siteHeader :imageSrc="siteHeaderWidget.LogoImage" />
|
||||
<div class="select-car">
|
||||
<div class="select-car-form rounded text-center">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ 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";
|
||||
|
|
@ -73,30 +72,45 @@ const router = createRouter({
|
|||
routes,
|
||||
});
|
||||
|
||||
router.navigate = (scenario, currentRoute, optionalQuery, optionalParams) => {
|
||||
|
||||
//---------------------------------------------------------- Router Functions ----------------------------------------------------------
|
||||
|
||||
// Navigate to the next route, depending on the scenario.
|
||||
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}) => {
|
||||
|
||||
if (!scenario) {
|
||||
console.error("No scenario provided, navigating to 404 page.");
|
||||
console.error("No scenario provided. Please review the routing table.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 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 })
|
||||
});
|
||||
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one.
|
||||
router.push({ path: '/', query: Object.assign(optionalQuery, { fmgPage: matchingScenarioMap.destinationFmgPageValue }), params: optionalParams });
|
||||
} else if (matchingScenarioMap.destinationUrl !== undefined) {
|
||||
navigateToUrl(matchingScenarioMap.destinationUrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get navigation map depeding on the scenario and the current 'page' you're on.
|
||||
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];
|
||||
}
|
||||
|
||||
//---------------------------------------------------------- Private Functions ----------------------------------------------------------
|
||||
|
||||
|
||||
// Navigate to an external url.
|
||||
function navigateToUrl(url) {
|
||||
// possibly show some loading screen in the future here.
|
||||
window.location.assign(url);
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue