updates to cached siteHeader to be more inline with card
This commit is contained in:
parent
fb8799fe6b
commit
005b97fcbf
5 changed files with 61 additions and 34 deletions
|
|
@ -1,3 +1,8 @@
|
|||
/* eslint-disable no-use-before-define */
|
||||
/* eslint-disable no-param-reassign */
|
||||
/* eslint-disable jsdoc/require-param-type */
|
||||
/* eslint-disable jsdoc/require-param-description */
|
||||
/* eslint-disable jsdoc/require-returns */
|
||||
import dynamicStrings from '@/constants/dynamic-strings';
|
||||
import { useMainStore } from '@/store';
|
||||
|
||||
|
|
@ -174,6 +179,45 @@ export function fetchCmsContentForPage(issPage) {
|
|||
);
|
||||
}
|
||||
|
||||
export function fetchGlobalCmsContent(issComponent) {
|
||||
const store = useMainStore();
|
||||
|
||||
return (
|
||||
store.getPageData(issComponent)
|
||||
.then((baseResponse) => processPageData(baseResponse, null)));
|
||||
}
|
||||
|
||||
export function updateCmsSiteHeader(cmsResponse) {
|
||||
const clientCmsSiteHeader = getCmsSiteHeader(cmsResponse);
|
||||
useMainStore().issConfig.clientHeader = clientCmsSiteHeader;
|
||||
}
|
||||
|
||||
function getCmsSiteHeader(cmsResponse) {
|
||||
if (cmsResponse?.SiteHeaderWidget) {
|
||||
const siteHeader = cmsResponse?.SiteHeaderWidget;
|
||||
if (siteHeader.Answers) {
|
||||
const { parentAccountNumber } = useMainStore().issConfig;
|
||||
let headerAnswersToUse = siteHeader.Answers
|
||||
.find((answer) => answer.AccountNumber === parentAccountNumber.toString());
|
||||
if (headerAnswersToUse === null) {
|
||||
headerAnswersToUse = siteHeader.Answers
|
||||
.find((answer) => answer.AccountNumber === '0');
|
||||
}
|
||||
|
||||
if (headerAnswersToUse) {
|
||||
return {
|
||||
altText: headerAnswersToUse.AltText,
|
||||
clientName: headerAnswersToUse.ClientName,
|
||||
hexCode: headerAnswersToUse.HexCode,
|
||||
imageId: headerAnswersToUse.ImageId,
|
||||
imageUrl: headerAnswersToUse.AnswerImageUrl
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @function mapStringToModal
|
||||
* @param str
|
||||
|
|
@ -476,6 +520,7 @@ export function doesCopyContainTextLink(copy) {
|
|||
export function setupModalLinks(context) {
|
||||
context.$nextTick(() => {
|
||||
const elements = document.getElementsByClassName('modal-text');
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const element of elements) {
|
||||
const target = element.getAttribute('modalTarget');
|
||||
if (target) {
|
||||
|
|
|
|||
|
|
@ -46,19 +46,19 @@ export default ({
|
|||
messageHeadline: '',
|
||||
type: ''
|
||||
},
|
||||
headerAnswers: null
|
||||
cmsClientHeader: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
imageSrc() {
|
||||
return this.headerAnswers ? this.headerAnswers.AnswerImageUrl : '';
|
||||
return this.cmsClientHeader ? this.cmsClientHeader.imageUrl : '';
|
||||
},
|
||||
altText() {
|
||||
return this.headerAnswers ? this.headerAnswers.AltText : '';
|
||||
return this.cmsClientHeader ? this.cmsClientHeader.altText : '';
|
||||
},
|
||||
logoBackgroundStyle() {
|
||||
return {
|
||||
'background-color': this.headerAnswers ? this.headerAnswers.HexCode : '#FFFFFF'
|
||||
'background-color': this.cmsClientHeader ? this.cmsClientHeader.hexCode : '#FFFFFF'
|
||||
};
|
||||
}
|
||||
},
|
||||
|
|
@ -86,10 +86,9 @@ export default ({
|
|||
},
|
||||
methods: {
|
||||
setupHeader() {
|
||||
const answers = useMainStore().issConfig.issCmsContent.SiteHeaderWidget.Answers;
|
||||
if (Array.isArray(answers)) {
|
||||
this.headerAnswers = answers.filter((x) => x.AccountNumber == this.mainStore.issConfig.parentAccountNumber)[0];
|
||||
this.headerAnswers = !this.headerAnswers ? answers.filter((x) => x.AccountNumber === '0')[0] : this.headerAnswers;
|
||||
const { clientHeader } = useMainStore().issConfig;
|
||||
if (clientHeader) {
|
||||
this.cmsClientHeader = clientHeader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
<script>
|
||||
// Supporting files
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import settleAllPromises from '@/helpers/layout-helper';
|
||||
import { validateISSClientTag, validateISSClientSignature } from '@/helpers/clientauth-helper';
|
||||
import { useMainStore } from '@/store';
|
||||
|
||||
|
|
@ -27,7 +25,6 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
issCmsContent: [],
|
||||
unauthorized: false
|
||||
};
|
||||
},
|
||||
|
|
@ -97,24 +94,6 @@ export default {
|
|||
window.location = `/?issPage=${issPageValues.WELCOME_PAGE}`;
|
||||
}
|
||||
},
|
||||
async populateISSCmsComponents(accountNumber) {
|
||||
console.log('get global cms components...');
|
||||
console.log(accountNumber);
|
||||
const cmsContentPromise = fetchCmsContentForPage('iss-siteheader');
|
||||
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: 'cmsContent',
|
||||
promise: cmsContentPromise
|
||||
}
|
||||
];
|
||||
|
||||
// use resultMap to populate layout content.
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
const issCmsContent = resultMap.cmsContent;
|
||||
this.mainStore.issConfig.issCmsContent = issCmsContent;
|
||||
},
|
||||
async populateISSConfigValues(data) {
|
||||
this.mainStore.issConfig.clientName = data.accountName;
|
||||
this.mainStore.issConfig.clientDisplayName = data.accountName; // Defaults to use the client name.
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ import dropdownQuestion from '@/digital-components/dropdown-question/dropdown-qu
|
|||
import textBlock from '@/digital-components/text-block/text-block.vue';
|
||||
|
||||
// Supporting files
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import { fetchCmsContentForPage, fetchGlobalCmsContent, updateCmsSiteHeader } from '@/helpers/cms-content-helper';
|
||||
import settleAllPromises from '@/helpers/layout-helper';
|
||||
import { required, regex } from '@/helpers/validation-rules';
|
||||
import errorMessages from '@/constants/error-messages';
|
||||
|
|
@ -226,19 +226,24 @@ export default {
|
|||
async beforeRouteEnter(to, from, next) {
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
||||
const cmsGlobalSiteHeaderContentPromise = fetchGlobalCmsContent('iss-siteheader');
|
||||
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: 'cmsContent',
|
||||
promise: cmsContentPromise
|
||||
},
|
||||
{
|
||||
resultKey: 'globalSiteHeaderCmsContent',
|
||||
promise: cmsGlobalSiteHeaderContentPromise
|
||||
}
|
||||
];
|
||||
|
||||
// use resultMap to populate layout content.
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
next((vm) => {
|
||||
updateCmsSiteHeader(resultMap.globalSiteHeaderCmsContent);
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
});
|
||||
},
|
||||
|
|
@ -317,7 +322,6 @@ export default {
|
|||
this.navigateForward();
|
||||
});
|
||||
},
|
||||
|
||||
navigateForward() {
|
||||
if (this.mainStore.applicationUser.duplicateOrders?.length > 0 ?? false) {
|
||||
this.$router.navigate(
|
||||
|
|
@ -354,7 +358,6 @@ export default {
|
|||
);
|
||||
}
|
||||
},
|
||||
|
||||
getWelcomePageModelFromStore() {
|
||||
return {
|
||||
policyNumber: this.mainStore.order.policy.policyNumber,
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ const getDefaultState = () => ({
|
|||
issConfig: {
|
||||
clientName: 'Generic Insurance', // this is the default and will be overriden by the client's name
|
||||
clientDisplayName: 'Generic Insurance', // this is the default and will be overridden by the client's name or client display name.
|
||||
issCmsContent: [],
|
||||
clientHeader: {},
|
||||
styleSheet: '', // Stylesheet used by the client.
|
||||
parentAccountNumber: 0, // Parent account number used by the client.
|
||||
isCoverageEnabled: false, // Indicates if we should be calling coverage on this flow.
|
||||
|
|
@ -1463,6 +1463,7 @@ export const useMainStore = defineStore({
|
|||
resetISSConfigState() {
|
||||
this.issConfig.clientName = 'Generic Insurance';
|
||||
this.issConfig.clientDisplayName = 'Generic Insurance';
|
||||
this.issConfig.clientHeader = {};
|
||||
this.issConfig.parentAccountNumber = 0;
|
||||
this.issConfig.styleSheet = '';
|
||||
this.issConfig.isCoverageEnabled = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue