Changes for consistency

This commit is contained in:
Leah Schumann 2023-02-09 11:55:00 -05:00
parent c274e16aac
commit a5509b88f5
2 changed files with 47 additions and 60 deletions

View file

@ -13,19 +13,16 @@
:text="this.mobileLocationLinkText" :text="this.mobileLocationLinkText"
href="#!" href="#!"
@click-event="openModal" @click-event="openModal"
:data-bs-target="getModalId"
aria-label="Modal window" /> aria-label="Modal window" />
</div> </div>
<textBlock cmsWidgetName="MobileFeeDisclaimerWidget" typeStyle="caption" /> <textBlock cmsWidgetName="MobileFeeDisclaimerWidget" typeStyle="caption" />
</div> </div>
<modal <modal
ref="mobileLocationModal" :ref="modalName"
:headerText="modalHeaderText" :headerText="modalHeaderText"
:modalId="this.modalWidgetName"
:onModalOpenedCallback="onModalOpened" :onModalOpenedCallback="onModalOpened"
:footerButtonText="modalFooterText" :footerButtonText="modalFooterText"
@footer-button-event="setMobileLocation" @footer-button-event="setMobileLocation">
:modalForm="modalForm">
<addressQuestions <addressQuestions
ref="addressQuestions" ref="addressQuestions"
v-model="mobileLocationQuestionModel.addressQuestions" v-model="mobileLocationQuestionModel.addressQuestions"
@ -97,15 +94,15 @@ export default {
mobileLocationLinkText() { mobileLocationLinkText() {
return this.getCmsContent(this.linkWidgetName, "BodyText"); return this.getCmsContent(this.linkWidgetName, "BodyText");
}, },
getModalId() {
return "#" + this.modalWidgetName;
},
modalHeaderText() { modalHeaderText() {
return this.getCmsContent(this.modalWidgetName, "HeaderText"); return this.getCmsContent(this.modalWidgetName, "HeaderText");
}, },
modalFooterText() { modalFooterText() {
return this.getCmsContent(this.modalWidgetName, "FooterText"); return this.getCmsContent(this.modalWidgetName, "FooterText");
}, },
modalName() {
return this.modalWidgetName;
},
mobileLocationQuestionModel: { mobileLocationQuestionModel: {
get: function () { get: function () {
return this.modelValue; return this.modelValue;
@ -117,10 +114,10 @@ export default {
}, },
methods: { methods: {
openModal() { openModal() {
this.$refs.mobileLocationModal.openModal(); this.$refs[this.modalName].openModal();
}, },
closeModal() { closeModal() {
this.$refs.mobileLocationModal.closeModal(); this.$refs[this.modalName].closeModal();
}, },
async setMobileLocation() { async setMobileLocation() {
this.closeModal(); this.closeModal();

View file

@ -2,9 +2,9 @@
<div class="text-center"> <div class="text-center">
<div class="update-zip-text-link"> <div class="update-zip-text-link">
<textLink <textLink
id="serviceLocationLinkPromptId" id="serviceZipLinkPromptId"
linkType="text" linkType="text"
:text="serviceZipDisplayText" :text="serviceZipLinkText"
href="#!" href="#!"
@click-event="openModal" @click-event="openModal"
aria-label="Modal window" /> aria-label="Modal window" />
@ -12,21 +12,19 @@
</div> </div>
<modal <modal
:ref="modalName" :ref="modalName"
:headerText="modalHeaderText"
:onModalOpenedCallback="onModalOpened" :onModalOpenedCallback="onModalOpened"
:footerButtonText="modalFooterText" :footerButtonText="modalFooterText"
:headerText="textboxQuestionPrompt" @footer-button-event="setZipCode">
@footer-button-event="setZipCode"
:modalForm="modalForm">
<textboxQuestion <textboxQuestion
ref="zipInputTextQuestion" ref="zipInputTextQuestion"
:cmsWidgetName="textboxQuestionWidgetName" :cmsWidgetName="textboxQuestionWidgetName"
v-model="serviceZipCodeInput" v-model="serviceZipModel.serviceZipCode"
inputId="zipInputTextQuestionTextbox" inputId="serviceZipCode"
questionAlignment="center" questionAlignment="center"
mask="#####" mask="#####"
:displayQuestionText="false" :displayQuestionText="false"
isRequired isRequired
disableAutoFill
validationRules="zip-required|zip-format" /> validationRules="zip-required|zip-format" />
<alert <alert
ref="alertInvalidZip" ref="alertInvalidZip"
@ -85,11 +83,33 @@ export default {
modalForm, modalForm,
}; };
}, },
methods: { computed: {
mobileLocationLinkPromptText() { serviceZipLinkText() {
return this.getCmsContent(this.linkWidgetName, "HeaderText"); const defaultText = this.getCmsContent(this.linkWidgetName, "BodyText");
if (this.modelValue.serviceZipCode.length > 0) {
return this.modelValue.serviceState + ", " + this.modelValue.serviceZipCode;
}
return this.serviceZipLinkPromptText || defaultText;
}, },
modalHeaderText() {
return this.getCmsContent(this.textboxQuestionWidgetName, "QuestionText");
},
modalFooterText() {
return this.getCmsContent(this.modalWidgetName, "FooterText");
},
modalName() {
return this.modalWidgetName;
},
serviceZipModel: {
get: function () {
return this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);
},
},
},
methods: {
resetAlerts() { resetAlerts() {
this.displayInvalidZipAlert = false; this.displayInvalidZipAlert = false;
}, },
@ -100,10 +120,8 @@ export default {
}, },
focusOnZipInput() { focusOnZipInput() {
this.$nextTick(() => { const input = document.getElementById("serviceZipCode");
const input = this.$refs.zipInputTextQuestion.$refs.zipInputTextQuestionTextbox; input.focus();
input.focus();
});
}, },
openModal() { openModal() {
@ -115,7 +133,6 @@ export default {
}, },
onModalOpened() { onModalOpened() {
this.serviceZipCodeInput = this.serviceZipModel.serviceZipCode;
this.resetsOnZipInput(); this.resetsOnZipInput();
this.focusOnZipInput(); this.focusOnZipInput();
}, },
@ -123,7 +140,7 @@ export default {
async setZipCode() { async setZipCode() {
this.resetAlerts(); this.resetAlerts();
const zipCodeData = await this.getZipCodeData(this.serviceZipCodeInput); const zipCodeData = await this.getZipCodeData(this.serviceZipModel.serviceZipCode);
if (!zipCodeData.isValid) { if (!zipCodeData.isValid) {
this.displayInvalidZipAlert = true; this.displayInvalidZipAlert = true;
@ -131,7 +148,7 @@ export default {
} else { } else {
this.serviceZipModel = { this.serviceZipModel = {
serviceState: zipCodeData.state, serviceState: zipCodeData.state,
serviceZipCode: this.serviceZipCodeInput, serviceZipCode: this.serviceZipModel.serviceZipCode,
isServiceable: zipCodeData.isServiceable, isServiceable: zipCodeData.isServiceable,
}; };
@ -139,38 +156,11 @@ export default {
} }
}, },
}, },
computed: {
serviceZipLinkPromptText() {
return this.getCmsContent(this.linkWidgetName, "BodyText");
},
modalFooterText() {
return this.getCmsContent(this.modalWidgetName, "FooterText");
},
textboxQuestionPrompt() {
return this.getCmsContent(this.textboxQuestionWidgetName, "QuestionText");
},
modalName() {
return this.modalWidgetName;
},
serviceZipDisplayText() {
if (this.modelValue.serviceZipCode.length > 0) {
return this.modelValue.serviceState + ", " + this.modelValue.serviceZipCode;
}
return this.serviceZipLinkPromptText || "Enter your service ZIP";
},
serviceZipModel: {
get: function () {
return this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);
},
},
},
watch: { watch: {
serviceZipCodeInput() { serviceZipModel: {
this.resetsOnZipInput(); handler() {
this.displayInvalidZipAlert = false;
},
}, },
}, },
components: { components: {