Merge pull request #1247 from Safelite/defect/CSR-1485
Add error validation to date-picker
This commit is contained in:
commit
04f36bc290
2 changed files with 45 additions and 0 deletions
|
|
@ -56,6 +56,9 @@
|
|||
:class="[!isLoading ? 'date-picker-hidden' : '']"
|
||||
loaderColor="blue"
|
||||
loaderPosition="center" />
|
||||
<div class="row form-test-error">
|
||||
<ErrorMessage name="date-of-month" class="small mt-1"></ErrorMessage>
|
||||
</div>
|
||||
<button
|
||||
v-if="calendarViewDirection === 'future' && !disableViewMoreDatesButton"
|
||||
type="button"
|
||||
|
|
@ -79,6 +82,7 @@ import {
|
|||
convertDateToDateString,
|
||||
convertDateStringToDate,
|
||||
} from "@/layouts/schedule/helpers/schedule-helper";
|
||||
import { useField, ErrorMessage } from "vee-validate";
|
||||
|
||||
export default {
|
||||
name: "datePicker",
|
||||
|
|
@ -113,6 +117,32 @@ export default {
|
|||
return [];
|
||||
},
|
||||
},
|
||||
validationRules: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const propsClone = Object.assign({}, props);
|
||||
const modelValue = propsClone.modelValue;
|
||||
|
||||
const fieldOptions = {
|
||||
value: modelValue,
|
||||
initialValue: modelValue,
|
||||
};
|
||||
|
||||
const { errorMessage, handleBlur, handleChange, meta, validate, errors, resetField } =
|
||||
useField("date-of-month", props.validationRules, fieldOptions);
|
||||
|
||||
return {
|
||||
errorMessage,
|
||||
handleBlur,
|
||||
handleChange,
|
||||
validate,
|
||||
meta,
|
||||
errors,
|
||||
resetField,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
todayString() {
|
||||
|
|
@ -639,8 +669,16 @@ export default {
|
|||
window.requestAnimationFrame(step);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
modelValue(newValue, oldValue) {
|
||||
this.resetField({
|
||||
value: newValue,
|
||||
});
|
||||
},
|
||||
},
|
||||
components: {
|
||||
loader,
|
||||
ErrorMessage,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -979,4 +1017,10 @@ export default {
|
|||
text-underline-offset: 4px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.form-test-error {
|
||||
margin: 0 auto 2rem auto;
|
||||
max-width: 414px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
v-model="selectedDate"
|
||||
class="text-link-small"
|
||||
:customSelectableDatesCallback="getAvailableDatesMethod"
|
||||
validationRules="date-required"
|
||||
@date-clicked="openInshopTimeSlotsModal" />
|
||||
<time-slot-modal-question
|
||||
ref="timeSlotModalQuestion"
|
||||
|
|
|
|||
Loading…
Reference in a new issue