unmatched vehicle and validation
unmatched vehicle and validation
This commit is contained in:
parent
a462d768c0
commit
27fc4162b4
3 changed files with 29 additions and 40 deletions
|
|
@ -26,7 +26,7 @@
|
||||||
{{ value }}
|
{{ value }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<div v-show="errorMessage" class="row mt-2 form-test-error">
|
<div v-show="errorMessage && this.disableValidation" class="row mt-2 form-test-error">
|
||||||
<span aria-atomic="true" aria-live="polite">{{ errorMessage }}</span>
|
<span aria-atomic="true" aria-live="polite">{{ errorMessage }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -56,6 +56,11 @@ export default {
|
||||||
required: false,
|
required: false,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
disableValidationIfElementDisabled: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const uuid = uuidv4();
|
const uuid = uuidv4();
|
||||||
|
|
@ -110,6 +115,9 @@ export default {
|
||||||
this.$emit("update:modelValue", newValue);
|
this.$emit("update:modelValue", newValue);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
disableValidation() {
|
||||||
|
return this.disableValidationIfElementDisabled ? !this.isDisabled : true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selectedOption(newValue) {
|
selectedOption(newValue) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<dropdownQuestion disableAutoFill v-model="selectedValue" :valueAsKey="true" />
|
<dropdownQuestion
|
||||||
|
disableAutoFill
|
||||||
|
v-model="selectedValue"
|
||||||
|
:valueAsKey="true"
|
||||||
|
:disableValidationIfElementDisabled="true" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
:isDisabled="!makeOptions.length"
|
:isDisabled="!makeOptions.length"
|
||||||
:options="makeOptions"
|
:options="makeOptions"
|
||||||
cmsWidgetName="VehicleMakeQuestion"
|
cmsWidgetName="VehicleMakeQuestion"
|
||||||
v-validate="{ rules: 'required', disabled: !makeOptions.length }"
|
|
||||||
validationRules="make-required"
|
validationRules="make-required"
|
||||||
placeHolderText="Select make"
|
placeHolderText="Select make"
|
||||||
inputId="makeQuestionField" />
|
inputId="makeQuestionField" />
|
||||||
|
|
@ -41,7 +40,6 @@
|
||||||
cmsWidgetName="VehicleModelQuestion"
|
cmsWidgetName="VehicleModelQuestion"
|
||||||
:isDisabled="!modelOptions.length"
|
:isDisabled="!modelOptions.length"
|
||||||
:options="modelOptions"
|
:options="modelOptions"
|
||||||
v-validate="{ rules: 'required', disabled: !modelOptions.length }"
|
|
||||||
validationRules="model-required"
|
validationRules="model-required"
|
||||||
placeHolderText="Select model"
|
placeHolderText="Select model"
|
||||||
inputId="modelQuestionField" />
|
inputId="modelQuestionField" />
|
||||||
|
|
@ -53,7 +51,6 @@
|
||||||
cmsWidgetName="VehicleStyleQuestion"
|
cmsWidgetName="VehicleStyleQuestion"
|
||||||
:isDisabled="!styleOptions.length"
|
:isDisabled="!styleOptions.length"
|
||||||
:options="styleOptions"
|
:options="styleOptions"
|
||||||
v-validate="{ rules: 'required', disabled: !styleOptions.length }"
|
|
||||||
validationRules="style-required"
|
validationRules="style-required"
|
||||||
placeHolderText="Select style"
|
placeHolderText="Select style"
|
||||||
inputId="styleQuestionField" />
|
inputId="styleQuestionField" />
|
||||||
|
|
@ -102,34 +99,10 @@ import { storeActions } from "@/constants/store-actions.js";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
|
||||||
//define validation rules
|
//define validation rules
|
||||||
defineRule("year-required", (value) => {
|
defineRule("year-required", required(errorMessages.YEAR_REQUIRED));
|
||||||
if (!value || !value.length ) {
|
defineRule("make-required", required(errorMessages.MAKE_REQUIRED));
|
||||||
return errorMessages.YEAR_REQUIRED;
|
defineRule("model-required", required(errorMessages.MODEL_REQUIRED));
|
||||||
}
|
defineRule("style-required", required(errorMessages.STYLE_REQUIRED));
|
||||||
return true;
|
|
||||||
});
|
|
||||||
defineRule("make-required", (value) => {
|
|
||||||
if (!value || !value.length) {
|
|
||||||
return errorMessages.MAKE_REQUIRED;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
defineRule("model-required", (value) => {
|
|
||||||
if (!value || !value.length) {
|
|
||||||
return errorMessages.MODEL_REQUIRED;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
defineRule("style-required", (value) => {
|
|
||||||
if (!value || !value.length) {
|
|
||||||
return errorMessages.STYLE_REQUIRED;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
// defineRule("year-required", required(errorMessages.YEAR_REQUIRED));
|
|
||||||
// defineRule("make-required", required(errorMessages.MAKE_REQUIRED));
|
|
||||||
// defineRule("model-required", required(errorMessages.MODEL_REQUIRED));
|
|
||||||
// defineRule("style-required", required(errorMessages.STYLE_REQUIRED));
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "vehicle",
|
name: "vehicle",
|
||||||
|
|
@ -141,7 +114,7 @@ export default {
|
||||||
selectedStyle: this.selectedStylefromStore(),
|
selectedStyle: this.selectedStylefromStore(),
|
||||||
carId: null,
|
carId: null,
|
||||||
category: null,
|
category: null,
|
||||||
imageUrl: null,
|
imageUrl: this.getImagefromStore(),
|
||||||
imageVifNumber: null,
|
imageVifNumber: null,
|
||||||
imageVifColor: null,
|
imageVifColor: null,
|
||||||
yearOptions: [],
|
yearOptions: [],
|
||||||
|
|
@ -149,7 +122,6 @@ export default {
|
||||||
modelOptions: [],
|
modelOptions: [],
|
||||||
styleOptions: [],
|
styleOptions: [],
|
||||||
displayGeneric: this.displayGenericFromStore(),
|
displayGeneric: this.displayGenericFromStore(),
|
||||||
unmatchedVehicleIcon: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -319,17 +291,19 @@ export default {
|
||||||
this.imageUrl = result?.data.imageUrl;
|
this.imageUrl = result?.data.imageUrl;
|
||||||
this.imageVifNumber = result?.data.imageVifNumber;
|
this.imageVifNumber = result?.data.imageVifNumber;
|
||||||
this.imageVifColor = result?.data.imageVifColor;
|
this.imageVifColor = result?.data.imageVifColor;
|
||||||
if (this.imageUrl == null) {
|
if (this.imageUrl == null) this.displayGeneric = false;
|
||||||
this.displayGeneric = false;
|
|
||||||
this.unmatchedVehicleIcon = true;
|
|
||||||
} else this.unmatchedVehicleIcon = false;
|
|
||||||
} else {
|
} else {
|
||||||
this.imageUrl = null;
|
this.imageUrl = null;
|
||||||
this.displayGeneric = true;
|
this.displayGeneric = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
unmatchedVehicleIcon() {
|
||||||
|
if (this.imageUrl == null) return true;
|
||||||
|
else return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getVehicle(year, make, model, style) {
|
getVehicle(year, make, model, style) {
|
||||||
return this.dispatchStoreAction(this.storeActions.GET_VEHICLE, {
|
return this.dispatchStoreAction(this.storeActions.GET_VEHICLE, {
|
||||||
|
|
@ -410,6 +384,9 @@ export default {
|
||||||
model: model,
|
model: model,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getImagefromStore() {
|
||||||
|
return store.getters.vehicle.imageUrl;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue