58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import store from "@/store";
|
|
import { storeActions } from "@/constants/store-actions.js";
|
|
import { storeMutations } from "@/constants/store-mutations.js";
|
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
|
import { widgetNames } from "@/constants/widget-names.js";
|
|
import { emitter } from "@/helpers/event-bus/event-bus";
|
|
import { globalEvents } from "@/constants/events";
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
routedToLastKnownPage: false,
|
|
};
|
|
},
|
|
methods: {
|
|
dispatchNonBlockingStoreAction(type, payload, encodePayload = true) {
|
|
// Encode the payload if required
|
|
if (encodePayload) {
|
|
encodeUriData(payload);
|
|
}
|
|
|
|
return store.dispatch(type, payload);
|
|
},
|
|
emitGlobalMessage(headline, copy, isDismissible, type) {
|
|
emitter.emit(globalEvents.GLOBAL_ALERT, {
|
|
globalAlertMessage: {
|
|
messageHeadline: headline,
|
|
messageCopy: copy,
|
|
isDismissible: isDismissible,
|
|
type: type
|
|
}
|
|
});
|
|
}
|
|
},
|
|
computed: {
|
|
storeActions() {
|
|
return storeActions;
|
|
},
|
|
storeMutations() {
|
|
return storeMutations;
|
|
},
|
|
navigationScenarios() {
|
|
return navigationScenarios;
|
|
},
|
|
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]);
|
|
});
|
|
}
|
|
}
|