CSR-1012 | reorganized service-location page data

This commit is contained in:
Matt Caimi 2023-02-10 13:50:17 -05:00
parent ce243fc296
commit 2be72ac348
3 changed files with 76 additions and 36 deletions

View file

@ -2,7 +2,7 @@
<!-- Modal --> <!-- Modal -->
<div <div
class="modal fade modal-component" class="modal fade modal-component"
v-on="{ 'hidden.bs.modal': resetButtonStyle, 'shown.bs.modal': onModalOpenedCallback }" v-on="{ 'hidden.bs.modal': onModalClosed, 'shown.bs.modal': onModalOpened }"
:id="modalId" :id="modalId"
tabindex="-1" tabindex="-1"
aria-labelledby="ModalComponentLabel" aria-labelledby="ModalComponentLabel"
@ -53,6 +53,9 @@ export default {
onModalOpenedCallback: { onModalOpenedCallback: {
type: Function, type: Function,
}, },
onModalClosedCallback: {
type: Function,
},
}, },
setup() { setup() {
const modalId = `modal-${crypto.randomUUID()}`; const modalId = `modal-${crypto.randomUUID()}`;
@ -78,6 +81,13 @@ export default {
resetButtonStyle() { resetButtonStyle() {
this.$refs.buttonMain.resetButtonStyle(); this.$refs.buttonMain.resetButtonStyle();
}, },
onModalOpened() {
this.onModalOpenedCallback?.();
},
onModalClosed() {
this.resetButtonStyle();
this.onModalClosedCallback?.();
},
openModal() { openModal() {
const modal = Modal.getOrCreateInstance(document.getElementById(this.modalId)); const modal = Modal.getOrCreateInstance(document.getElementById(this.modalId));
modal.show(); modal.show();

View file

@ -4,14 +4,13 @@
<funnelHeader cmsWidgetName="FunnelHeaderWidget" /> <funnelHeader cmsWidgetName="FunnelHeaderWidget" />
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" /> <funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
<serviceZipModalQuestion <serviceZipModalQuestion
v-model="serviceZipQuestion" v-model="serviceZipQuestionModel"
linkWidgetName="ServiceZipLinkWidget" linkWidgetName="ServiceZipLinkWidget"
modalWidgetName="ServiceZipModalWidget" modalWidgetName="ServiceZipModalWidget"
textboxQuestionWidgetName="ServiceZipQuestionWidget" textboxQuestionWidgetName="ServiceZipQuestionWidget"
alertInvalidZipWidgetName="AlertInvalidZipWidget" /> alertInvalidZipWidgetName="AlertInvalidZipWidget" />
<mobileLocationModalQuestions <mobileLocationModalQuestions
v-model="mobileLocationQuestions" v-model="mobileLocationQuestionsModel"
:serviceZipCode="serviceZipQuestion.serviceZipCode"
linkWidgetName="MobileLocationLinkWidget" linkWidgetName="MobileLocationLinkWidget"
modalWidgetName="MobileLocationModalWidget" modalWidgetName="MobileLocationModalWidget"
mobileFeeDisclaimerWidgetName="MobileFeeDisclaimerWidget" mobileFeeDisclaimerWidgetName="MobileFeeDisclaimerWidget"
@ -42,25 +41,18 @@ export default {
name: "service-location", name: "service-location",
data() { data() {
return { return {
serviceZipQuestion: { isServiceable: null,
serviceState: "", streetAddress: "",
serviceZipCode: "", apartmentNumberOrBusinessName: "",
isServiceable: null, city: "",
}, state: "",
mobileLocationQuestions: { zipCode: "",
addressQuestions: { isVehicleProtected: null,
streetAddress: "", isZipServiceableMobile: null,
apartmentNumberOrBusinessName: "", isZipServiceableInShop: null,
city: "",
state: "",
zipCode: "",
},
isVehicleProtected: null,
isZipServiceableMobile: null,
isZipServiceableInShop: null,
},
}; };
}, },
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
@ -80,6 +72,42 @@ export default {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
}); });
}, },
computed: {
serviceZipQuestionModel: {
get: function () {
return {
state: this.state,
zipCode: this.zipCode,
isServiceable: this.isServiceable,
};
},
set: function (newValue) {
this.state = newValue.state;
this.zipCode = newValue.zipCode;
this.isServiceable = newValue.isServiceable;
},
},
mobileLocationQuestionsModel: {
get: function () {
return {
addressQuestions: {
streetAddress: this.streetAddress,
apartmentNumberOrBusinessName: this.apartmentNumberOrBusinessName,
city: this.city,
state: this.state,
zipCode: this.zipCode,
},
};
},
set: function (newValue) {
this.streetAddress = newValue.streetAddress;
this.apartmentNumberOrBusinessName = newValue.apartmentNumberOrBusinessName;
this.city = newValue.city;
this.state = newValue.state;
this.zipCode = newValue.zipCode;
},
},
},
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return true; return true;

View file

@ -14,12 +14,13 @@
:ref="modalName" :ref="modalName"
:headerText="modalHeaderText" :headerText="modalHeaderText"
:onModalOpenedCallback="onModalOpened" :onModalOpenedCallback="onModalOpened"
:onModalClosedCallback="onModalClosed"
:footerButtonText="modalFooterText" :footerButtonText="modalFooterText"
@footer-button-event="setZipCode"> @footer-button-event="setZipCode">
<serviceZipQuestion <serviceZipQuestion
ref="serviceZipQuestion" ref="serviceZipQuestion"
:cmsWidgetName="textboxQuestionWidgetName" :cmsWidgetName="textboxQuestionWidgetName"
v-model="serviceZipModel.serviceZipCode" /> v-model="serviceZipCodeInput" />
<alert <alert
ref="alertInvalidZip" ref="alertInvalidZip"
v-if="displayInvalidZipAlert" v-if="displayInvalidZipAlert"
@ -59,8 +60,8 @@ export default {
type: Object, type: Object,
default: () => ({ default: () => ({
serviceZipQuestion: { serviceZipQuestion: {
serviceState: "", state: "",
serviceZipCode: "1234", zipCode: "",
isServiceable: null, isServiceable: null,
}, },
}), }),
@ -79,11 +80,10 @@ export default {
}, },
computed: { computed: {
serviceZipLinkText() { serviceZipLinkText() {
const defaultText = this.getCmsContent(this.linkWidgetName, "BodyText"); if (this.modelValue.zipCode.length > 0) {
if (this.modelValue.serviceZipCode.length > 0) { return this.modelValue.state + ", " + this.modelValue.zipCode;
return this.modelValue.serviceState + ", " + this.modelValue.serviceZipCode;
} }
return this.serviceZipLinkPromptText || defaultText; return this.getCmsContent(this.linkWidgetName, "BodyText");
}, },
modalHeaderText() { modalHeaderText() {
return this.getCmsContent(this.textboxQuestionWidgetName, "QuestionText"); return this.getCmsContent(this.textboxQuestionWidgetName, "QuestionText");
@ -127,22 +127,26 @@ export default {
}, },
onModalOpened() { onModalOpened() {
this.resetsOnZipInput();
this.focusOnZipInput(); this.focusOnZipInput();
}, },
onModalClosed() {
this.serviceZipCodeInput = this.serviceZipModel.zipCode;
this.resetsOnZipInput();
},
async setZipCode() { async setZipCode() {
this.resetAlerts(); this.resetAlerts();
const zipCodeData = await this.getZipCodeData(this.serviceZipModel.serviceZipCode); const zipCodeData = await this.getZipCodeData(this.serviceZipCodeInput);
if (!zipCodeData.isValid) { if (!zipCodeData.isValid) {
this.displayInvalidZipAlert = true; this.displayInvalidZipAlert = true;
this.focusOnZipInput(); this.focusOnZipInput();
} else { } else {
this.serviceZipModel = { this.serviceZipModel = {
serviceState: zipCodeData.state, state: zipCodeData.state,
serviceZipCode: this.serviceZipModel.serviceZipCode, zipCode: this.serviceZipCodeInput,
isServiceable: zipCodeData.isServiceable, isServiceable: zipCodeData.isServiceable,
}; };
@ -151,10 +155,8 @@ export default {
}, },
}, },
watch: { watch: {
serviceZipModel: { serviceZipCodeInput() {
handler() { this.resetsOnZipInput();
this.displayInvalidZipAlert = false;
},
}, },
}, },
components: { components: {