Added Promise.All
This commit is contained in:
parent
b0257ecd46
commit
d3d880b2b3
3 changed files with 35 additions and 33 deletions
|
|
@ -2,7 +2,7 @@ import { storeActions } from "@/constants/store-actions.js";
|
||||||
import { widgetNames } from "@/constants/widget-names.js";
|
import { widgetNames } from "@/constants/widget-names.js";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
|
||||||
export function GetContentFromCms(fmgPage) {
|
export function fetchCmsContentForPage(fmgPage) {
|
||||||
return store.dispatch(storeActions.GET_PAGE_DATA, { pageName: fmgPage }).then((response) => {
|
return store.dispatch(storeActions.GET_PAGE_DATA, { pageName: fmgPage }).then((response) => {
|
||||||
|
|
||||||
const pageDataFromCms = {
|
const pageDataFromCms = {
|
||||||
|
|
@ -18,7 +18,6 @@ export function GetContentFromCms(fmgPage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pageDataFromCms[widget.Type] = [widget.Model];
|
pageDataFromCms[widget.Type] = [widget.Model];
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1,40 +1,46 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="select-car">
|
<div class="select-car">
|
||||||
<div class="select-car-form rounded text-center">
|
<div class="select-car-form rounded text-center">
|
||||||
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
||||||
<yearQuestion :questionText="radioQuestionWidgets.QuestionText" />
|
<yearQuestion :questionText="radioQuestionWidgets.QuestionText" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
||||||
import pageHeader from "@/ux-components/header/header";
|
import pageHeader from "@/ux-components/header/header";
|
||||||
import {
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
GetContentFromCms
|
import store from "@/store";
|
||||||
} from "@/helpers/cms-adapter";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "vehicle-year",
|
name: "vehicle-year",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
pageHeaderWidgets: {},
|
pageHeaderWidgets: {},
|
||||||
radioQuestionWidgets: {},
|
radioQuestionWidgets: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
beforeRouteEnter(to, from, next) {
|
beforeRouteEnter(to, from, next) {
|
||||||
GetContentFromCms(to.query.fmgPage).then((response) => {
|
|
||||||
console.log(response)
|
Promise.allSettled([
|
||||||
next(vm => {
|
fetchCmsContentForPage(to.query.fmgPage),
|
||||||
vm.pageHeaderWidgets = response.PageHeaderWidget[0];
|
store.dispatch(storeActions.GET_VEHICLE_YEARS, {}),
|
||||||
vm.radioQuestionWidgets = response.RadioQuestionWidget[0];
|
]).then(([contentPromise, getYearsPromise]) => {
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
// Call our next function to transition to the next page.
|
||||||
components: {
|
next((vm) => {
|
||||||
yearQuestion,
|
vm.pageHeaderWidgets = contentPromise.value.PageHeaderWidget[0];
|
||||||
pageHeader,
|
vm.radioQuestionWidgets = contentPromise.value.RadioQuestionWidget[0];
|
||||||
},
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
yearQuestion,
|
||||||
|
pageHeader,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.dispatchNonBlockingStoreAction(this.storeActions.GET_VEHICLE_YEARS, {}).then((response) => {
|
|
||||||
this.years = response.data;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
radioQuestion,
|
radioQuestion,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue