updated to clear the entire vehicle object. Additional store items can be added to resetVehicle method as they are added to the store.
This commit is contained in:
parent
b0d91b0224
commit
53160a5119
5 changed files with 45 additions and 5 deletions
|
|
@ -92,7 +92,8 @@
|
|||
selectedMake(make) {
|
||||
if(make != this.mainStore.order.vehicle.make)
|
||||
{
|
||||
this.mainStore.updateVehicle({make, model: null, style: null});
|
||||
const vehicle = this.mainStore.order.vehicle;
|
||||
this.mainStore.updateVehicle( { year: vehicle.year, make }, true );
|
||||
}
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.SELECTED_MAKE,
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@
|
|||
selectedModel(model) {
|
||||
if(model != this.mainStore.order.vehicle.model)
|
||||
{
|
||||
this.mainStore.updateVehicle({model, style: null});
|
||||
const vehicle = this.mainStore.order.vehicle;
|
||||
this.mainStore.updateVehicle( { year: vehicle.year, make: vehicle.make, model }, true );
|
||||
}
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.SELECTED_MODEL,
|
||||
|
|
|
|||
|
|
@ -79,7 +79,16 @@ export default {
|
|||
selectedStyle(style) {
|
||||
if(style != this.mainStore.order.vehicle.style)
|
||||
{
|
||||
this.mainStore.updateVehicle({style});
|
||||
const vehicle = this.mainStore.order.vehicle;
|
||||
this.mainStore.updateVehicle(
|
||||
{
|
||||
year: vehicle.year,
|
||||
make: vehicle.make,
|
||||
model: vehicle.model,
|
||||
style
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
this.mainStore.setVehicle().then(() => {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
const parsedYear = parseInt(year);
|
||||
if(parsedYear != this.mainStore.order.vehicle.year)
|
||||
{
|
||||
this.mainStore.updateVehicle({year: parsedYear, make: null, model: null, style: null});
|
||||
this.mainStore.updateVehicle( { year: parsedYear }, true );
|
||||
}
|
||||
|
||||
this.$router.navigate(
|
||||
|
|
|
|||
|
|
@ -131,10 +131,39 @@ export const useMainStore = defineStore({
|
|||
});
|
||||
},
|
||||
|
||||
updateVehicle(vehicle)
|
||||
updateVehicle(vehicle, reset = false)
|
||||
{
|
||||
if(reset)
|
||||
{
|
||||
this.resetVehicle();
|
||||
}
|
||||
this.order.vehicle = { ...this.order.vehicle, ...vehicle };
|
||||
},
|
||||
|
||||
resetVehicle()
|
||||
{
|
||||
this.order.vehicle = {
|
||||
year: null,
|
||||
make: null,
|
||||
model: null,
|
||||
style: null,
|
||||
carId: null,
|
||||
category: null,
|
||||
vin: null,
|
||||
imageUrl: null,
|
||||
imageVifNumber: null,
|
||||
imageColor: null,
|
||||
registration: {
|
||||
licensePlate: null,
|
||||
address: null,
|
||||
city: null,
|
||||
state: null,
|
||||
zipCode: null,
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
addEventToBus (event) {
|
||||
this.applicationUser.eventBus.push(event);
|
||||
|
|
|
|||
Loading…
Reference in a new issue