This commit is contained in:
Leah Schumann 2023-05-09 07:30:21 -04:00
parent 1dd661e7df
commit 3cf505f697
4 changed files with 51 additions and 37 deletions

View file

@ -137,6 +137,9 @@ export default {
alertInvalidZipWidgetName: String, alertInvalidZipWidgetName: String,
customComponentId: String, customComponentId: String,
validationRules: String, validationRules: String,
optionalCallback: {
type: Function,
},
}, },
computed: { computed: {
mobileLocationLinkPromptText() { mobileLocationLinkPromptText() {
@ -257,6 +260,10 @@ export default {
// Update the page level model // Update the page level model
this.$emit("update:modelValue", this.internalModel); this.$emit("update:modelValue", this.internalModel);
if (this.optionalCallback) {
await this.optionalCallback(serviceZipCode);
}
this.closeModal(); this.closeModal();
} }
}, },

View file

@ -12,7 +12,8 @@
@updated-serviceability="setServiceabilityDetails" @updated-serviceability="setServiceabilityDetails"
@updated-contains-military-base="setContainsMilitaryBase" @updated-contains-military-base="setContainsMilitaryBase"
linkWidgetName="ServiceZipLinkWidget" linkWidgetName="ServiceZipLinkWidget"
modalWidgetName="ServiceZipModalWidget" /> modalWidgetName="ServiceZipModalWidget"
:optionalCallback="reloadShopData" />
<alert <alert
ref="alertMilitaryBaseZip" ref="alertMilitaryBaseZip"
class="my-5" class="my-5"
@ -64,17 +65,16 @@
validationRules="mobile-location-required" validationRules="mobile-location-required"
ref="mobileLocationQuestions" ref="mobileLocationQuestions"
linkWidgetName="MobileLocationLinkWidget" linkWidgetName="MobileLocationLinkWidget"
modalWidgetName="MobileLocationModalWidget" /> modalWidgetName="MobileLocationModalWidget"
:optionalCallback="reloadShopData" />
<Transition name="fade" mode="out-in"> <Transition name="fade" mode="out-in">
<shopQuestion <shopQuestion
ref="shopQuestion" ref="shopQuestion"
v-show=" v-show="isShopQuestionDisplayed"
selectedAppointmentType === 'Inshop' ||
selectedAppointmentType === 'Dropoff'
"
v-model="selectedProvider" v-model="selectedProvider"
:serviceZipCode="zipCode" :serviceZipCode="zipCode"
:selectedAppointmentType="selectedAppointmentType" :selectedAppointmentType="selectedAppointmentType"
:isDisplayed="isShopQuestionDisplayed"
cmsWidgetName="ShopQuestionWidget" /> cmsWidgetName="ShopQuestionWidget" />
</Transition> </Transition>
<contentGroupModal ref="RecalModal" cmsWidgetName="RecalModal" /> <contentGroupModal ref="RecalModal" cmsWidgetName="RecalModal" />
@ -268,6 +268,12 @@ export default {
return this.isGlassServiceableInshop; return this.isGlassServiceableInshop;
} }
}, },
isShopQuestionDisplayed() {
return (
this.selectedAppointmentType === "Inshop" ||
this.selectedAppointmentType === "Dropoff"
);
},
// Specifically check for isRecalibrationServiceableMobile === false, not null or true. // Specifically check for isRecalibrationServiceableMobile === false, not null or true.
requiresInshopRecalibration() { requiresInshopRecalibration() {
return ( return (
@ -364,6 +370,9 @@ export default {
openModalAction(modalName) { openModalAction(modalName) {
this.$refs[modalName].openModal(); this.$refs[modalName].openModal();
}, },
async reloadShopData() {
await this.$refs.shopQuestion.reloadShopData(this.zipCode);
},
}, },
components: { components: {
alert, alert,

View file

@ -69,6 +69,9 @@ export default {
}, },
linkWidgetName: String, linkWidgetName: String,
modalWidgetName: String, modalWidgetName: String,
optionalCallback: {
type: Function,
},
}, },
setup() { setup() {
const textboxQuestionWidgetName = "ServiceZipQuestionWidget"; const textboxQuestionWidgetName = "ServiceZipQuestionWidget";
@ -161,6 +164,10 @@ export default {
// Update the page level model // Update the page level model
this.$emit("update:modelValue", this.internalModel); this.$emit("update:modelValue", this.internalModel);
if (this.optionalCallback) {
await this.optionalCallback(serviceZipCode);
}
this.closeModal(); this.closeModal();
} }
} else { } else {

View file

@ -1,6 +1,6 @@
<template> <template>
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<div class="shop-question" aria-live="polite"> <div v-if="isDisplayed" class="shop-question" aria-live="polite">
<alert <alert
ref="alertDropoffInformation" ref="alertDropoffInformation"
v-if="displayDropoffInformation" v-if="displayDropoffInformation"
@ -49,6 +49,7 @@ import { defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules"; import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import baseMixin from "@/mixins/base-mixin.js"; import baseMixin from "@/mixins/base-mixin.js";
import { nextTick } from "vue";
defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
@ -73,6 +74,7 @@ export default {
selectedAppointmentType: String, selectedAppointmentType: String,
cmsWidgetName: String, cmsWidgetName: String,
validationRules: String, validationRules: String,
isDisplayed: Boolean,
}, },
computed: { computed: {
questionText() { questionText() {
@ -83,9 +85,11 @@ export default {
return this.modelValue; return this.modelValue;
}, },
set: function (newValue) { set: function (newValue) {
const provider = this.shopProviders.find( // Button Question only supports primitive values so we must get the full object to emit to the page
const provider = this.shopProviders?.find(
(provider) => provider.providerNumber == newValue (provider) => provider.providerNumber == newValue
); );
this.$emit("update:modelValue", provider); this.$emit("update:modelValue", provider);
}, },
}, },
@ -98,6 +102,9 @@ export default {
}, },
methods: { methods: {
loadInitialData(serviceZipCode) { loadInitialData(serviceZipCode) {
return this.loadData(serviceZipCode);
},
loadData(serviceZipCode) {
return baseMixin.methods.dispatchStoreAction(storeActions.GET_PROVIDERS, { return baseMixin.methods.dispatchStoreAction(storeActions.GET_PROVIDERS, {
serviceZipCode: serviceZipCode, serviceZipCode: serviceZipCode,
}); });
@ -164,44 +171,28 @@ export default {
this.answers = []; this.answers = [];
this.shopIndex = 0; this.shopIndex = 0;
this.selectedValue = ""; this.selectedValue = "";
this.$refs.buttonQuestion.resetField();
}, },
async reloadShopData(serviceZipCode) { async reloadShopData(serviceZipCode) {
const result = await this.loadInitialData(serviceZipCode); const result = await this.loadData(serviceZipCode);
this.initializeComponent(result); this.initializeComponent(result.data);
this.resetShopList(); this.resetShopList();
await nextTick();
await this.getNextShopsFromList();
}, },
}, },
watch: { watch: {
serviceZipCode: {
async handler(newValue) {
await this.reloadShopData(newValue);
},
},
selectedAppointmentType: { selectedAppointmentType: {
async handler() { async handler(newValue) {
// If the validation has been previously triggered, clear it before displaying the component
this.$refs.buttonQuestion.resetField();
this.resetShopList(); this.resetShopList();
await this.$nextTick();
if (newValue !== "Mobile") {
await this.getNextShopsFromList(); await this.getNextShopsFromList();
await this.$nextTick(); await this.$nextTick();
this.scrollToPageBottom(); this.scrollToPageBottom();
},
},
shopProviders: {
async handler(newValue) {
this.$refs.buttonQuestion.resetField();
const selectedShopIndex = newValue.findIndex(
(provider) => provider.providerNumber == this.modelValue?.providerNumber
);
if (selectedShopIndex >= 3) {
await this.getNextShopsFromList(selectedShopIndex + 1);
} else {
await this.getNextShopsFromList();
} }
}, },
}, },