CSR-1421: refactor work to move router-link into textBlock instead of using it directly on page
This commit is contained in:
parent
6d36cd5c74
commit
f0c7ecbb9b
4 changed files with 84 additions and 43 deletions
|
|
@ -1,11 +1,43 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div class="text-block w-100" :class="[justifyText, typeStyle, fontWeight, marginTopClass]">
|
||||||
class="text-block w-100 mt-2"
|
<span v-for="copy in splitCopyOnCMSPlaceHolder(this.textBlockCopy)" :key="copy">
|
||||||
:class="[justifyText, typeStyle, fontWeight]"
|
<span v-if="doesCopyContainRouterLink(copy)">
|
||||||
v-html="this.TextBlockCopy"></div>
|
<router-link
|
||||||
|
:to="{
|
||||||
|
query: { [pageQueryString]: `${getRouterLinkRouteFromCopy(copy)}` },
|
||||||
|
name: 'root',
|
||||||
|
}"
|
||||||
|
>{{ getRouterLinkDisplayTextFromCopy(copy) }}</router-link
|
||||||
|
>
|
||||||
|
</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>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Components
|
||||||
|
import textLink from "@/ux-components/text-link/text-link";
|
||||||
|
|
||||||
|
// Supporting files
|
||||||
|
import {
|
||||||
|
doesCopyContainRouterLink,
|
||||||
|
doesCopyContainTextLink,
|
||||||
|
splitCopyOnCMSPlaceHolder,
|
||||||
|
getRouterLinkRouteFromCopy,
|
||||||
|
getRouterLinkDisplayTextFromCopy,
|
||||||
|
} from "@/helpers/cms-content-helper";
|
||||||
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "textBlock",
|
name: "textBlock",
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -14,14 +46,37 @@ export default {
|
||||||
typeStyle: String, // h1-h6, body, small, label, caption (see Figma or Confluence documentation)
|
typeStyle: String, // h1-h6, body, small, label, caption (see Figma or Confluence documentation)
|
||||||
fontWeight: String, // bold=500, default is 400
|
fontWeight: String, // bold=500, default is 400
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
|
marginTopSizeOverride: Number, // override mt-2 with a bootstrap size from 0-5 or auto
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
doesCopyContainRouterLink,
|
||||||
|
doesCopyContainTextLink,
|
||||||
|
splitCopyOnCMSPlaceHolder,
|
||||||
|
getRouterLinkRouteFromCopy,
|
||||||
|
getRouterLinkDisplayTextFromCopy,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
TextBlockCopy() {
|
pageQueryString() {
|
||||||
|
return applicationConfig.PAGE_QUERYSTRING;
|
||||||
|
},
|
||||||
|
textBlockCopy() {
|
||||||
if (this.customText) {
|
if (this.customText) {
|
||||||
return this.customText;
|
return this.customText;
|
||||||
}
|
}
|
||||||
return this.getCmsContent(this.cmsWidgetName, "Text");
|
return this.getCmsContent(this.cmsWidgetName, "Text");
|
||||||
},
|
},
|
||||||
|
marginTopClass() {
|
||||||
|
if (this.marginTopSizeOverride === "auto") {
|
||||||
|
return "mt-auto";
|
||||||
|
}
|
||||||
|
if (this.marginTopSizeOverride >= 0 && this.marginTopSizeOverride <= 5) {
|
||||||
|
return "mt-" + this.marginTopSizeOverride;
|
||||||
|
}
|
||||||
|
return "mt-2";
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
textLink,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,12 @@
|
||||||
validationRules="vehicle-required"
|
validationRules="vehicle-required"
|
||||||
v-model="selectedVehicleVin"
|
v-model="selectedVehicleVin"
|
||||||
:isCarIdDifferent="isCarIdDifferent" />
|
:isCarIdDifferent="isCarIdDifferent" />
|
||||||
<div class="alert-provide-vin my-3" v-if="splitAlertProvideVinBodyForLink.length">
|
<div class="alert-provide-vin" v-if="splitAlertProvideVinBodyForLink.length">
|
||||||
<span v-for="copy in splitAlertProvideVinBodyForLink" :key="copy">
|
<textBlock
|
||||||
<span v-if="doesCopyContainRouterLink(copy)" class="text-body">
|
:customText="AlertProvideVinBody"
|
||||||
<router-link
|
justifyText="left"
|
||||||
:to="{
|
class="mb-3"
|
||||||
query: { fmgPage: `${getRouterLinkRouteFromCopy(copy)}` },
|
marginTopSizeOverride="3" />
|
||||||
name: 'root',
|
|
||||||
}"
|
|
||||||
>{{ getRouterLinkDisplayTextFromCopy(copy) }}</router-link
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
<span v-else class="m-0 text-body" v-html="copy"></span>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<funnelFooter
|
<funnelFooter
|
||||||
cmsWidgetName="FunnelFooterWidget"
|
cmsWidgetName="FunnelFooterWidget"
|
||||||
|
|
@ -52,6 +45,7 @@ import vehicleBanner from "@/fmg-components/vehicle-banner/vehicle-banner";
|
||||||
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
import addressVehiclesQuestion from "@/layouts/address-vehicles/address-vehicles-question/address-vehicles-question";
|
import addressVehiclesQuestion from "@/layouts/address-vehicles/address-vehicles-question/address-vehicles-question";
|
||||||
|
import textBlock from "@/digital-components/text-block/text-block";
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
|
@ -237,6 +231,7 @@ export default {
|
||||||
alert,
|
alert,
|
||||||
funnelFooter,
|
funnelFooter,
|
||||||
addressVehiclesQuestion,
|
addressVehiclesQuestion,
|
||||||
|
textBlock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,13 @@
|
||||||
<loadingModal ref="loadingModal" />
|
<loadingModal ref="loadingModal" />
|
||||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" class="mt-5" />
|
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" class="mt-5" />
|
||||||
<div class="text-center mt-1 mb-3" v-if="ChangeShopLink.length">
|
<template v-if="ChangeShopLink.length">
|
||||||
<span v-for="copy in ChangeShopLink" :key="copy">
|
<textBlock
|
||||||
<span v-if="doesCopyContainRouterLink(copy)" class="text-body">
|
cmsWidgetName="ChangeShopLink"
|
||||||
<router-link
|
justifyText="center"
|
||||||
:to="{
|
class="mb-3"
|
||||||
query: { fmgPage: `${getRouterLinkRouteFromCopy(copy)}` },
|
marginTopSizeOverride="1" />
|
||||||
name: 'root',
|
</template>
|
||||||
}"
|
|
||||||
>{{ getRouterLinkDisplayTextFromCopy(copy) }}</router-link
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
<span v-else class="m-0 text-body" v-html="copy"></span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<location-alerts cmsWidgetPrefix="LocationAlert-" ref="locationAlerts" />
|
<location-alerts cmsWidgetPrefix="LocationAlert-" ref="locationAlerts" />
|
||||||
<date-picker
|
<date-picker
|
||||||
selectableDatesSetting="custom"
|
selectableDatesSetting="custom"
|
||||||
|
|
@ -60,6 +53,7 @@ import { Form, defineRule } from "vee-validate";
|
||||||
import datePicker from "@/digital-components/date-picker/date-picker";
|
import datePicker from "@/digital-components/date-picker/date-picker";
|
||||||
import locationAlerts from "@/layouts/schedule/location-alerts/location-alerts";
|
import locationAlerts from "@/layouts/schedule/location-alerts/location-alerts";
|
||||||
import timeSlotModalQuestion from "./time-slot-modal-question/time-slot-modal-question";
|
import timeSlotModalQuestion from "./time-slot-modal-question/time-slot-modal-question";
|
||||||
|
import textBlock from "@/digital-components/text-block/text-block";
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
|
@ -373,6 +367,7 @@ export default {
|
||||||
datePicker,
|
datePicker,
|
||||||
locationAlerts,
|
locationAlerts,
|
||||||
timeSlotModalQuestion,
|
timeSlotModalQuestion,
|
||||||
|
textBlock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,11 @@
|
||||||
v-if="!doesCopyContainRouterLink(paragraph) && !doesCopyContainTextLink(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-if="doesCopyContainRouterLink(paragraph)">
|
||||||
<span v-if="doesCopyContainRouterLink(copy)">
|
<textBlock :customText="paragraph" class="mb-1" marginTopSizeOverride="0" />
|
||||||
<router-link
|
</template>
|
||||||
:to="{
|
<template v-else v-for="copy in splitCopyOnCMSPlaceHolder(paragraph)" :key="copy">
|
||||||
query: { [pageQueryString]: `${getRouterLinkRouteFromCopy(copy)}` },
|
<span v-if="doesCopyContainTextLink(copy)">
|
||||||
name: 'root',
|
|
||||||
}"
|
|
||||||
>{{ getRouterLinkDisplayTextFromCopy(copy) }}</router-link
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
<span v-else-if="doesCopyContainTextLink(copy)">
|
|
||||||
<textLink
|
<textLink
|
||||||
linkType="text"
|
linkType="text"
|
||||||
:text="getRouterLinkDisplayTextFromCopy(copy)"
|
:text="getRouterLinkDisplayTextFromCopy(copy)"
|
||||||
|
|
@ -59,6 +53,7 @@ import {
|
||||||
} from "@/helpers/cms-content-helper";
|
} from "@/helpers/cms-content-helper";
|
||||||
import textLink from "@/ux-components/text-link/text-link";
|
import textLink from "@/ux-components/text-link/text-link";
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
import textBlock from "@/digital-components/text-block/text-block";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "alert",
|
name: "alert",
|
||||||
|
|
@ -136,6 +131,7 @@ export default {
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
textLink,
|
textLink,
|
||||||
|
textBlock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue