CSR-297 WIP persist page selections
This commit is contained in:
parent
e4a045349a
commit
895bc5c43e
4 changed files with 67 additions and 5 deletions
7
src/constants/damage-locations-selected.js
Normal file
7
src/constants/damage-locations-selected.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const damageLocationsSelected = {
|
||||
WINDSHIELD: "Windshield",
|
||||
SIDEDOOR: "SideDoor",
|
||||
REARWINDOW: "RearWindow",
|
||||
};
|
||||
|
||||
export { damageLocationsSelected };
|
||||
|
|
@ -51,7 +51,7 @@ export default {
|
|||
);
|
||||
},
|
||||
arePagePrerequisitesValid() {
|
||||
return store.getters.lineItems.glassParts !== null;
|
||||
return true;
|
||||
},
|
||||
resetDependentState() {
|
||||
// Set
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import store from "@/store";
|
|||
import baseMixin from "@/mixins/base-mixin";
|
||||
import { damageLocationsParts } from "@/constants/damage-locations-parts.js";
|
||||
import { damageLocationsCms } from "@/constants/damage-locations-cms.js";
|
||||
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
|
||||
|
||||
|
||||
export default {
|
||||
|
|
@ -106,13 +107,13 @@ export default {
|
|||
},
|
||||
data(){
|
||||
return {
|
||||
selectedDamageLocations: [],
|
||||
selectedDamageLocations: this.getDamageLocations(),
|
||||
sideDoorOptionsData: {
|
||||
selectedDoorSides: [],
|
||||
selectedDriverSideReplaceOptions: [],
|
||||
selectedPassengerSideReplaceOptions: []
|
||||
},
|
||||
selectedWindshieldOptions: [],
|
||||
selectedWindshieldOptions: this.getWindshieldOptions(),
|
||||
selectedRearReplaceOptions: [],
|
||||
}
|
||||
},
|
||||
|
|
@ -131,6 +132,60 @@ export default {
|
|||
);
|
||||
},
|
||||
|
||||
getDamageLocations() {
|
||||
var glassSelections = [];
|
||||
if (store.getters.damage.glassToReplace.some(glass => { return glass.location === damageLocationsParts.WINDSHIELD }) ||
|
||||
store.getters.damage.isRepair) {
|
||||
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
||||
}
|
||||
if (store.getters.damage.glassToReplace.some(glass => { return glass.location === damageLocationsParts.DRIVER })) {
|
||||
glassSelections.push(damageLocationsSelected.SIDEDOOR);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace.some(glass => { return glass.location === damageLocationsParts.PASSENGER })) {
|
||||
glassSelections.push(damageLocationsSelected.SIDEDOOR);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace.some(glass => { return glass.location === damageLocationsParts.REAR })) {
|
||||
glassSelections.push(damageLocationsSelected.REARWINDOW);
|
||||
}
|
||||
|
||||
return glassSelections;
|
||||
},
|
||||
|
||||
getWindshieldOptions() {
|
||||
var windShieldOptions = { selectedWindshieldDamageType: [], selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: []};
|
||||
|
||||
if (store.getters.damage.isRepair === undefined) return windshieldOptions;
|
||||
|
||||
if (!store.getters.damage.isRepair) {
|
||||
if (store.getters.damage.glassToReplace.some(glass => { return glass.location === damageLocationsParts.WINDSHIELD &&
|
||||
glass.name === "Single" })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push("Replace");
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push("Single");
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace.some(glass => { return glass.location === damageLocationsParts.WINDSHIELD &&
|
||||
glass.name === "Driver" })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push("Replace");
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push("Driver");
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace.some(glass => { return glass.location === damageLocationsParts.WINDSHIELD &&
|
||||
glass.name === "Passenger" })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push("Replace");
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push("Passenger");
|
||||
}
|
||||
}
|
||||
|
||||
if (store.getters.damage.isRepair) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push("Repair");
|
||||
windShieldOptions.selectedWindshieldChipCount.push(store.getters.damage.numberOfChips);
|
||||
}
|
||||
|
||||
return windShieldOptions;
|
||||
},
|
||||
|
||||
async forwardButtonAction() {
|
||||
const windshieldChipCount = this.selectedWindshieldOptions.selectedWindshieldChipCount && this.isWindshieldDamageLocation ?
|
||||
this.selectedWindshieldOptions.selectedWindshieldChipCount[0] : null;
|
||||
|
|
@ -171,7 +226,7 @@ export default {
|
|||
store.commit(this.storeMutations.UPDATE_PARTS, partsData.data.partsOrQuestions[0].parts);
|
||||
}
|
||||
|
||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_DAMAGE_WITH_SINGLE_PART, this.$route);
|
||||
this.$router.navigate(this.navigationScenarios.SELECTED_DAMAGE_WITH_SINGLE_PART, this.$route);
|
||||
},
|
||||
|
||||
selectedGlassToReplace() {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export default ({
|
|||
},
|
||||
selectedWindshieldChipCountValues: {
|
||||
get: function() {
|
||||
return this.selectedValues.selectedChipCount;
|
||||
return this.selectedValues.selectedWindshieldChipCount;
|
||||
},
|
||||
set: function(newValue) {
|
||||
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, newValue, null);
|
||||
|
|
|
|||
Loading…
Reference in a new issue