This should have the new behavior and keep the old behavior

This commit is contained in:
Bill Richardson 2023-10-27 14:16:12 -04:00
parent 11f94b0e50
commit e25425e2a0
4 changed files with 67 additions and 3 deletions

View file

@ -5,15 +5,33 @@
<component :is="Component" @focusin="handleAnyComponentFocus" />
</transition>
</router-view>
<loadingModal notFullScreen :showLoader="shouldShowLoader" :showTextCarousel="shouldShowTextCarousel" />
</template>
<script>
import { handleAnyComponentFocus } from "@/helpers/button-question-focus-helper";
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
import { showFmgLoadingModal } from "@/helpers/loading-modal-helper";
export default {
name: "app",
setup() {
const { globalNonpersistedState } = showFmgLoadingModal();
return { globalNonpersistedState };
},
methods: {
handleAnyComponentFocus: handleAnyComponentFocus,
},
computed: {
shouldShowLoader() {
return this.globalNonpersistedState.showLoadingModal;
},
shouldShowTextCarousel() {
return this.globalNonpersistedState.showTextCarousel;
},
},
components: {
loadingModal,
},
};
</script>

View file

@ -1,5 +1,5 @@
<template>
<div v-if="isModalVisible" class="container-fluid modal-loader">
<div v-if="showModalContent" class="container-fluid modal-loader">
<div class="row g-2 h-100 d-flex align-items-center">
<div class="container-fluid overflow-hidden">
<div class="row h-100">
@ -9,7 +9,7 @@
</div>
</div>
</div>
<div class="row">
<div v-if="showTextCarouselContent" class="row">
<div class="col">
<div class="text-container slide">
<p>
@ -56,11 +56,31 @@ export default {
data() {
return {
isModalVisible: false,
isModalTextCarouselVisible: false,
};
},
props: {
showLoader: {
type: Boolean,
default: false,
},
showTextCarousel: {
type: Boolean,
default: false,
},
},
computed: {
showModalContent() {
return this.isModalVisible || this.showLoader;
},
showTextCarouselContent() {
return this.isModalTextCarouselVisible || this.showTextCarousel;
},
},
methods: {
showModal() {
showModal(showTextCarousel = true) {
//Display modal
this.isModalTextCarouselVisible = showTextCarousel;
this.isModalVisible = true;
//Force page reload on back button
window.addEventListener(

View file

@ -0,0 +1,18 @@
import { reactive } from "vue";
// state encapsulated and managed by the composable
const globalNonpersistedState = reactive({
showLoadingModal: true,
showTextCarousel: false,
});
export const showFmgLoadingModal = (newValue, showTextCarousel = false) => {
if (newValue !== undefined) {
globalNonpersistedState.showLoadingModal = newValue;
}
if (showTextCarousel !== undefined) {
globalNonpersistedState.showTextCarousel = showTextCarousel;
}
return { globalNonpersistedState };
};

View file

@ -8,6 +8,7 @@ import { globalEvents, globalEventTypes } from "@/constants/events";
import { queryStrings } from "@/constants/query-strings";
import { getQuerystringParameter } from "@/helpers/querystring-helper";
import { getDeviceIdValue } from "@/helpers/heritage-integration/cookie-helper";
import { showFmgLoadingModal } from "@/helpers/loading-modal-helper";
// Heritage integration
import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper";
@ -152,6 +153,11 @@ router.beforeEach(async (to, from, next) => {
// use current page url query string name when to.name is "root" (due to unresolved navigation in beforeEach)
router.lastNavigationPage = to.name == "root" ? analyticsMixin.methods.getPageName() : to.name;
const fromQueryPage = from.query?.fmgPage;
if (fromQueryPage === undefined) {
showFmgLoadingModal(true);
}
next();
});
@ -169,6 +175,8 @@ router.afterEach(async (to, from) => {
}
}
showFmgLoadingModal(false);
// Push page view to GA
analyticsMixin.methods.pushPageViewToGA();