Code format.
This commit is contained in:
parent
30396f2b71
commit
00539a6ac6
1 changed files with 103 additions and 159 deletions
|
|
@ -143,7 +143,7 @@ export default {
|
||||||
replaceOptionsQuestion,
|
replaceOptionsQuestion,
|
||||||
// eslint-disable-next-line vue/no-reserved-component-names
|
// eslint-disable-next-line vue/no-reserved-component-names
|
||||||
Form,
|
Form,
|
||||||
alert,
|
alert
|
||||||
},
|
},
|
||||||
mixins: [BaseFormMixin, vehicleQuestionsMixin],
|
mixins: [BaseFormMixin, vehicleQuestionsMixin],
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
|
|
@ -151,20 +151,18 @@ export default {
|
||||||
|
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
||||||
const damageOptionsPromise = store.getDamageOptions(
|
const damageOptionsPromise = store.getDamageOptions(store.order.vehicle.carId);
|
||||||
store.order.vehicle.carId
|
|
||||||
);
|
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: 'cmsContent',
|
resultKey: 'cmsContent',
|
||||||
promise: cmsContentPromise,
|
promise: cmsContentPromise
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
resultKey: 'damageOptions',
|
resultKey: 'damageOptions',
|
||||||
promise: damageOptionsPromise,
|
promise: damageOptionsPromise
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
@ -172,23 +170,17 @@ export default {
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.$refs.damageLocation.initializeComponent(
|
vm.$refs.damageLocation.initializeComponent(resultMap.damageOptions);
|
||||||
resultMap.damageOptions
|
|
||||||
);
|
|
||||||
vm.$refs.sideDoorOptions.initializeComponent(
|
vm.$refs.sideDoorOptions.initializeComponent(
|
||||||
resultMap.damageOptions.driverSideOptions
|
resultMap.damageOptions.driverSideOptions
|
||||||
.availableReplacementOptions,
|
.availableReplacementOptions,
|
||||||
resultMap.damageOptions.passengerSideOptions
|
resultMap.damageOptions.passengerSideOptions
|
||||||
.availableReplacementOptions
|
.availableReplacementOptions
|
||||||
);
|
);
|
||||||
vm.$refs.windshieldOptions.initializeComponent(
|
vm.$refs.windshieldOptions.initializeComponent(resultMap.damageOptions.windshieldOptions
|
||||||
resultMap.damageOptions.windshieldOptions
|
.availableReplacementOptions);
|
||||||
.availableReplacementOptions
|
vm.$refs.backGlassOptions.initializeComponent(resultMap.damageOptions.backGlassOptions
|
||||||
);
|
.availableReplacementOptions);
|
||||||
vm.$refs.backGlassOptions.initializeComponent(
|
|
||||||
resultMap.damageOptions.backGlassOptions
|
|
||||||
.availableReplacementOptions
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|
@ -204,7 +196,7 @@ export default {
|
||||||
selectedDriverSideReplaceOptions:
|
selectedDriverSideReplaceOptions:
|
||||||
this.getDriverSideReplaceOptionsFromStore(),
|
this.getDriverSideReplaceOptionsFromStore(),
|
||||||
selectedPassengerSideReplaceOptions:
|
selectedPassengerSideReplaceOptions:
|
||||||
this.getPassengerSideReplaceOptionsFromStore(),
|
this.getPassengerSideReplaceOptionsFromStore()
|
||||||
},
|
},
|
||||||
selectedWindshieldOptions: this.getWindshieldOptionsFromStore(),
|
selectedWindshieldOptions: this.getWindshieldOptionsFromStore(),
|
||||||
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(),
|
selectedRearReplaceOptions: this.getRearReplaceOptionsFromStore(),
|
||||||
|
|
@ -213,83 +205,66 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isWindshieldDamageLocation() {
|
isWindshieldDamageLocation() {
|
||||||
return this.selectedDamageLocations.some(
|
return this.selectedDamageLocations.some((selectedDamages) =>
|
||||||
(selectedDamages) =>
|
selectedDamages.toUpperCase()
|
||||||
selectedDamages.toUpperCase() ===
|
=== damageLocationsCms.WINDSHIELD);
|
||||||
damageLocationsCms.WINDSHIELD
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
isSideDoorDamageLocation() {
|
isSideDoorDamageLocation() {
|
||||||
return this.selectedDamageLocations.some(
|
return this.selectedDamageLocations.some((selectedDamages) =>
|
||||||
(selectedDamages) =>
|
selectedDamages.toUpperCase()
|
||||||
selectedDamages.toUpperCase() ===
|
=== damageLocationsCms.SIDEDOOR);
|
||||||
damageLocationsCms.SIDEDOOR
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
isRearWindowDamageLocation() {
|
isRearWindowDamageLocation() {
|
||||||
return this.selectedDamageLocations.some(
|
return this.selectedDamageLocations.some((selectedDamages) =>
|
||||||
(selectedDamages) =>
|
selectedDamages.toUpperCase()
|
||||||
selectedDamages.toUpperCase() ===
|
=== damageLocationsCms.REARWINDOW);
|
||||||
damageLocationsCms.REARWINDOW
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
isWindshieldRepair() {
|
isWindshieldRepair() {
|
||||||
return (
|
return (
|
||||||
this.isWindshieldDamageLocation &&
|
this.isWindshieldDamageLocation
|
||||||
this.selectedWindshieldOptions.selectedWindshieldDamageType ===
|
&& this.selectedWindshieldOptions.selectedWindshieldDamageType
|
||||||
damageLocationsSelected.REPAIR
|
=== damageLocationsSelected.REPAIR
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
isDriverSideReplace() {
|
isDriverSideReplace() {
|
||||||
if (!this.isSideDoorDamageLocation) return false;
|
if (!this.isSideDoorDamageLocation) return false;
|
||||||
|
|
||||||
return this.sideDoorOptionsData.selectedDoorSides.some(
|
return this.sideDoorOptionsData.selectedDoorSides.some((selectedDriverSide) =>
|
||||||
(selectedDriverSide) =>
|
selectedDriverSide.toUpperCase()
|
||||||
selectedDriverSide.toUpperCase() ===
|
=== damageLocationsCms.DRIVERSIDE);
|
||||||
damageLocationsCms.DRIVERSIDE
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
isPassengerSideReplace() {
|
isPassengerSideReplace() {
|
||||||
if (!this.isSideDoorDamageLocation) return false;
|
if (!this.isSideDoorDamageLocation) return false;
|
||||||
|
|
||||||
return this.sideDoorOptionsData.selectedDoorSides.some(
|
return this.sideDoorOptionsData.selectedDoorSides.some((selectedPassengerSide) =>
|
||||||
(selectedPassengerSide) =>
|
selectedPassengerSide.toUpperCase()
|
||||||
selectedPassengerSide.toUpperCase() ===
|
=== damageLocationsCms.PASSENGERSIDE);
|
||||||
damageLocationsCms.PASSENGERSIDE
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
hasRepairReplaceConflict() {
|
hasRepairReplaceConflict() {
|
||||||
return (
|
return (
|
||||||
this.isWindshieldDamageLocation &&
|
this.isWindshieldDamageLocation
|
||||||
this.selectedDamageLocations.length > 1 &&
|
&& this.selectedDamageLocations.length > 1
|
||||||
this.isWindshieldRepair
|
&& this.isWindshieldRepair
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
hasSplitSingleConflict() {
|
hasSplitSingleConflict() {
|
||||||
if (
|
if (
|
||||||
!this.selectedDamageLocations?.includes('Windshield') ||
|
!this.selectedDamageLocations?.includes('Windshield')
|
||||||
this.selectedWindshieldOptions.selectedWindshieldDamageType ===
|
|| this.selectedWindshieldOptions.selectedWindshieldDamageType
|
||||||
damageLocationsSelected.REPAIR ||
|
=== damageLocationsSelected.REPAIR
|
||||||
!this.selectedWindshieldOptions.selectedWindshieldReplaceOptions
|
|| !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions
|
||||||
)
|
) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(
|
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some((selectedSingleWindshield) =>
|
||||||
(selectedSingleWindshield) =>
|
selectedSingleWindshield.toUpperCase()
|
||||||
selectedSingleWindshield.toUpperCase() ===
|
=== damageLocationsSelected.SINGLE.toUpperCase())
|
||||||
damageLocationsSelected.SINGLE.toUpperCase()
|
&& (this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some((selectedDriverWindshield) =>
|
||||||
) &&
|
selectedDriverWindshield.toUpperCase()
|
||||||
(this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(
|
=== damageLocationsSelected.DRIVER.toUpperCase())
|
||||||
(selectedDriverWindshield) =>
|
|| this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some((selectedPassengerWindshield) =>
|
||||||
selectedDriverWindshield.toUpperCase() ===
|
selectedPassengerWindshield.toUpperCase()
|
||||||
damageLocationsSelected.DRIVER.toUpperCase()
|
=== damageLocationsSelected.PASSENGER.toUpperCase()))
|
||||||
) ||
|
|
||||||
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions?.some(
|
|
||||||
(selectedPassengerWindshield) =>
|
|
||||||
selectedPassengerWindshield.toUpperCase() ===
|
|
||||||
damageLocationsSelected.PASSENGER.toUpperCase()
|
|
||||||
))
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
shouldDisplayVehicleChangeAlert() {
|
shouldDisplayVehicleChangeAlert() {
|
||||||
|
|
@ -309,32 +284,26 @@ export default {
|
||||||
const glassSelections = [];
|
const glassSelections = [];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation
|
||||||
glass.glassLocation ===
|
=== damageLocationsSelected.WINDSHIELD)
|
||||||
damageLocationsSelected.WINDSHIELD
|
|| this.mainStore.order.damage.isRepair
|
||||||
) ||
|
|
||||||
this.mainStore.order.damage.isRepair
|
|
||||||
) {
|
) {
|
||||||
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation
|
||||||
glass.glassLocation ===
|
=== damageLocationsSelected.DRIVER
|
||||||
damageLocationsSelected.DRIVER ||
|
|| glass.glassLocation
|
||||||
glass.glassLocation ===
|
=== damageLocationsSelected.PASSENGER)
|
||||||
damageLocationsSelected.PASSENGER
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
glassSelections.push(damageLocationsSelected.SIDEDOOR);
|
glassSelections.push(damageLocationsSelected.SIDEDOOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation === damageLocationsSelected.REAR)
|
||||||
glass.glassLocation === damageLocationsSelected.REAR
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
glassSelections.push(damageLocationsSelected.REARWINDOW);
|
glassSelections.push(damageLocationsSelected.REARWINDOW);
|
||||||
}
|
}
|
||||||
|
|
@ -345,11 +314,10 @@ export default {
|
||||||
const windShieldOptions = {
|
const windShieldOptions = {
|
||||||
selectedWindshieldDamageType: '',
|
selectedWindshieldDamageType: '',
|
||||||
selectedWindshieldChipCount: null,
|
selectedWindshieldChipCount: null,
|
||||||
selectedWindshieldReplaceOptions: [],
|
selectedWindshieldReplaceOptions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.mainStore.order.damage.isRepair === undefined)
|
if (this.mainStore.order.damage.isRepair === undefined) return windshieldOptions;
|
||||||
return windshieldOptions;
|
|
||||||
|
|
||||||
if (this.mainStore.order.damage.isRepair) {
|
if (this.mainStore.order.damage.isRepair) {
|
||||||
windShieldOptions.selectedWindshieldDamageType =
|
windShieldOptions.selectedWindshieldDamageType =
|
||||||
|
|
@ -358,49 +326,37 @@ export default {
|
||||||
this.mainStore.order.damage.numberOfChips;
|
this.mainStore.order.damage.numberOfChips;
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation
|
||||||
glass.glassLocation ===
|
=== damageLocationsSelected.WINDSHIELD
|
||||||
damageLocationsSelected.WINDSHIELD &&
|
&& glass.glassName === damageLocationsSelected.SINGLE)
|
||||||
glass.glassName === damageLocationsSelected.SINGLE
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
windShieldOptions.selectedWindshieldDamageType =
|
windShieldOptions.selectedWindshieldDamageType =
|
||||||
damageLocationsSelected.REPLACE;
|
damageLocationsSelected.REPLACE;
|
||||||
windShieldOptions.selectedWindshieldReplaceOptions.push(
|
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE);
|
||||||
damageLocationsSelected.SINGLE
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation
|
||||||
glass.glassLocation ===
|
=== damageLocationsSelected.WINDSHIELD
|
||||||
damageLocationsSelected.WINDSHIELD &&
|
&& glass.glassName === damageLocationsSelected.DRIVER)
|
||||||
glass.glassName === damageLocationsSelected.DRIVER
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
windShieldOptions.selectedWindshieldDamageType =
|
windShieldOptions.selectedWindshieldDamageType =
|
||||||
damageLocationsSelected.REPLACE;
|
damageLocationsSelected.REPLACE;
|
||||||
windShieldOptions.selectedWindshieldReplaceOptions.push(
|
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER);
|
||||||
damageLocationsSelected.DRIVER
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation
|
||||||
glass.glassLocation ===
|
=== damageLocationsSelected.WINDSHIELD
|
||||||
damageLocationsSelected.WINDSHIELD &&
|
&& glass.glassName
|
||||||
glass.glassName ===
|
=== damageLocationsSelected.PASSENGER)
|
||||||
damageLocationsSelected.PASSENGER
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
windShieldOptions.selectedWindshieldDamageType =
|
windShieldOptions.selectedWindshieldDamageType =
|
||||||
damageLocationsSelected.REPLACE;
|
damageLocationsSelected.REPLACE;
|
||||||
windShieldOptions.selectedWindshieldReplaceOptions.push(
|
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER);
|
||||||
damageLocationsSelected.PASSENGER
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -409,20 +365,16 @@ export default {
|
||||||
getDoorSidesFromStore() {
|
getDoorSidesFromStore() {
|
||||||
const doorSides = [];
|
const doorSides = [];
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation === damageLocationsSelected.DRIVER)
|
||||||
glass.glassLocation === damageLocationsSelected.DRIVER
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
doorSides.push(damageLocationsSelected.DRIVERSIDE);
|
doorSides.push(damageLocationsSelected.DRIVERSIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.mainStore.order.damage.glassToReplace?.some(
|
this.mainStore.order.damage.glassToReplace?.some((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation
|
||||||
glass.glassLocation ===
|
=== damageLocationsSelected.PASSENGER)
|
||||||
damageLocationsSelected.PASSENGER
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
doorSides.push(damageLocationsSelected.PASSENGERSIDE);
|
doorSides.push(damageLocationsSelected.PASSENGERSIDE);
|
||||||
}
|
}
|
||||||
|
|
@ -453,10 +405,8 @@ export default {
|
||||||
},
|
},
|
||||||
getRearReplaceOptionsFromStore() {
|
getRearReplaceOptionsFromStore() {
|
||||||
const rearReplaceOptions =
|
const rearReplaceOptions =
|
||||||
this.mainStore.order.damage.glassToReplace?.filter(
|
this.mainStore.order.damage.glassToReplace?.filter((glass) =>
|
||||||
(glass) =>
|
glass.glassLocation === damageLocationsSelected.REAR)[0]?.glassName;
|
||||||
glass.glassLocation === damageLocationsSelected.REAR
|
|
||||||
)[0]?.glassName;
|
|
||||||
|
|
||||||
return rearReplaceOptions;
|
return rearReplaceOptions;
|
||||||
},
|
},
|
||||||
|
|
@ -512,48 +462,42 @@ export default {
|
||||||
selectedGlassToReplace() {
|
selectedGlassToReplace() {
|
||||||
const selectedGlassToReplace = [];
|
const selectedGlassToReplace = [];
|
||||||
if (this.isWindshieldDamageLocation && !this.isWindshieldRepair) {
|
if (this.isWindshieldDamageLocation && !this.isWindshieldRepair) {
|
||||||
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach(
|
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach((wsItem) => {
|
||||||
(wsItem) => {
|
selectedGlassToReplace.push({
|
||||||
selectedGlassToReplace.push({
|
glassLocation: damageLocationsSelected.WINDSHIELD,
|
||||||
glassLocation: damageLocationsSelected.WINDSHIELD,
|
glassName: wsItem
|
||||||
glassName: wsItem,
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isDriverSideReplace) {
|
if (this.isDriverSideReplace) {
|
||||||
this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach(
|
this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach((driverItem) => {
|
||||||
(driverItem) => {
|
selectedGlassToReplace.push({
|
||||||
selectedGlassToReplace.push({
|
glassLocation: damageLocationsSelected.DRIVER,
|
||||||
glassLocation: damageLocationsSelected.DRIVER,
|
glassName: driverItem
|
||||||
glassName: driverItem,
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isPassengerSideReplace) {
|
if (this.isPassengerSideReplace) {
|
||||||
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach(
|
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach((passengerItem) => {
|
||||||
(passengerItem) => {
|
selectedGlassToReplace.push({
|
||||||
selectedGlassToReplace.push({
|
glassLocation: damageLocationsSelected.PASSENGER,
|
||||||
glassLocation: damageLocationsSelected.PASSENGER,
|
glassName: passengerItem
|
||||||
glassName: passengerItem,
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isRearWindowDamageLocation) {
|
if (this.isRearWindowDamageLocation) {
|
||||||
selectedGlassToReplace.push({
|
selectedGlassToReplace.push({
|
||||||
glassLocation: damageLocationsSelected.REAR,
|
glassLocation: damageLocationsSelected.REAR,
|
||||||
glassName: this.selectedRearReplaceOptions,
|
glassName: this.selectedRearReplaceOptions
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedGlassToReplace;
|
return selectedGlassToReplace;
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue