diff --git a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js index cf620b15f..5cade9ddb 100644 --- a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js +++ b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.spec.js @@ -59,6 +59,80 @@ describe("address-questions.vue", () => { expect(zipCode.exists()).toBe(true); }); + test("Should render apartmentNumberOrBusinessName textbox-question when captureApartmentNumberOrBusinessName = true", async () => { + // Arrange + const { wrapper } = setupMocks({ + props: { + modelValue: { + streetAddress: "", + apartmentNumberOrBusinessName: "", + city: "", + state: "", + zipCode: "", + }, + captureApartmentNumberOrBusinessName: true, + }, + }); + + await wrapper.setData({ + showAddressFields: true, + }); + + // Act + const streetAddress = wrapper.findComponent({ ref: "autocomplete" }); + const apartmentNumberOrBusinessName = wrapper.findComponent({ + ref: "apartmentNumberOrBusinessName", + }); + const city = wrapper.findComponent({ ref: "city" }); + const state = wrapper.findComponent({ ref: "state" }); + const zipCode = wrapper.findComponent({ ref: "zipCode" }); + + // Assert + expect(streetAddress.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.isVisible()).toBe(true); + expect(city.exists()).toBe(true); + expect(state.exists()).toBe(true); + expect(zipCode.exists()).toBe(true); + }); + + test("Should *not* render apartmentNumberOrBusinessName textbox-question when captureApartmentNumberOrBusinessName = false", async () => { + // Arrange + const { wrapper } = setupMocks({ + props: { + modelValue: { + streetAddress: "", + apartmentNumberOrBusinessName: "", + city: "", + state: "", + zipCode: "", + }, + captureApartmentNumberOrBusinessName: false, + }, + }); + + await wrapper.setData({ + showAddressFields: true, + }); + + // Act + const streetAddress = wrapper.findComponent({ ref: "autocomplete" }); + const apartmentNumberOrBusinessName = wrapper.findComponent({ + ref: "apartmentNumberOrBusinessName", + }); + const city = wrapper.findComponent({ ref: "city" }); + const state = wrapper.findComponent({ ref: "state" }); + const zipCode = wrapper.findComponent({ ref: "zipCode" }); + + // Assert + expect(streetAddress.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.exists()).toBe(true); + expect(apartmentNumberOrBusinessName.isVisible()).toBe(false); + expect(city.exists()).toBe(true); + expect(state.exists()).toBe(true); + expect(zipCode.exists()).toBe(true); + }); + test("Should set this.showAddressFields to true when the model is prepopulated", async () => { // Arrange // Act diff --git a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue index 23bc9280c..ff7fb0d9a 100644 --- a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue +++ b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue @@ -16,6 +16,21 @@ @keydown.enter.prevent /> + +
+
+ +
+
+
@@ -78,7 +93,6 @@ import { applicationConfig } from "@/constants/application-config.js"; import { defineRule } from "vee-validate"; import { required, regex } from "@/helpers/validation-rules"; import { errorMessages } from "@/constants/error-messages"; -import { fill } from "lodash"; // DEFINE VALIDATION RULES defineRule("street-address-required", required(errorMessages.STREET_ADDRESS_REQUIRED)); @@ -95,12 +109,17 @@ export default { type: Object, default: () => ({ streetAddress: "", + apartmentNumberOrBusinessName: "", city: "", state: "", zipCode: "", }), }, validationRules: String, + captureApartmentNumberOrBusinessName: { + type: Boolean, + default: false, + }, }, data() { return { @@ -180,6 +199,11 @@ export default { this.$emit("update:modelValue", newValue); }, }, + showApartmentNumberOrBusinessNameField: { + get: function () { + return this.captureApartmentNumberOrBusinessName; + }, + }, }, methods: { setupAddressLookup() { @@ -233,13 +257,17 @@ export default { }); 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( ".pac-container .pac-item-selected" ); if (selectedItem !== null) { // Fill-in the address using selected item in the list. - fillInAddress(selectedItem); + autocomplete.dispatchEvent(event); + //fillInAddress(selectedItem.textContent); } else { // Fill-in the address using first item in the list. fillInAddressUsingFirstItem(); @@ -249,23 +277,25 @@ export default { } }); - addressField1.addEventListener("change", () => { - // If a match has been previously attempted then do nothing - if (self.matchFound !== null) { - return; - } + // addressField1.addEventListener("change", () => { + // // If a match has been previously attempted then do nothing + // if (self.matchFound !== null) { + // return; + // } - // Get the address that the user clicked on (if any) - const clickedAddress = document.querySelector( - ".pac-container .pac-item:hover" - ); + // // Get the address that the user clicked on (if any) + // const clickedAddress = document.querySelector( + // ".pac-container .pac-item:hover" + // ); - // If the Street Address field changed without clicking (i.e. by pressing Tab, or clicking outside the field) - if (clickedAddress === null) { - // Fill-in the address using first item in the list. - fillInAddressUsingFirstItem(); - } - }); + // // If the Street Address field changed without clicking (i.e. by pressing Tab, or clicking outside the field) + // if (clickedAddress === null) { + // // Fill-in the address using first item in the list. + // fillInAddressUsingFirstItem(); + // } + + // console.log("change"); + // }); function fillInAddressUsingFirstItem() { // Fill-in the address using first item in the list. @@ -290,6 +320,7 @@ export default { } function fillInAddress(place) { + console.log("fillInAddress"); if (!place) { place = autocomplete.getPlace(); } @@ -297,8 +328,11 @@ export default { if (place && place.address_components) { self.matchFound = true; - self.addressModel.streetAddress = ""; self.$nextTick(function () { + //self.addressModel.streetAddress = ""; + + //self.$nextTick(); + self.showAddressFields = true; for (const component of place.address_components) { @@ -382,6 +416,11 @@ export default { } }, }, + "addressModel.streetAddress": { + handler(newValue, oldValue) { + console.log(`I got changed from ${oldValue} to ${newValue}`); + }, + }, }, components: { textboxQuestion, diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue new file mode 100644 index 000000000..7aea041e9 --- /dev/null +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.vue b/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.vue new file mode 100644 index 000000000..b8c795d5f --- /dev/null +++ b/src/layouts/service-location/mobile-location-modal-questions/vehicle-protected-question/vehicle-protected-question.vue @@ -0,0 +1,53 @@ + + + \ No newline at end of file diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 872c8f4c0..a34875dbb 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -9,6 +9,11 @@ fmg textboxQuestionWidgetName="ServiceZipQuestionWidget" alertNonServiceableZipWidgetName="AlertNonServiceableZipWidget" alertInvalidZipWidgetName="AlertInvalidZipWidget" /> + // Components import serviceZipModalQuestion from "@/layouts/service-location/service-zip-modal-question/service-zip-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 funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; @@ -33,7 +39,17 @@ import { settleAllPromises } from "@/helpers/layout-helper"; export default { name: "service-location", data() { - return {}; + return { + mobileLocationQuestion: { + addressQuestions: { + streetAddress: "", + apartmentNumberOrBusinessName: "", + city: "", + state: "", + zipCode: "", + }, + }, + }; }, async beforeRouteEnter(to, from, next) { // Call APIs @@ -64,6 +80,7 @@ export default { }, components: { serviceZipModalQuestion, + mobileLocationModalQuestions, funnelHeader, funnelFooter, funnelSubHeader,