Merge branch 'feature/CSR-6' into feature/CSR-120_vehicle-banner-2

This commit is contained in:
Adam Caouette 2021-11-29 13:13:29 -05:00
commit 314df2d116
4 changed files with 63 additions and 37 deletions

View file

@ -0,0 +1,31 @@
import { storeActions } from "@/constants/store-actions.js";
import { widgetNames } from "@/constants/widget-names.js";
import store from "@/store";
export function GetContentFromCms(fmgPage) {
return store.dispatch(storeActions.GET_PAGE_DATA, { pageName: fmgPage }).then((response) => {
const pageDataFromCms = {
isCmsContentReady: false
};
response.data.Result.forEach((widget) => {
if (Object.values(widgetNames).includes(widget.Type)) {
// If we already have this widget, push it on the collection
if (widget.Type in pageDataFromCms) {
pageDataFromCms[widget.Type].push(widget.Model);
return;
}
pageDataFromCms[widget.Type] = [widget.Model];
}
});
// Our 'Page' is ready because we have data now
pageDataFromCms.isCmsContentReady = true;
return pageDataFromCms;
});
}

View file

@ -211,6 +211,7 @@
/>
</div>
</div>
<<<<<<< HEAD
<div class="row my-2">
<div class="col">
<alert
@ -220,6 +221,19 @@
v-bind:isDismissible = "false"
/>
</div>
=======
<div class="row">
<div class="col my-3 d-flex align-items-center">
<buttonPrimary buttonText="Primary" @click="testMethod" />
</div>
</div>
<div class="my-3">
<div class="select-car">
<div class="select-car-form">
<radioQuestion questionText="What year is your vehicle?" :answers="this.years" />
</div>
</div>
>>>>>>> feature/CSR-6
</div>
<div class="row my-4">
<div class="col">

View file

@ -1,4 +1,4 @@
<template v-if="isCmsContentReady">
<template>
<div class="select-car">
<div class="select-car-form rounded text-center">
<vehicleBanner />
@ -12,6 +12,9 @@
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
import pageHeader from "@/ux-components/header/header";
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
import {
GetContentFromCms
} from "@/helpers/cms-adapter";
export default {
name: "vehicle-year",
@ -22,11 +25,14 @@ export default {
};
},
computed: {},
async created() {
const pageContent = await this.GetContentFromCms();
this.pageHeaderWidgets = pageContent.PageHeaderWidget[0];
this.radioQuestionWidgets = pageContent.RadioQuestionWidget[0];
beforeRouteEnter(to, from, next) {
GetContentFromCms(to.query.fmgPage).then((response) => {
console.log(response)
next(vm => {
vm.pageHeaderWidgets = response.PageHeaderWidget[0];
vm.radioQuestionWidgets = response.RadioQuestionWidget[0];
});
});
},
components: {
yearQuestion,

View file

@ -8,13 +8,13 @@ export default {
}
},
methods: {
// dispatchBlockingStoreAction(type, payload) {
// // globalMethods.showWaitingModal(true);
dispatchBlockingStoreAction(type, payload) {
// globalMethods.showWaitingModal(true);
// return this.dispatchNonBlockingStoreAction(type, payload).finally(() => {
// // globalMethods.showWaitingModal(false);
// });
// },
return this.dispatchNonBlockingStoreAction(type, payload).finally(() => {
// globalMethods.showWaitingModal(false);
});
},
dispatchNonBlockingStoreAction(type, payload, encodePayload = false) {
// Encode the payload if required
if (encodePayload) {
@ -23,31 +23,6 @@ export default {
return this.$store.dispatch(type, payload);
},
GetContentFromCms() {
return this.dispatchNonBlockingStoreAction(this.storeActions.GET_PAGE_DATA,{ pageName: this.$route.query.fmgPage }).then((response) => {
const pageDataFromCms = {};
response.data.Result.forEach((widget) => {
if (Object.values(this.widgetNames).includes(widget.Type)) {
// If we already have this widget, push it on the collection
if (widget.Type in pageDataFromCms) {
pageDataFromCms[widget.Type].push(widget.Model);
return;
}
pageDataFromCms[widget.Type] = [widget.Model];
}
});
// Our 'Page' is ready because we have data now
this.isCmsContentReady = true;
return pageDataFromCms;
});
},
},
computed: {
storeActions() {