From ca0b266efae93412f6732ee398bc753954343602 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Tue, 1 Mar 2022 14:12:05 -0500 Subject: [PATCH] CSR-319: move validation into vehicle-damage page --- .../replace-options-question.vue | 49 ++++----- src/layouts/vehicle-damage/vehicle-damage.vue | 102 +++++++++++++----- .../windshield-options/windshield-options.vue | 3 +- .../list-button-horizontal.vue | 2 +- src/ux-components/list-button/list-button.vue | 2 +- src/ux-components/list-card/list-card.vue | 4 +- 6 files changed, 107 insertions(+), 55 deletions(-) diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue index bc42364d2..63c72f7ce 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue @@ -1,6 +1,7 @@ @@ -40,6 +71,7 @@ import sideDoorOptions from "@/layouts/vehicle-damage/side-door-options/side-doo import damageLocationQuestion from "@/layouts/vehicle-damage/damage-location-question/damage-location-question"; import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/windshield-options"; import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question"; +import alert from "@/ux-components/alert/alert"; // Supporting files import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; @@ -47,7 +79,7 @@ import { settleAllPromises } from "@/helpers/layout-helper"; import { storeActions } from "@/constants/store-actions"; import store from "@/store"; import baseMixin from "@/mixins/base-mixin"; -import { defineRule } from "vee-validate"; +import { Form, defineRule } from "vee-validate"; // DEFINE VALIDATION RULES defineRule("replace-options-required", (value) => { @@ -147,6 +179,24 @@ export default { this.$route ); }, + onSubmit(values) { + window.alert('Success! Submitted values: ' + JSON.stringify(values, null ,2)) + console.log('submitted: ', JSON.stringify(values, null ,2)); + }, + onInvalidSubmit({ values, errors, results }) { + // identify the first error field and put focus on it + console.log("values: ", values); + console.log("errors: ", errors); + console.log("results: ", results); + // get error names array + const errorNames = errors ? Object.keys(errors) : []; + const firstErrorEl = errorNames[0]; + if (firstErrorEl) { + console.log('firstErrorEl: ', firstErrorEl); + const qsString = "[data-focus-target='" + firstErrorEl + "']"; + document.querySelector(qsString).focus(); + } + }, }, components: { funnelHeader, @@ -157,6 +207,8 @@ export default { damageLocationQuestion, windshieldOptions, replaceOptionsQuestion, + Form, + alert, }, }; diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue index fc265fd0a..5a2c2f62e 100644 --- a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue +++ b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue @@ -1,5 +1,6 @@