some hide show updates change modelValue to emit
This commit is contained in:
parent
f72772e6b0
commit
b4e929d574
4 changed files with 45 additions and 24 deletions
|
|
@ -329,6 +329,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
inShopAvailabilityRating: 'high',
|
inShopAvailabilityRating: 'high',
|
||||||
inShopDatesData: [],
|
inShopDatesData: [],
|
||||||
|
isDatePickerRefreshing: false,
|
||||||
isMobileView: false,
|
isMobileView: false,
|
||||||
mobileDatesData: [],
|
mobileDatesData: [],
|
||||||
mobileFeePart: null,
|
mobileFeePart: null,
|
||||||
|
|
@ -362,7 +363,8 @@ export default {
|
||||||
const serviceLocationPreReqs = serviceLocationToUse.zipCode !== null
|
const serviceLocationPreReqs = serviceLocationToUse.zipCode !== null
|
||||||
&& serviceLocationToUse.zipCodeCtu !== null
|
&& serviceLocationToUse.zipCodeCtu !== null
|
||||||
&& serviceLocationToUse.appointmentType !== null
|
&& serviceLocationToUse.appointmentType !== null
|
||||||
&& (validMobileAppointmentType || validInShopAppointmentType);
|
&& (validMobileAppointmentType || validInShopAppointmentType)
|
||||||
|
&& !this.isDatePickerRefreshing;
|
||||||
|
|
||||||
const damageInfo = useMainStore().order.damage.isRepair
|
const damageInfo = useMainStore().order.damage.isRepair
|
||||||
|| (useMainStore().order.lineItems?.glassParts != null && useMainStore().order.lineItems.glassParts.length > 0);
|
|| (useMainStore().order.lineItems?.glassParts != null && useMainStore().order.lineItems.glassParts.length > 0);
|
||||||
|
|
@ -688,11 +690,12 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async refreshDatePicker() {
|
async refreshDatePicker() {
|
||||||
console.log('refresh date picker...');
|
|
||||||
this.resetLocalFlags();
|
this.resetLocalFlags();
|
||||||
|
this.isDatePickerRefreshing = true;
|
||||||
await this.getDatePickerInitialData().then((data) => {
|
await this.getDatePickerInitialData().then((data) => {
|
||||||
this.selectableDatesData = data.initialShopTimeSlotsResponse;
|
this.selectableDatesData = data.initialShopTimeSlotsResponse;
|
||||||
this.$refs.datePicker.initializeComponent(data);
|
this.$refs.datePicker.initializeComponent(data);
|
||||||
|
this.isDatePickerRefreshing = false;
|
||||||
showIssLoadingModal(false);
|
showIssLoadingModal(false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -96,13 +96,14 @@
|
||||||
</div>
|
</div>
|
||||||
<serviceZipQuestion
|
<serviceZipQuestion
|
||||||
ref="mobileServiceZipCodeQuestion"
|
ref="mobileServiceZipCodeQuestion"
|
||||||
v-model="mobileZipCode"
|
|
||||||
customInputId="mobileServiceZipCode"
|
customInputId="mobileServiceZipCode"
|
||||||
class="mobile-service-zip-question"
|
class="mobile-service-zip-question"
|
||||||
|
:parentZipCode="mobileZipCode"
|
||||||
:placeholderText="mobileZipPlaceholder"
|
:placeholderText="mobileZipPlaceholder"
|
||||||
:serviceZipFormatErrorMessage="errorMessages.MOBILE_SERVICE_ZIP_FORMAT"
|
:serviceZipFormatErrorMessage="errorMessages.MOBILE_SERVICE_ZIP_FORMAT"
|
||||||
:hasError="mobileZipError !== ''"
|
:hasError="mobileZipError !== ''"
|
||||||
cmsWidgetName="MobileZipWidget" />
|
cmsWidgetName="MobileZipWidget"
|
||||||
|
@serviceZipCodeUpdated="handleServiceZipCodeChanged" />
|
||||||
<div
|
<div
|
||||||
v-if="mobileZipError"
|
v-if="mobileZipError"
|
||||||
ref="errorMessageDiv"
|
ref="errorMessageDiv"
|
||||||
|
|
@ -300,16 +301,7 @@ export default {
|
||||||
},
|
},
|
||||||
async mobileZipCode(newZip, oldZip) {
|
async mobileZipCode(newZip, oldZip) {
|
||||||
if (newZip !== '' && newZip !== oldZip && !this.initializingData) {
|
if (newZip !== '' && newZip !== oldZip && !this.initializingData) {
|
||||||
showIssLoadingModal(true);
|
await this.processMobileZipCodeChange();
|
||||||
await this.updateMobileZip();
|
|
||||||
const updateMobileZipServiceLocationObj = {
|
|
||||||
mobileProviderNumber: this.mobileProviderNumber,
|
|
||||||
provider: null,
|
|
||||||
refreshDatePicker: true,
|
|
||||||
zipCode: this.zipCode,
|
|
||||||
zipCodeCtu: this.zipCodeCtu
|
|
||||||
};
|
|
||||||
this.$emit('mobile-zip-updated', updateMobileZipServiceLocationObj);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
schedulingInshopAvailabilityRating(newRating) {
|
schedulingInshopAvailabilityRating(newRating) {
|
||||||
|
|
@ -446,6 +438,26 @@ export default {
|
||||||
this.$emit('in-shop-zip-updated', inShopZipServiceLocationObj);
|
this.$emit('in-shop-zip-updated', inShopZipServiceLocationObj);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
async handleServiceZipCodeChanged(serviceZipCodeFromQuestion) {
|
||||||
|
if (serviceZipCodeFromQuestion !== this.mobileZipCode) {
|
||||||
|
// Can probs just make this one call but have to think about initialization flow and not wanting to trigger extra calls on load
|
||||||
|
this.mobileZipCode = serviceZipCodeFromQuestion;
|
||||||
|
} else {
|
||||||
|
await this.processMobileZipCodeChange();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async processMobileZipCodeChange() {
|
||||||
|
showIssLoadingModal(true);
|
||||||
|
await this.updateMobileZip();
|
||||||
|
const updateMobileZipServiceLocationObj = {
|
||||||
|
mobileProviderNumber: this.mobileProviderNumber,
|
||||||
|
provider: null,
|
||||||
|
refreshDatePicker: true,
|
||||||
|
zipCode: this.zipCode,
|
||||||
|
zipCodeCtu: this.zipCodeCtu
|
||||||
|
};
|
||||||
|
this.$emit('mobile-zip-updated', updateMobileZipServiceLocationObj);
|
||||||
|
},
|
||||||
setCtuForMobile(val) {
|
setCtuForMobile(val) {
|
||||||
this.zipCodeCtu = val;
|
this.zipCodeCtu = val;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
isRequired
|
isRequired
|
||||||
:hasError="hasError"
|
:hasError="hasError"
|
||||||
:validationRules="`zip-required|${cmsWidgetName}-zip-format`"
|
:validationRules="`zip-required|${cmsWidgetName}-zip-format`"
|
||||||
@clickEvent="updateModelValue"
|
@clickEvent="emitZipCodeUpdate"
|
||||||
@fieldHasError="handleFieldError" />
|
@fieldHasError="handleFieldError" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default {
|
||||||
},
|
},
|
||||||
// TODO: Correct prop def.
|
// TODO: Correct prop def.
|
||||||
props: {
|
props: {
|
||||||
modelValue: String,
|
parentZipCode: String,
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
serviceZipFormatErrorMessage: {
|
serviceZipFormatErrorMessage: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
@ -43,14 +43,14 @@ export default {
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['update:modelValue', 'field-has-error'],
|
emits: ['service-zip-code-updated', 'field-has-error'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
internalZipcode: this.modelValue
|
internalZipcode: this.parentZipCode
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
modelValue(newValue) {
|
parentZipCode(newValue) {
|
||||||
if (newValue !== this.internalZipcode) {
|
if (newValue !== this.internalZipcode) {
|
||||||
this.internalZipcode = newValue;
|
this.internalZipcode = newValue;
|
||||||
}
|
}
|
||||||
|
|
@ -63,8 +63,8 @@ export default {
|
||||||
handleFieldError(hasError) {
|
handleFieldError(hasError) {
|
||||||
this.$emit('field-has-error', hasError);
|
this.$emit('field-has-error', hasError);
|
||||||
},
|
},
|
||||||
updateModelValue() {
|
emitZipCodeUpdate() {
|
||||||
this.$emit('update:modelValue', this.internalZipcode);
|
this.$emit('service-zip-code-updated', this.internalZipcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,11 @@
|
||||||
<serviceZipQuestion
|
<serviceZipQuestion
|
||||||
v-if="renderServiceZip"
|
v-if="renderServiceZip"
|
||||||
:ref="SERVICE_ZIP_QUESTION_REF_NAME"
|
:ref="SERVICE_ZIP_QUESTION_REF_NAME"
|
||||||
v-model="internalZipcode"
|
:parentZipCode="internalZipcode"
|
||||||
customInputId="serviceZipCode"
|
customInputId="serviceZipCode"
|
||||||
:cmsWidgetName="textboxQuestionWidgetName"
|
:cmsWidgetName="textboxQuestionWidgetName"
|
||||||
@fieldHasError="handleFieldError" />
|
@fieldHasError="handleFieldError"
|
||||||
|
@serviceZipCodeUpdated="handleServiceZipCodeChanged" />
|
||||||
<div
|
<div
|
||||||
v-if="errorMessage"
|
v-if="errorMessage"
|
||||||
ref="errorMessageDiv"
|
ref="errorMessageDiv"
|
||||||
|
|
@ -243,7 +244,7 @@ export default {
|
||||||
showIssLoadingModal(false);
|
showIssLoadingModal(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async updateShops(autoExpand = false) {
|
async updateShops(autoExpand = false) {
|
||||||
this.errorMessage = '';
|
this.errorMessage = '';
|
||||||
let result = await this.getNearbyShops(this.searchRadiusInMiles);
|
let result = await this.getNearbyShops(this.searchRadiusInMiles);
|
||||||
|
|
@ -333,6 +334,11 @@ export default {
|
||||||
this.errorMessage = '';
|
this.errorMessage = '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async handleServiceZipCodeChanged(serviceZipCodeFromQuestion) {
|
||||||
|
if (serviceZipCodeFromQuestion !== this.internalZipcode) {
|
||||||
|
this.internalZipcode = serviceZipCodeFromQuestion;
|
||||||
|
}
|
||||||
|
},
|
||||||
forceServiceZipRerender() {
|
forceServiceZipRerender() {
|
||||||
this.renderServiceZip = false;
|
this.renderServiceZip = false;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue