Model reset stuff

This commit is contained in:
Leah Schumann 2023-02-14 10:50:27 -05:00
parent 6b24f56a2b
commit d7fa90ee58
4 changed files with 36 additions and 7 deletions

View file

@ -207,6 +207,7 @@ export default {
}, },
methods: { methods: {
setupAddressLookup() { setupAddressLookup() {
this.showAddressFields = false;
if ( if (
this.addressModel.streetAddress && this.addressModel.streetAddress &&
this.addressModel.city && this.addressModel.city &&

View file

@ -146,18 +146,24 @@ export default {
onModalClosed() { onModalClosed() {
this.mobileLocationQuestionsInput = this.mobileLocationQuestionsModel; this.mobileLocationQuestionsInput = this.mobileLocationQuestionsModel;
}, },
resetModel() { resetComponent() {
// Address // Address
this.addressModel.streetAddress = ""; this.addressModelInput.streetAddress = "";
this.addressModel.apartmentNumberOrBusinessName = ""; this.addressModelInput.apartmentNumberOrBusinessName = "";
this.addressModel.city = ""; this.addressModelInput.city = "";
this.addressModel.state = ""; this.addressModelInput.state = "";
this.addressModel.zipCode = ""; this.addressModelInput.zipCode = "";
// Is Vehicle Protected // Is Vehicle Protected
this.mobileLocationQuestionsInput.isVehicleProtected = null; this.mobileLocationQuestionsInput.isVehicleProtected = null;
this.$refs[this.modalName].form.resetForm();
this.$refs.addressQuestions.setupAddressLookup();
}, },
async setMobileLocation() { async setMobileLocation() {
// TODO: Any lookups or actions to be taken before assigning the Mobile Location
this.mobileLocationQuestionsModel = { this.mobileLocationQuestionsModel = {
addressQuestions: { addressQuestions: {
streetAddress: this.addressModelInput.streetAddress, streetAddress: this.addressModelInput.streetAddress,

View file

@ -6,11 +6,13 @@
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" /> <funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
<serviceZipModalQuestion <serviceZipModalQuestion
v-model="serviceZipQuestionModel" v-model="serviceZipQuestionModel"
@service-zip-updated="resetMobileLocation"
linkWidgetName="ServiceZipLinkWidget" linkWidgetName="ServiceZipLinkWidget"
modalWidgetName="ServiceZipModalWidget" modalWidgetName="ServiceZipModalWidget"
textboxQuestionWidgetName="ServiceZipQuestionWidget" textboxQuestionWidgetName="ServiceZipQuestionWidget"
alertInvalidZipWidgetName="AlertInvalidZipWidget" /> alertInvalidZipWidgetName="AlertInvalidZipWidget" />
<mobileLocationModalQuestions <mobileLocationModalQuestions
ref="mobileLocationModalQuestions"
v-model="mobileLocationQuestionsModel" v-model="mobileLocationQuestionsModel"
linkWidgetName="MobileLocationLinkWidget" linkWidgetName="MobileLocationLinkWidget"
modalWidgetName="MobileLocationModalWidget" modalWidgetName="MobileLocationModalWidget"
@ -121,7 +123,22 @@ export default {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
return true; return true;
}, },
resetMobileLocation() {
this.mobileLocationQuestionsModel = {
addressQuestions: {
streetAddress: "",
apartmentNumberOrBusinessName: "",
city: "",
state: "",
zipCode: "",
},
isVehicleProtected: null,
isZipServiceableMobile: null,
isZipServiceableInShop: null,
};
this.$refs.mobileLocationModalQuestions.resetComponent();
},
backButtonAction() { backButtonAction() {
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },

View file

@ -138,6 +138,11 @@ export default {
this.displayInvalidZipAlert = true; this.displayInvalidZipAlert = true;
this.focusOnZipInput(); this.focusOnZipInput();
} else { } else {
// if the service zip code changes we need to clear the Mobile Location Model
if (this.serviceZipModel.zipCode !== "" && this.serviceZipCodeInput !== this.serviceZipModel.zipCode ) {
this.$emit("service-zip-updated");
}
this.serviceZipModel = { this.serviceZipModel = {
state: zipCodeData.state, state: zipCodeData.state,
zipCode: this.serviceZipCodeInput, zipCode: this.serviceZipCodeInput,