58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
import { storeActions } from "@/constants/storeActions.js";
|
|
import { widgetNames } from "@/constants/widgetNames.js";
|
|
|
|
export default {
|
|
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];
|
|
}
|
|
});
|
|
return pageDataFromCms;
|
|
});
|
|
},
|
|
},
|
|
computed: {
|
|
storeActions() {
|
|
return storeActions;
|
|
},
|
|
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]);
|
|
});
|
|
}
|
|
}
|