CSR-347: refactor per PR comments

This commit is contained in:
Adam Caouette 2022-05-12 14:06:46 -04:00
parent 611b0c0730
commit 016e5c93af
4 changed files with 16 additions and 26 deletions

View file

@ -24,6 +24,7 @@ module.exports = {
"!src/layouts/address-lookup/customer-questions/customer-questions.vue",
"!src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue",
"!src/layouts/address-vehicles/address-vehicles.vue",
"!src/layouts/address-vehicles/address-vehicles-question/address-vehicles-question.vue",
"!src/common-components/dropdown-question/dropdown-question.vue",
"!src/common-components/textbox-question/textbox-question.vue",
"!src/helpers/validation-rules.js",

View file

@ -29,19 +29,12 @@ import { getDamageString } from "@/helpers/damage-helper";
export default {
name: "address-vehicles-question",
data() {
return {
questionText: String,
customAlertData: {},
};
},
props: {
vehicles: Array,
modelValue: String,
cmsWidgetName: String,
validationRules: String,
isCarIdDifferent: Boolean,
selectedVehicle: Object,
},
computed: {
differentVehicleAlertHeader() {
@ -66,18 +59,19 @@ export default {
this.selectedVehicle?.vehicle.model
);
},
selectedVehicleVin: {
get: function() {
return this.modelValue;
},
set: function(newValue) {
this.$emit("update:modelValue", newValue);
}
questionText() {
return this.getCmsContent("VehicleConfirmationQuestion", "QuestionText");
},
},
methods: {
initializeComponent(VehicleConfirmationQuestion) {
this.questionText = VehicleConfirmationQuestion.QuestionText;
selectedVehicleVin: {
get: function() {
return this.modelValue;
},
set: function(newValue) {
this.$emit("update:modelValue", newValue);
}
},
selectedVehicle() {
return this.vehicles.find( ({ vin }) => vin === this.selectedVehicleVin[0] );
},
},
components: {

View file

@ -24,7 +24,6 @@
:vehicles="VehiclesForQuestions"
validationRules="vehicle-required"
v-model="selectedVehicleVin"
:selectedVehicle="selectedVehicle"
:isCarIdDifferent="isCarIdDifferent"
/>
<div class="alert-provide-vin my-5" v-if="splitAlertProvideVinBodyForLink.length">
@ -92,7 +91,6 @@ export default {
// Call the "next" function to complete the transition to this page.
next((vm) => {
vm.setCmsContent(resultMap.cmsContent);
vm.$refs.addressVehiclesQuestion.initializeComponent(resultMap.cmsContent.VehicleConfirmationQuestion);
});
},
props: {
@ -101,7 +99,6 @@ export default {
data() {
return {
selectedVehicleVin: null,
selectedVehicle: {},
isCarIdDifferent: false,
isSelectedGlassAvailableForVehicle: true,
};
@ -122,7 +119,6 @@ export default {
return this.AlertProvideVinBody.split(/{(.*?)}/g);
},
VehiclesForQuestions() {
const vehiclesData = this.VehiclesFromApi;
// Map API result data, to address-vehicles data structure
@ -130,7 +126,6 @@ export default {
const maskSymbol = "X";
const vinStart = maskSymbol.repeat(v.vin.length-4);
const vinEnd = v.vin.substring(v.vin.length-4);
return {
vin: v.vin,
vehicle: v.vehicle,
@ -138,7 +133,6 @@ export default {
Name: v.vin,
SubText: "VIN " + vinStart + vinEnd,
};
});
return mappedData;
@ -146,6 +140,9 @@ export default {
VehiclesFromApi() {
return store.getters.pageData(fmgPageValues.ADDRESS_VEHICLES);
},
selectedVehicle() {
return this.VehiclesForQuestions.find( ({ vin }) => vin === this.selectedVehicleVin[0] );
},
},
methods: {
arePagePrerequisitesValid() {
@ -214,8 +211,6 @@ export default {
watch: {
selectedVehicleVin(vehicleVin) {
const selectedVin = vehicleVin[0];
this.selectedVehicle = this.VehiclesForQuestions.find( ({ vin }) => vin === selectedVin );
// does this vehicle match the previously selected carId?
this.isCarIdDifferent = this.selectedVehicle.vehicle.carId !== store.getters.vehicle.carId;
this.$refs.funnelFooter.updateButtonText(`Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}`);