diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 0ac79ac28..dcf8cc581 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -31,6 +31,10 @@ const storeActions = { RESET_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies", RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies", RESET_STATE: "resetState", + + //RESET STATE + RESET_SAVE_VEHICLE_YEAR: "saveVehicleYear", + RESET_SAVE_VEHICLE_MAKE :"saveVehicleMake" }; export { storeActions }; diff --git a/src/layouts/vehicle-make/vehicle-make.vue b/src/layouts/vehicle-make/vehicle-make.vue index aecd90a6f..286560b98 100644 --- a/src/layouts/vehicle-make/vehicle-make.vue +++ b/src/layouts/vehicle-make/vehicle-make.vue @@ -82,7 +82,10 @@ export default { } return false; }, - resetDependentState() { + resetDependentState: function(){ + store.dispatch(storeActions.RESET_SAVE_VEHICLE_MAKE); + } + /* resetDependentState() { // Set store.commit(storeMutations.UPDATE_MODEL, null); store.commit(storeMutations.UPDATE_STYLE, null); @@ -96,7 +99,7 @@ export default { // Invokes store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - }, + }, */ }, watch: { diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue index 1041f82ae..18c1822d0 100644 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ b/src/layouts/vehicle-year/vehicle-year.vue @@ -100,7 +100,10 @@ export default { arePagePrerequisitesValid() { return true; }, - resetDependentState() { + resetDependentState: function(){ + store.dispatch(storeActions.RESET_SAVE_VEHICLE_YEAR); + } + /* resetDependentState() { // Set store.commit(storeMutations.UPDATE_MAKE, null); store.commit(storeMutations.UPDATE_MODEL, null); @@ -115,7 +118,7 @@ export default { // Invokes store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); store.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - }, + }, */ }, components: { yearQuestion, diff --git a/src/store/index.js b/src/store/index.js index dda0fab35..a1a0b00da 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -69,6 +69,9 @@ const getDefaultState = () => { export const state = getDefaultState(); +const oldState = state; +const newState = state; + // Export Mutations export const mutations = { // VEHICLE MUTATIONS @@ -615,7 +618,41 @@ export const actions = { context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data); return response; }); - } + }, + + saveVehicleYear(){ + //NEED TO COMPARE OLDVALUE TO NEW VALUE + console.log(state.order.vehicle.year); + if(state.order.vehicle.year!=null){ + storeMutations.updateMake = null; + storeMutations.updateModel = null; + storeMutations.updateStyle = null; + storeMutations.updateCarId = null; + storeMutations.updateVehicleCategory = null; + storeMutations.updateVehicleVin = null; + storeMutations.updateVehicleImageUrl = null; + storeMutations.updateVehicleImageVifNumber = null; + storeMutations.updateVehicleImageColor = null; + storeMutations.resetDamageAndDependencies; + storeMutations.resetRegistrationAndDependencies; + console.log("save vehicle year!"); + } + }, + saveVehicleMake(){ + if(state.order.vehicle.year!=null && state.order.vehicle.make!=null){ + storeMutations.updateModel = null; + storeMutations.updateStyle = null; + storeMutations.updateCarId = null; + storeMutations.updateVehicleCategory = null; + storeMutations.updateVehicleVin = null; + storeMutations.updateVehicleImageUrl = null; + storeMutations.updateVehicleImageVifNumber = null; + storeMutations.updateVehicleImageColor = null; + storeMutations.resetDamageAndDependencies; + storeMutations.resetRegistrationAndDependencies; + console.log("save vehicle make!"); + } + }, } export default createStore({ @@ -631,4 +668,87 @@ export default createStore({ actions, }); +/* export const mutationActions ={ + saveVehicleMake(){ + storeMutations.updateModel = null; + storeMutations.updateStyle = null; + storeMutations.updateCarId = null; + storeMutations.updateVehicleCategory = null; + storeMutations.updateVehicleVin = null; + storeMutations.updateVehicleImageUrl = null; + storeMutations.updateVehicleImageVifNumber = null; + storeMutations.updateVehicleImageColor = null; + storeMutations.resetDamageAndDependencies; + storeMutations.resetRegistrationAndDependencies; + }, + saveVehicleModel(){ + storeMutations.updateStyle = null; + storeMutations.updateCarId = null; + storeMutations.updateVehicleCategory = null; + storeMutations.updateVehicleVin = null; + storeMutations.updateVehicleImageUrl = null; + storeMutations.updateVehicleImageVifNumber = null; + storeMutations.updateVehicleImageColor = null; + storeMutations.resetDamageAndDependencies; + storeMutations.resetRegistrationAndDependencies; + }, + saveVehicleStyle(){ + storeMutations.updateCarId = null; + storeMutations.updateVehicleCategory = null; + storeMutations.updateVehicleVin = null; + storeMutations.updateVehicleImageUrl = null; + storeMutations.updateVehicleImageVifNumber = null; + storeMutations.updateVehicleImageColor = null; + storeMutations.resetDamageAndDependencies; + storeMutations.resetRegistrationAndDependencies; + }, + saveVehicleDamage(){ + storeMutations.resetPartsAndDependencies; + }, + saveVinLookup(carId){ + if(state.carId!=carId && state.payload.glass==false){ + storeMutations.resetDamageAndDependencies; + } + storeMutations.resetRegistrationAndDependencies; + }, + saveServiceLocation(){ + + }, + saveEmail(){ + + }, + saveRegistrationLicensePlateLookup(carId){ + if(state.carId!=carId && state.payload.glass==false){ + storeMutations.resetDamageAndDependencies; + } + storeMutations.registrationAddress = null; + storeMutations.registrationCity = null; + storeMutations.registration.firstName = null; + storeMutations.registration.lastName = null; + }, + saveVin(carId){ + if(state.carId!=carId && state.payload.glass==false){ + storeMutations.resetDamageAndDependencies; + } + }, + saveRegistrationAddressLookup(carId){ + if(state.carId!=carId && state.payload.glass==false){ + storeMutations.resetDamageAndDependencies; + } + storeMutations.registrationAddress = null; + storeMutations.registrationCity = null; + storeMutations.registration.firstName = null; + storeMutations.registration.lastName = null; + }, + savePartQuestionAnswers(){ + + }, + saveGlassParts(){ + + } +} */ + // Private Functions + +//Track state values +const oldValue = state;