import { storeActions } from "@/constants/store-actions.js"; import { storeMutations } from "@/constants/store-mutations.js"; import { widgetNames } from "@/constants/widget-names.js"; export default { data(){ return { isCmsContentReady: false } }, methods: { // dispatchBlockingStoreAction(type, payload) { // // globalMethods.showWaitingModal(true); // return this.dispatchNonBlockingStoreAction(type, payload).finally(() => { // // globalMethods.showWaitingModal(false); // }); // }, dispatchNonBlockingStoreAction(type, payload, encodePayload = false) { // Encode the payload if required if (encodePayload) { encodeUriData(payload); } 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() { return storeActions; }, storeMutations() { return storeMutations; }, widgetNames() { return widgetNames; }, }, }; function encodeUriData(payload) { if (payload && Object.keys(payload).length > 0) { // Loop through the payload and encode the values Object.keys(payload).forEach((key) => { payload[key] = encodeURIComponent(payload[key]); }); } }