DigitalConsumer.ISS/src/mixins/base-form-mixin.js
2024-05-02 14:23:18 -04:00

31 lines
921 B
JavaScript

import showIssLoadingModal from '@/helpers/loading-modal-helper';
export default {
mounted() {
showIssLoadingModal(false);
},
methods: {
onSubmit() {
/**
* DO NOT REMOVE;
* Needed to prevent default form submit behavior.
* Cannot use .prevent modifier for vee-validate Form.
*/
},
onInvalidSubmit({ errors }) {
/**
* Identify the first error field and put focus on it
* get error names array
*/
const errorNames = errors ? Object.keys(errors) : [];
const firstErrorEl = errorNames[0];
if (firstErrorEl) {
const qsString = `[data-focus-target="${firstErrorEl}"]`;
const el = document.querySelector(qsString);
if (el !== null) {
el.focus();
}
}
}
}
};