Add text link rendering to alert + hook into opening modal.

This commit is contained in:
Chloe Herd 2023-04-04 15:11:38 -04:00
parent f18032d92e
commit 8daa078c29
2 changed files with 25 additions and 4 deletions

View file

@ -30,6 +30,7 @@
class="my-4" class="my-4"
cmsWidgetName="AlertRecalNoMobileWidget" cmsWidgetName="AlertRecalNoMobileWidget"
v-if="displayRecalibrationWarning" v-if="displayRecalibrationWarning"
@text-link-clicked="openModalAction"
alertClass="alert-warning" /> alertClass="alert-warning" />
<alert <alert
ref="alertInshopOnly" ref="alertInshopOnly"
@ -233,7 +234,7 @@ export default {
}, },
displayRecalibrationWarning() { displayRecalibrationWarning() {
//TODO: Check lineItems for static or dual recalibration. //TODO: Check lineItems for static or dual recalibration.
return false; return true;
}, },
displayServiceableInshopOnly() { displayServiceableInshopOnly() {
return ( return (
@ -311,6 +312,9 @@ export default {
forwardButtonAction() { forwardButtonAction() {
navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal });
}, },
openModalAction(modalName) {
this.$refs[modalName].openModal();
},
}, },
components: { components: {
alert, alert,

View file

@ -11,12 +11,11 @@
<template v-for="paragraph in splitAlertCopyForParagraphTag" :key="paragraph"> <template v-for="paragraph in splitAlertCopyForParagraphTag" :key="paragraph">
<p <p
class="m-0 text-body small" class="m-0 text-body small"
v-if="!doesCopyContainRouterLink(paragraph)" v-if="!doesCopyContainRouterLink(paragraph) && !doesCopyContainTextLink(paragraph)"
v-html="paragraph"></p> v-html="paragraph"></p>
<p class="m-0 text-body small" v-else> <p class="m-0 text-body small" v-else>
<template v-for="copy in splitCopyOnCMSPlaceHolder(paragraph)" :key="copy"> <template v-for="copy in splitCopyOnCMSPlaceHolder(paragraph)" :key="copy">
<span v-if="!doesCopyContainRouterLink(copy)" v-html="copy"></span> <span v-if="doesCopyContainRouterLink(copy)">
<span v-else>
<router-link <router-link
:to="{ :to="{
query: { [pageQueryString]: `${getRouterLinkRouteFromCopy(copy)}` }, query: { [pageQueryString]: `${getRouterLinkRouteFromCopy(copy)}` },
@ -25,6 +24,18 @@
>{{ getRouterLinkDisplayTextFromCopy(copy) }}</router-link >{{ getRouterLinkDisplayTextFromCopy(copy) }}</router-link
> >
</span> </span>
<span v-else-if="doesCopyContainTextLink(copy)">
<textLink
linkType="text"
:text="getRouterLinkDisplayTextFromCopy(copy)"
href="#!"
@click-event="
$emit('textLinkClicked', getRouterLinkRouteFromCopy(copy))
"
:data-bs-target="'#' + getRouterLinkRouteFromCopy(copy)"
aria-label="Modal window" />
</span>
<span v-else v-html="copy"></span>
</template> </template>
</p> </p>
</template> </template>
@ -40,11 +51,13 @@
<script> <script>
import { import {
doesCopyContainRouterLink, doesCopyContainRouterLink,
doesCopyContainTextLink,
splitCopyOnCMSPlaceHolder, splitCopyOnCMSPlaceHolder,
getRouterLinkRouteFromCopy, getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy, getRouterLinkDisplayTextFromCopy,
splitCMSCopyOnParagraphTag, splitCMSCopyOnParagraphTag,
} from "@/helpers/cms-content-helper"; } from "@/helpers/cms-content-helper";
import textLink from "@/ux-components/text-link/text-link";
import { applicationConfig } from "@/constants/application-config"; import { applicationConfig } from "@/constants/application-config";
export default { export default {
@ -96,6 +109,7 @@ export default {
methods: { methods: {
doesCopyContainRouterLink, doesCopyContainRouterLink,
splitCopyOnCMSPlaceHolder, splitCopyOnCMSPlaceHolder,
doesCopyContainTextLink,
getRouterLinkRouteFromCopy, getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy, getRouterLinkDisplayTextFromCopy,
ensureAlertIsInViewPort() { ensureAlertIsInViewPort() {
@ -120,6 +134,9 @@ export default {
mounted() { mounted() {
this.ensureAlertIsInViewPort(); this.ensureAlertIsInViewPort();
}, },
components: {
textLink,
},
}; };
</script> </script>