Updates to service location when coming out of a modal.

This commit is contained in:
Bill Richardson 2023-09-19 16:59:09 -04:00
parent 860620240a
commit f4b2b96c91
4 changed files with 43 additions and 3 deletions

View file

@ -80,7 +80,7 @@ import listButton from '@/ux-components/list-button/list-button.vue';
import listButtonHorizontal from '@/ux-components/list-button-horizontal/list-button-horizontal.vue'; import listButtonHorizontal from '@/ux-components/list-button-horizontal/list-button-horizontal.vue';
import listCard from '@/ux-components/list-card/list-card.vue'; import listCard from '@/ux-components/list-card/list-card.vue';
import radio from '@/ux-components/radio/radio.vue'; import radio from '@/ux-components/radio/radio.vue';
import { ErrorMessage } from 'vee-validate'; import { useField, ErrorMessage } from 'vee-validate';
import providerPrefRadio from '@/layouts/provider-preference/provider-pref-radio/provider-pref-radio.vue'; import providerPrefRadio from '@/layouts/provider-preference/provider-pref-radio/provider-pref-radio.vue';
export default { export default {
@ -134,6 +134,28 @@ export default {
isSmallQuestionLabelText: Boolean isSmallQuestionLabelText: Boolean
}, },
emits: ['update:modelValue'], emits: ['update:modelValue'],
setup(props) {
const propsClone = { ...props };
const { modelValue } = propsClone;
const fieldOptions = {
value: modelValue,
initialValue: null
};
const { errorMessage, handleBlur, handleChange, meta, validate, errors, resetField } =
useField(props.groupName, props.validationRules, fieldOptions);
return {
errorMessage,
handleBlur,
handleChange,
validate,
meta,
errors,
resetField
};
},
data() { data() {
return { return {
lastValuePushedToGa: null lastValuePushedToGa: null
@ -231,6 +253,13 @@ export default {
} }
} }
}, },
watch: {
modelValue(newValue) {
this.resetField({
value: newValue
});
}
},
beforeMount() { beforeMount() {
if (this.buttonTypeObject) { if (this.buttonTypeObject) {
this.$options.components[this.buttonTypeString] = this.buttonTypeObject; this.$options.components[this.buttonTypeString] = this.buttonTypeObject;

View file

@ -128,7 +128,7 @@ export default {
type: Function type: Function
} }
}, },
emits: ['update:modelValue', 'updated-mobile-fee-part', 'updated-contains-military-base'], emits: ['update:modelValue', 'updated-mobile-fee-part', 'updated-contains-military-base', 'updated-serviceability'],
setup(props) { setup(props) {
const uuid = crypto.randomUUID(); const uuid = crypto.randomUUID();
const componentId = !props.customComponentId const componentId = !props.customComponentId

View file

@ -14,6 +14,7 @@
ref="serviceZipCodeQuestion" ref="serviceZipCodeQuestion"
v-model="serviceZipCodeQuestion" v-model="serviceZipCodeQuestion"
modalWidgetName="ServiceZipModalWidget" modalWidgetName="ServiceZipModalWidget"
:onZipUpdateCallback="reloadShopData"
@updatedServiceability="setServiceabilityDetails" @updatedServiceability="setServiceabilityDetails"
@updatedContainsMilitaryBase="setContainsMilitaryBase" /> @updatedContainsMilitaryBase="setContainsMilitaryBase" />
<alert <alert
@ -329,6 +330,9 @@ export default {
*/ */
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
async reloadShopData() {
await this.$refs.shopQuestion.reloadShopData(this.zipCode);
},
async forwardButtonAction() { async forwardButtonAction() {
useMainStore().saveServiceLocation({ useMainStore().saveServiceLocation({
address: this.streetAddress, address: this.streetAddress,

View file

@ -57,7 +57,10 @@ export default {
zipCode: '' zipCode: ''
}) })
}, },
modalWidgetName: String modalWidgetName: String,
onZipUpdateCallback: {
type: Function
}
}, },
emits: ['update:modelValue', 'updated-serviceability', 'updated-contains-military-base'], emits: ['update:modelValue', 'updated-serviceability', 'updated-contains-military-base'],
setup() { setup() {
@ -162,6 +165,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.onZipUpdateCallback) {
await this.onZipUpdateCallback(serviceZipCode);
}
this.closeModal(); this.closeModal();
} }
} else { } else {