From 84b0257de26d91610cf3e7f2a787739669ee73c7 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Fri, 4 Mar 2022 15:02:39 -0500 Subject: [PATCH] CSR-319: improve repair/replace logic --- src/constants/error-messages.js | 2 +- .../damage-location-question.vue | 2 +- .../side-door-options/side-door-options.vue | 2 +- src/layouts/vehicle-damage/vehicle-damage.vue | 51 ++++++++----------- .../windshield-options/windshield-options.vue | 8 +-- 5 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js index 963840bda..ba2b0e585 100644 --- a/src/constants/error-messages.js +++ b/src/constants/error-messages.js @@ -9,4 +9,4 @@ const errorMessages = { REPLACE_OPTIONS_REQUIRED: "Please select rear window type", }; -export default { errorMessages }; \ No newline at end of file +export { errorMessages }; \ No newline at end of file diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue index ec32273f0..dff518342 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue @@ -17,7 +17,7 @@ import buttonQuestion from "@/common-components/button-question/button-question" import store from "@/store"; import { defineRule } from "vee-validate"; import { required } from "@/helpers/validation-rules"; -import errorMessages from "@/constants/error-messages"; +import { errorMessages } from "@/constants/error-messages"; // DEFINE VALIDATION RULES defineRule("damage-location-required", required(errorMessages.DAMAGE_LOCATION_REQUIRED)); diff --git a/src/layouts/vehicle-damage/side-door-options/side-door-options.vue b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue index d58f986f7..9366954ec 100644 --- a/src/layouts/vehicle-damage/side-door-options/side-door-options.vue +++ b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue @@ -40,7 +40,7 @@ import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-que import store from "@/store"; import { defineRule } from "vee-validate"; import { required } from "@/helpers/validation-rules"; -import errorMessages from "@/constants/error-messages"; +import { errorMessages } from "@/constants/error-messages"; // DEFINE VALIDATION RULES defineRule("damage-side-required", required(errorMessages.DAMAGE_SIDE_REQUIRED)); diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 1f7fa0996..7d68961d9 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -7,7 +7,7 @@ @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" - v-slot="{ values, meta, errors }" + v-slot="{ meta }" > - - -
-

Current Form, values:

-
{{ values }}
-

Errors:

-
{{ errors }}
-

Is Form Valid? (Meta.valid):

-
{{ meta.valid }}
-
- @@ -82,7 +72,7 @@ import store from "@/store"; import baseMixin from "@/mixins/base-mixin"; import { Form, defineRule } from "vee-validate"; import { required } from "@/helpers/validation-rules"; -import errorMessages from "@/constants/error-messages"; +import { errorMessages } from "@/constants/error-messages"; import { damageLocationsParts } from "@/constants/damage-locations-parts.js"; import { damageLocationsCms } from "@/constants/damage-locations-cms.js"; @@ -169,12 +159,12 @@ export default { this.$route ); }, - onSubmit(values) { - // window.alert('Success! Submitted values: ' + JSON.stringify(values, null ,2)) - // TODO - ADD IN SAVING OF DATA - // TODO - ADD IN ADVANCING TO NEXT PAGE - console.log('submitted: ', JSON.stringify(values, null, 2)); - }, + // onSubmit(values) { + // // window.alert('Success! Submitted values: ' + JSON.stringify(values, null ,2)) + // // TODO - ADD IN SAVING OF DATA + // // TODO - ADD IN ADVANCING TO NEXT PAGE + // console.log('submitted: ', JSON.stringify(values, null, 2)); + // }, onInvalidSubmit({ values, errors, results }) { // identify the first error field and put focus on it // get error names array @@ -260,7 +250,7 @@ export default { return selectedGlassToReplace; }, }, - computed:{ + computed: { isWindshieldDamageLocation() { return this.selectedDamageLocations.some(selectedDamages => { @@ -282,7 +272,7 @@ export default { isWindshieldRepair() { if (!this.isWindshieldDamageLocation) return false; - return this.selectedWindshieldOptions.selectedWindshieldDamageType.some(selectedDamageType => + return this.selectedWindshieldOptions.selectedWindshieldDamageType && this.selectedWindshieldOptions.selectedWindshieldDamageType.some(selectedDamageType => { return selectedDamageType.toUpperCase() === "REPAIR"; }); @@ -302,7 +292,10 @@ export default { { return selectedPassengerSide.toUpperCase() === damageLocationsCms.PASSENGERSIDE; }); - } + }, + hasRepairReplaceConflict() { + return this.isWindshieldDamageLocation && this.selectedDamageLocations.length > 1 && this.isWindshieldRepair; + }, }, components: { diff --git a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue index c381d4995..216ba623e 100644 --- a/src/layouts/vehicle-damage/windshield-options/windshield-options.vue +++ b/src/layouts/vehicle-damage/windshield-options/windshield-options.vue @@ -2,13 +2,13 @@