Fixed error issues with Address component, fixed spacing in modals

This commit is contained in:
Leah Schumann 2023-01-27 10:01:15 -05:00
parent 23d30d6037
commit e684260e24
5 changed files with 172 additions and 43 deletions

View file

@ -17,7 +17,7 @@
data-bs-dismiss="modal" data-bs-dismiss="modal"
aria-label="Close"></button> aria-label="Close"></button>
</div> </div>
<div class="modal-body ps-4 pe-4 pt-5 pb-4" v-if="showModalBody"> <div class="modal-body ps-5 pe-5 pt-5 pb-4" v-if="showModalBody">
<img :src="ModalImage" class="mw-100 d-flex mx-auto mb-4" alt="" /> <img :src="ModalImage" class="mw-100 d-flex mx-auto mb-4" alt="" />
<h5 class="mb-4" v-html="ModalHeadline"></h5> <h5 class="mb-4" v-html="ModalHeadline"></h5>
<p class="fw-bold mb-2 subheader-text" v-html="ModalSubheadertext"></p> <p class="fw-bold mb-2 subheader-text" v-html="ModalSubheadertext"></p>
@ -62,12 +62,11 @@ export default {
}, },
data() { data() {
return { return {
myModal: null, modal: null,
} };
}, },
mounted() { mounted() {
this.myModal = new Modal(document.getElementById(this.cmsWidgetName)); this.modal = new Modal(document.getElementById(this.cmsWidgetName));
}, },
computed: { computed: {
ModalHeadline() { ModalHeadline() {
@ -97,10 +96,10 @@ export default {
this.$refs.buttonMain.resetButtonStyle(); this.$refs.buttonMain.resetButtonStyle();
}, },
openModal() { openModal() {
this.myModal.show(); this.modal.show();
}, },
closeModal() { closeModal() {
this.myModal.hide(); this.modal.hide();
}, },
async footerButtonClick() { async footerButtonClick() {
if (this.footerButtonCallback) { if (this.footerButtonCallback) {

View file

@ -93,7 +93,6 @@ import { applicationConfig } from "@/constants/application-config.js";
import { defineRule } from "vee-validate"; import { defineRule } from "vee-validate";
import { required, regex } from "@/helpers/validation-rules"; import { required, regex } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import { fill } from "lodash";
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule("street-address-required", required(errorMessages.STREET_ADDRESS_REQUIRED)); defineRule("street-address-required", required(errorMessages.STREET_ADDRESS_REQUIRED));
@ -258,13 +257,17 @@ export default {
}); });
addressField1.addEventListener("keydown", (e) => { addressField1.addEventListener("keydown", (e) => {
if (e.code === "Enter" || e.code === "NumpadEnter") { const autocomplete = document.getElementById("autocomplete");
const event = new Event("place_changed");
if (e.code === "Enter" || e.code === "NumpadEnter" || e.code === "Tab") {
const selectedItem = document.querySelector( const selectedItem = document.querySelector(
".pac-container .pac-item-selected" ".pac-container .pac-item-selected"
); );
if (selectedItem !== null) { if (selectedItem !== null) {
// Fill-in the address using selected item in the list. // Fill-in the address using selected item in the list.
fillInAddress(selectedItem); autocomplete.dispatchEvent(event);
//fillInAddress(selectedItem.textContent);
} else { } else {
// Fill-in the address using first item in the list. // Fill-in the address using first item in the list.
fillInAddressUsingFirstItem(); fillInAddressUsingFirstItem();
@ -274,23 +277,25 @@ export default {
} }
}); });
addressField1.addEventListener("change", () => { // addressField1.addEventListener("change", () => {
// If a match has been previously attempted then do nothing // // If a match has been previously attempted then do nothing
if (self.matchFound !== null) { // if (self.matchFound !== null) {
return; // return;
} // }
// Get the address that the user clicked on (if any) // // Get the address that the user clicked on (if any)
const clickedAddress = document.querySelector( // const clickedAddress = document.querySelector(
".pac-container .pac-item:hover" // ".pac-container .pac-item:hover"
); // );
// If the Street Address field changed without clicking (i.e. by pressing Tab, or clicking outside the field) // // If the Street Address field changed without clicking (i.e. by pressing Tab, or clicking outside the field)
if (clickedAddress === null) { // if (clickedAddress === null) {
// Fill-in the address using first item in the list. // // Fill-in the address using first item in the list.
fillInAddressUsingFirstItem(); // fillInAddressUsingFirstItem();
} // }
});
// console.log("change");
// });
function fillInAddressUsingFirstItem() { function fillInAddressUsingFirstItem() {
// Fill-in the address using first item in the list. // Fill-in the address using first item in the list.
@ -315,6 +320,7 @@ export default {
} }
function fillInAddress(place) { function fillInAddress(place) {
console.log("fillInAddress");
if (!place) { if (!place) {
place = autocomplete.getPlace(); place = autocomplete.getPlace();
} }
@ -322,8 +328,11 @@ export default {
if (place && place.address_components) { if (place && place.address_components) {
self.matchFound = true; self.matchFound = true;
self.addressModel.streetAddress = "";
self.$nextTick(function () { self.$nextTick(function () {
//self.addressModel.streetAddress = "";
//self.$nextTick();
self.showAddressFields = true; self.showAddressFields = true;
for (const component of place.address_components) { for (const component of place.address_components) {
@ -407,6 +416,11 @@ export default {
} }
}, },
}, },
"addressModel.streetAddress": {
handler(newValue, oldValue) {
console.log(`I got changed from ${oldValue} to ${newValue}`);
},
},
}, },
components: { components: {
textboxQuestion, textboxQuestion,

View file

@ -12,7 +12,7 @@
linkType="text" linkType="text"
:text="this.mobileLocationDisplayText" :text="this.mobileLocationDisplayText"
href="#!" href="#!"
data-bs-toggle="modal" @click-event="openModal"
:data-bs-target="getModalId" :data-bs-target="getModalId"
aria-label="Modal window" /> aria-label="Modal window" />
</div> </div>
@ -22,8 +22,13 @@
:cmsWidgetName="this.modalWidgetName" :cmsWidgetName="this.modalWidgetName"
:onModalOpenedCallback="onModalOpened" :onModalOpenedCallback="onModalOpened"
:footerButtonCallback="saveMobileLocationData"> :footerButtonCallback="saveMobileLocationData">
<div class="ps-4 pe-4 pb-4"> <div class="modal-body ps-5 pe-5 pt-5 pb-4">
<addressQuestions ref="addressQuestions" captureApartmentNumberOrBusinessName ="true" /> <addressQuestions
ref="addressQuestions"
v-model="mobileQuestionModel.addressQuestions"
captureApartmentNumberOrBusinessName="true" />
<vehicleProtectedQuestion v-model="mobileQuestionModel.selectedValue"/>
<textBlock cmsWidgetName="QuoteEmailTextBlockWidget" typeStyle="caption" />
</div> </div>
</modal> </modal>
</template> </template>
@ -32,28 +37,49 @@
// Components // Components
import textLink from "@/ux-components/text-link/text-link"; import textLink from "@/ux-components/text-link/text-link";
import modal from "@/digital-components/modal/modal"; import modal from "@/digital-components/modal/modal";
import buttonQuestion from "@/digital-components/button-question/button-question";
import alert from "@/ux-components/alert/alert"; import alert from "@/ux-components/alert/alert";
import textboxQuestion from "@/digital-components/textbox-question/textbox-question"; import textboxQuestion from "@/digital-components/textbox-question/textbox-question";
import addressQuestions from "@/layouts/address-lookup/customer-questions/address-questions/address-questions"; import addressQuestions from "@/layouts/address-lookup/customer-questions/address-questions/address-questions";
import vehicleProtectedQuestion from "@/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question";
import textBlock from "@/digital-components/text-block/text-block";
//Supporting Files // Supporting Files
import { defineRule } from "vee-validate"; import { defineRule } from "vee-validate";
import { required, regex } from "@/helpers/validation-rules"; import { required, regex } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import { isNoUnitNumericStyleProp } from "@vue/shared"; import { storeActions } from "@/constants/store-actions.js";
import baseMixin from "@/mixins/base-mixin.js";
import TextBlock from '../../../digital-components/text-block/text-block.vue';
// Define Validation Rules // Define Validation Rules
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED)); defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
defineRule("zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT)); defineRule("zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT));
export default { export default {
name: "mobile-location-modal-question", name: "mobile-location-modal-questions",
emits: ["update:modelValue"], // The component emits an event
data() { data() {
return { return {
isVehicleProtectedAnswers: [],
}; };
}, },
props: { props: {
modelValue: {
type: Object,
default: () => ({
addressQuestions: {
streetAddress: "",
apartmentNumberOrBusinessName: "",
city: "",
state: "",
zipCode: "",
},
isZipServiceableMobile: Boolean,
isZipServiceableInShop: Boolean,
isVehicleProtected: Boolean,
}),
},
cmsWidgetName: String, cmsWidgetName: String,
modalWidgetName: String, modalWidgetName: String,
textboxQuestionWidgetName: String, textboxQuestionWidgetName: String,
@ -61,7 +87,25 @@ export default {
alertInvalidZipWidgetName: String, alertInvalidZipWidgetName: String,
}, },
methods: { methods: {
loadInitialData() {
return baseMixin.methods.dispatchStoreAction(storeActions.GET_VEHICLE_YEARS, {});
},
initializeComponent(initialData) {
this.isVehicleProtectedAnswers = initialData;
},
openModal() {
this.$refs.mobileServiceModal.openModal();
},
closeModal() {
this.$refs.mobileServiceModal.closeModal();
},
focusOnZipInput() {
this.$nextTick(() => {
console.log(this.$refs);
const input = this.$refs.streetAddressField;
input.focus();
});
},
}, },
computed: { computed: {
getModalId() { getModalId() {
@ -71,17 +115,25 @@ export default {
return this.getCmsContent(this.cmsWidgetName, "HeaderText"); return this.getCmsContent(this.cmsWidgetName, "HeaderText");
}, },
mobileLocationDisplayText() { mobileLocationDisplayText() {
return this.getCmsContent(this.cmsWidgetName, "FooterText"); return this.getCmsContent(this.cmsWidgetName, "FooterText");
}, },
}, mobileQuestionModel: {
mounted() { get: function () {
return this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);
},
},
}, },
mounted() {},
components: { components: {
textLink, textLink,
modal, modal,
addressQuestions addressQuestions,
vehicleProtectedQuestion,
textBlock
}, },
}; };
</script> </script>

View file

@ -0,0 +1,53 @@
<template>
<buttonQuestion
class="radioQuestion"
:questionText="questionText"
:answers="answers"
groupName="isVehicleProtected"
textPosition="text-center"
v-model="selectedValue"
isRequired />
</template>
<script>
import buttonQuestion from "@/digital-components/button-question/button-question";
// Supporting files
import { storeActions } from "@/constants/store-actions.js";
import baseMixin from "@/mixins/base-mixin.js";
export default {
name: "vehicle-protected-question",
data() {
return {
answers: [ "Yes", "No" ],
};
},
props: {
modelValue: String,
cmsWidgetName: String,
},
components: {
buttonQuestion,
},
computed: {
questionText() {
return this.getCmsContent(this.cmsWidgetName, "QuestionText");
},
selectedValue: {
get: function () {
return this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);
},
},
},
methods: {
loadInitialData() {
return baseMixin.methods.dispatchStoreAction(storeActions.GET_VEHICLE_YEARS, {});
},
initializeComponent(initialData) {
this.years = initialData;
},
},
};
</script>

View file

@ -10,10 +10,11 @@ fmg
textboxQuestionWidgetName="ServiceZipQuestionWidget" textboxQuestionWidgetName="ServiceZipQuestionWidget"
alertNonServiceableZipWidgetName="AlertNonServiceableZipWidget" alertNonServiceableZipWidgetName="AlertNonServiceableZipWidget"
alertInvalidZipWidgetName="AlertInvalidZipWidget" /> alertInvalidZipWidgetName="AlertInvalidZipWidget" />
<mobileLocationModalQuestion <mobileLocationModalQuestions
v-model="mobileLocationQuestion"
cmsWidgetName="MobileLocationModalWidget" cmsWidgetName="MobileLocationModalWidget"
modalWidgetName="LocationModalWidget" modalWidgetName="LocationModalWidget"
textboxQuestionWidgetName="MobileLocationQuestionWidget" /> textboxQuestionWidgetName="MobileLocationQuestionWidget" />
<funnel-footer <funnel-footer
cmsWidgetName="FunnelFooterWidget" cmsWidgetName="FunnelFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@ -26,7 +27,7 @@ fmg
<script> <script>
// Components // Components
import serviceZipModalQuestion from "@/layouts/service-location/service-zip-modal-question/service-zip-modal-question"; import serviceZipModalQuestion from "@/layouts/service-location/service-zip-modal-question/service-zip-modal-question";
import mobileLocationModalQuestion from "@/layouts/service-location/mobile-location-modal-question/mobile-location-modal-question"; import mobileLocationModalQuestions from "@/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions";
import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer";
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
@ -39,7 +40,17 @@ import { settleAllPromises } from "@/helpers/layout-helper";
export default { export default {
name: "service-location", name: "service-location",
data() { data() {
return {}; return {
mobileLocationQuestion: {
addressQuestions: {
streetAddress: "",
apartmentNumberOrBusinessName: "",
city: "",
state: "",
zipCode: "",
},
},
};
}, },
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
@ -70,7 +81,7 @@ export default {
}, },
components: { components: {
serviceZipModalQuestion, serviceZipModalQuestion,
mobileLocationModalQuestion, mobileLocationModalQuestions,
funnelHeader, funnelHeader,
funnelFooter, funnelFooter,
funnelSubHeader, funnelSubHeader,