From de717b10e9773aa9754a4389707cf7b1318cbd0b Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Mon, 24 Jul 2023 09:06:29 -0400 Subject: [PATCH] Changed modal to work like the other modals which fixed CSR-1510 --- .../date-picker/date-picker.vue | 18 ++++-- src/layouts/schedule/schedule.vue | 25 +++++++- .../time-slot-modal-question.vue | 60 +++++++++++-------- 3 files changed, 71 insertions(+), 32 deletions(-) diff --git a/src/digital-components/date-picker/date-picker.vue b/src/digital-components/date-picker/date-picker.vue index 2f42ebd16..775c8596f 100644 --- a/src/digital-components/date-picker/date-picker.vue +++ b/src/digital-components/date-picker/date-picker.vue @@ -84,6 +84,9 @@ import { } from "@/layouts/schedule/helpers/schedule-helper"; import { useField, ErrorMessage } from "vee-validate"; +import { deepClone } from "@/helpers/object-helper"; +import { v4 as uuidv4 } from "uuid"; + export default { name: "datePicker", data() { @@ -96,6 +99,7 @@ export default { }; }, props: { + customComponentId: String, selectableDatesSetting: { type: String, validator(value) { @@ -123,18 +127,24 @@ export default { }, }, setup(props) { - const propsClone = Object.assign({}, props); - const modelValue = propsClone.modelValue; + const uuid = uuidv4(); + const componentId = !props.customComponentId + ? `component-${uuid}` + : props.customComponentId; + + const modelValue = deepClone(props).modelValue; + const initialValue = modelValue; const fieldOptions = { value: modelValue, - initialValue: modelValue, + initialValue: initialValue, }; const { errorMessage, handleBlur, handleChange, meta, validate, errors, resetField } = - useField("date-of-month", props.validationRules, fieldOptions); + useField(componentId, props.validationRules, fieldOptions); return { + componentId, errorMessage, handleBlur, handleChange, diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 8d295ce76..bd3457af7 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -13,6 +13,7 @@ { if ( value.date == null || value.startTime == null || - value.endTime == null || value.routeCode == null || value.estimatedServiceMinutesMaximum ) { @@ -339,6 +340,12 @@ export default { (lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE ).length; }, + timeSlotModalClosed() { + // Clear the selectedDate if no timeSlot has been selected + if (this.selectedTimeSlot.routeCode == null) { + this.selectedDate = null; + } + }, updateFooterButtonText(timeSlot) { let funnelFooterButtonText; if (!timeSlot || !timeSlot.date) { @@ -438,6 +445,18 @@ export default { }, }, watch: { + selectedDate(newValue, oldValue) { + // Clear time slot selection if date selected changes + if (newValue !== oldValue) { + this.selectedTimeSlot = { + date: null, + routeCode: null, + startTime: null, + endTime: null, + jobMaxMinutes: null, + }; + } + }, selectedTimeSlot(newValue) { this.updateFooterButtonText(newValue); }, diff --git a/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue b/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue index 5b5692605..786ec71b9 100644 --- a/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue +++ b/src/layouts/schedule/time-slot-modal-question/time-slot-modal-question.vue @@ -3,10 +3,9 @@ :ref="modalName" :headerText="dateSelectedReadableDate" :footerButtonText="footerCloseButtonText" - :onModalOpenedCallback="onModalOpened" :onModalClosedCallback="onModalClosed" @isModalOpened="setModalStatus" - @footer-button-event="setTimeSlot" + @footer-button-event="setSelectedTimeSlot" class="time-slots-modal">