nightly
This commit is contained in:
parent
acf45ff1cd
commit
133bdf52a4
4 changed files with 30 additions and 7 deletions
|
|
@ -3,7 +3,8 @@ const dynamicStrings = {
|
|||
CUSTOM: "custom",
|
||||
ROUTER_LINK: "routerLink:",
|
||||
MODAL_LINK: "modalLink",
|
||||
TEXT_LINK: 'textLink'
|
||||
TEXT_LINK: 'textLink',
|
||||
EXTERNAL_LINK: 'externalLink',
|
||||
};
|
||||
|
||||
export { dynamicStrings };
|
||||
|
|
@ -151,12 +151,15 @@ function processWidgetItemForReplacement(widgetModel, key) {
|
|||
getStoreValueFromString
|
||||
);
|
||||
|
||||
if (widgetModel[key].includes(dynamicStrings.GLOBAL_STATE)) {
|
||||
widgetModel[key] = mapStringToState(widgetModel[key]);
|
||||
}
|
||||
if (widgetModel[key].includes(dynamicStrings.MODAL_LINK)) {
|
||||
widgetModel[key] = mapStringToModal(widgetModel[key]);
|
||||
}
|
||||
if (widgetModel[key].includes(dynamicStrings.EXTERNAL_LINK)) {
|
||||
widgetModel[key] = mapStringToLink(widgetModel[key]);
|
||||
}
|
||||
if (widgetModel[key].includes(dynamicStrings.GLOBAL_STATE)) {
|
||||
widgetModel[key] = mapStringToState(widgetModel[key]);
|
||||
}
|
||||
return widgetModel[key];
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +197,24 @@ function mapStringToModal(str) {
|
|||
return returnVal;
|
||||
}
|
||||
|
||||
function mapStringToLink(str) {
|
||||
const startIndex = str.indexOf('{' + dynamicStrings.EXTERNAL_LINK);
|
||||
let linkToReplace = str.substring(startIndex, str.length);
|
||||
linkToReplace = linkToReplace.substring(0, linkToReplace.indexOf('}') + 1);
|
||||
|
||||
const params = linkToReplace.substring((dynamicStrings.EXTERNAL_LINK).length + 2, linkToReplace.length - 1);
|
||||
const splitParams = params.split(',');
|
||||
|
||||
const bodyText = '<a href="' + splitParams[0] + '" class="external-text">' + splitParams[1] + '</a>';
|
||||
|
||||
let returnVal = str.replace(linkToReplace, bodyText);
|
||||
|
||||
if (returnVal.includes(dynamicStrings.EXTERNAL_LINK)) {
|
||||
returnVal = mapStringToLink(returnVal);
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
// Function to convert a string, into a matching global state item.
|
||||
function mapStringToState(str) {
|
||||
// Pull all matches out of the string.
|
||||
|
|
@ -221,10 +242,10 @@ function mapStringToState(str) {
|
|||
}
|
||||
|
||||
// Concatenate the string.
|
||||
stringBuilder = `${stringBuilder} ${stringWithReplacement}`;
|
||||
str = `${stringBuilder} ${stringWithReplacement}`;
|
||||
}
|
||||
|
||||
return stringBuilder.trimStart();
|
||||
return str.trimStart();
|
||||
}
|
||||
|
||||
function getStoreValueFromString(str) {
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ export default {
|
|||
return this.getCmsContent(cmsWidgetName, 'SubheaderText');
|
||||
},
|
||||
getBodyTextFromCms(cmsWidgetName) {
|
||||
const bodyText = this.getCmsContent(cmsWidgetName, "BodyText");
|
||||
let bodyText = this.getCmsContent(cmsWidgetName, "BodyText");
|
||||
return processIfStatements(bodyText, "custom", this.getCustomValueFromString);
|
||||
},
|
||||
getFooterTextFromCms(cmsWidgetName) {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ export const useMainStore = defineStore({
|
|||
id: storeId,
|
||||
state: () => state,
|
||||
getters: {
|
||||
hasRecalibrationPart: (state) => getHasRecalibrationPart(state),
|
||||
vehicle: (state) => state.order.vehicle,
|
||||
damage: (state) => state.order.damage,
|
||||
lineItems: (state) => state.order.lineItems,
|
||||
|
|
|
|||
Loading…
Reference in a new issue