commit
1906ceeb31
6 changed files with 33 additions and 50 deletions
|
|
@ -133,7 +133,7 @@ describe("vehicle-damage.vue", () => {
|
|||
wrapper.vm.selectedWindshieldOptions = {
|
||||
selectedWindshieldChipCount: null,
|
||||
selectedWindshieldReplaceOptions: ["Single"],
|
||||
selectedWindshieldDamageType: ["Replace"]
|
||||
selectedWindshieldDamageType: "Replace"
|
||||
};
|
||||
|
||||
wrapper.vm.sideDoorOptionsData = {
|
||||
|
|
@ -232,7 +232,7 @@ describe("vehicle-damage.vue", () => {
|
|||
wrapper.vm.selectedWindshieldOptions = {
|
||||
selectedWindshieldChipCount: null,
|
||||
selectedWindshieldReplaceOptions: ["Single"],
|
||||
selectedWindshieldDamageType: ["Replace"]
|
||||
selectedWindshieldDamageType: "Replace"
|
||||
};
|
||||
|
||||
const expectedGlassToReplace = [{ glassLocation: "Windshield", glassName: "Single" },];
|
||||
|
|
@ -375,7 +375,7 @@ describe("vehicle-damage.vue", () => {
|
|||
);
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["Windshield"];
|
||||
wrapper.vm.selectedWindshieldOptions = { selectedWindshieldDamageType: ["Repair"] };
|
||||
wrapper.vm.selectedWindshieldOptions = { selectedWindshieldDamageType: "Repair" };
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isWindshieldRepair).toEqual(true);
|
||||
|
|
@ -395,7 +395,7 @@ describe("vehicle-damage.vue", () => {
|
|||
);
|
||||
|
||||
wrapper.vm.selectedDamageLocations = ["SideDoor"];
|
||||
wrapper.vm.selectedWindshieldOptions = { selectedWindshieldDamageType: ["Repair"] };
|
||||
wrapper.vm.selectedWindshieldOptions = { selectedWindshieldDamageType: "Repair" };
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isWindshieldRepair).toEqual(false);
|
||||
|
|
@ -518,19 +518,19 @@ describe("vehicle-damage.vue", () => {
|
|||
});
|
||||
|
||||
const storeWindshieldOptions = [[1, false, "Windshield", "Single", {
|
||||
selectedWindshieldDamageType: [damageLocationsSelected.REPLACE],
|
||||
selectedWindshieldDamageType: damageLocationsSelected.REPLACE,
|
||||
selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: [damageLocationsSelected.SINGLE]
|
||||
}],
|
||||
[2, false, "Windshield", "Driver", {
|
||||
selectedWindshieldDamageType: [damageLocationsSelected.REPLACE],
|
||||
selectedWindshieldDamageType: damageLocationsSelected.REPLACE,
|
||||
selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: [damageLocationsSelected.DRIVER]
|
||||
}],
|
||||
[3, false, "Windshield", "Passenger", {
|
||||
selectedWindshieldDamageType: [damageLocationsSelected.REPLACE],
|
||||
selectedWindshieldDamageType: damageLocationsSelected.REPLACE,
|
||||
selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: [damageLocationsSelected.PASSENGER]
|
||||
}],
|
||||
[4, true, "", "", {
|
||||
selectedWindshieldDamageType: [damageLocationsSelected.REPAIR],
|
||||
selectedWindshieldDamageType: damageLocationsSelected.REPAIR,
|
||||
selectedWindshieldChipCount: [2], selectedWindshieldReplaceOptions: []
|
||||
}]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -197,32 +197,32 @@ export default {
|
|||
},
|
||||
|
||||
getWindshieldOptionsFromStore() {
|
||||
var windShieldOptions = { selectedWindshieldDamageType: [], selectedWindshieldChipCount: [], selectedWindshieldReplaceOptions: []};
|
||||
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.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.SINGLE })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
|
||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE;
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.DRIVER })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
|
||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE;
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.PASSENGER })) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPLACE);
|
||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE;
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER);
|
||||
}
|
||||
}
|
||||
|
||||
if (store.getters.damage.isRepair) {
|
||||
windShieldOptions.selectedWindshieldDamageType.push(damageLocationsSelected.REPAIR);
|
||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPAIR;
|
||||
windShieldOptions.selectedWindshieldChipCount.push(store.getters.damage.numberOfChips);
|
||||
}
|
||||
|
||||
|
|
@ -350,12 +350,7 @@ export default {
|
|||
});
|
||||
},
|
||||
isWindshieldRepair() {
|
||||
if (!this.isWindshieldDamageLocation) return false;
|
||||
|
||||
return this.selectedWindshieldOptions.selectedWindshieldDamageType && this.selectedWindshieldOptions.selectedWindshieldDamageType.some(selectedDamageType =>
|
||||
{
|
||||
return selectedDamageType.toUpperCase() === "REPAIR";
|
||||
});
|
||||
return this.isWindshieldDamageLocation && this.selectedWindshieldOptions.selectedWindshieldDamageType === damageLocationsSelected.REPAIR;
|
||||
},
|
||||
isDriverSideReplace() {
|
||||
if (!this.isSideDoorDamageLocation) return false;
|
||||
|
|
@ -377,7 +372,7 @@ export default {
|
|||
return this.isWindshieldDamageLocation && this.selectedDamageLocations.length > 1 && this.isWindshieldRepair;
|
||||
},
|
||||
hasSplitSingleConflict() {
|
||||
if (!this.selectedDamageLocations || !this.selectedDamageLocations.includes("Windshield") || !this.selectedWindshieldOptions.selectedWindshieldDamageType || !this.selectedWindshieldOptions.selectedWindshieldDamageType.includes("Replace") || !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions) return false;
|
||||
if (!this.selectedDamageLocations?.includes("Windshield") || this.selectedWindshieldOptions.selectedWindshieldDamageType === damageLocationsSelected.REPAIR || !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions) return false;
|
||||
|
||||
return this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.some(selectedSingleWindshield =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import store from "@/store";
|
|||
export default ({
|
||||
name: "windshieldDamageTypeQuestion",
|
||||
props: {
|
||||
modelValue: Array,
|
||||
modelValue: String,
|
||||
groupName: String,
|
||||
isAvailable: Boolean,
|
||||
suppressError: Boolean,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
:isAvailable=isWindshieldDamageLocation
|
||||
:suppressError="hasRepairReplaceConflict || showNoReplacementAvailableError"
|
||||
groupName="WindshieldDamageTypeQuestion"
|
||||
v-model="selectedWindshieldDamageTypeValues"
|
||||
v-model="selectedWindshieldDamageTypeValue"
|
||||
:validationRules="windshieldDamageTypeQuestionValidationRules"
|
||||
/>
|
||||
<alert
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
validationRules="windshield-chip-count-required"
|
||||
/>
|
||||
<replaceOptionsQuestion ref="replaceOptionsQuestion" cmsWidgetName="WindshieldReplaceOptionsQuestion"
|
||||
:isAvailable=isReplaceOptionSelected
|
||||
:isAvailable="isReplaceOptionSelected"
|
||||
isMultiSelect
|
||||
groupName="WindshieldReplaceOptions"
|
||||
v-model="selectedWindshieldReplaceOptionsValues"
|
||||
|
|
@ -55,21 +55,13 @@ defineRule("windshield-damage-type-required", required(errorMessages.WINDSHIELD_
|
|||
defineRule("windshield-chip-count-required", required(errorMessages.WINDSHIELD_CHIP_COUNT_REQUIRED));
|
||||
defineRule("windshield-replace-options-required", required(errorMessages.WINSHIELD_REPLACE_OPTIONS_REQUIRED));
|
||||
|
||||
defineRule("check-for-repair-and-replace", (value, [otherFieldValue]) => {
|
||||
if (value.toString().toUpperCase().includes(damageLocationsSelected.REPAIR.toUpperCase()) &&
|
||||
otherFieldValue.toString().toUpperCase().includes(damageLocationsSelected.WINDSHIELD.toUpperCase()) &&
|
||||
Array.isArray(otherFieldValue) &&
|
||||
otherFieldValue.length > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
defineRule("check-for-repair-and-replace", (selectedWindshieldDamageType, [selectedDamageLocations]) => {
|
||||
return selectedWindshieldDamageType.toString() != damageLocationsSelected.REPAIR ||
|
||||
!selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) ||
|
||||
selectedDamageLocations.length === 1;
|
||||
});
|
||||
defineRule("repair-only", (value) => {
|
||||
if (value.toString().toUpperCase() === damageLocationsSelected.REPAIR.toUpperCase()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return value.toString() === damageLocationsSelected.REPAIR;
|
||||
});
|
||||
defineRule("prevent-split-and-single-together", (value) => {
|
||||
if (value.toString().toUpperCase().includes(damageLocationsSelected.SINGLE.toUpperCase()) &&
|
||||
|
|
@ -91,7 +83,7 @@ export default ({
|
|||
},
|
||||
|
||||
props: {
|
||||
modelValue: Array,
|
||||
modelValue: String,
|
||||
selectedDamageLocations: Array,
|
||||
hasRepairReplaceConflict: Boolean,
|
||||
hasSplitSingleConflict: Boolean,
|
||||
|
|
@ -120,7 +112,7 @@ export default ({
|
|||
this.$emit("update:modelValue", newValue);
|
||||
}
|
||||
},
|
||||
selectedWindshieldDamageTypeValues:{
|
||||
selectedWindshieldDamageTypeValue: {
|
||||
get: function() {
|
||||
return this.selectedValues.selectedWindshieldDamageType;
|
||||
},
|
||||
|
|
@ -133,7 +125,7 @@ export default ({
|
|||
return this.selectedValues.selectedWindshieldChipCount;
|
||||
},
|
||||
set: function(newValue) {
|
||||
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, newValue, null);
|
||||
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValue, newValue, null);
|
||||
}
|
||||
},
|
||||
selectedWindshieldReplaceOptionsValues: {
|
||||
|
|
@ -141,7 +133,7 @@ export default ({
|
|||
return this.selectedValues.selectedWindshieldReplaceOptions;
|
||||
},
|
||||
set: function(newValue) {
|
||||
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, null, newValue);
|
||||
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValue, null, newValue);
|
||||
}
|
||||
},
|
||||
isWindshieldDamageLocation() {
|
||||
|
|
@ -151,14 +143,10 @@ export default ({
|
|||
});
|
||||
},
|
||||
isRepairOptionSelected(){
|
||||
if (!this.selectedWindshieldDamageTypeValues) return false;
|
||||
|
||||
return this.selectedWindshieldDamageTypeValues.some(val => val.toUpperCase() === "REPAIR") && this.isWindshieldDamageLocation;
|
||||
return this.selectedWindshieldDamageTypeValue === damageLocationsSelected.REPAIR && this.isWindshieldDamageLocation;
|
||||
},
|
||||
isReplaceOptionSelected(){
|
||||
if (!this.selectedWindshieldDamageTypeValues) return false;
|
||||
|
||||
return this.selectedWindshieldDamageTypeValues.some(val => val.toUpperCase() === "REPLACE") && this.isWindshieldDamageLocation;
|
||||
return this.selectedWindshieldDamageTypeValue === damageLocationsSelected.REPLACE && this.isWindshieldDamageLocation;
|
||||
},
|
||||
isWindshieldReplaceAvailable() {
|
||||
return !(Array.isArray(this.windshieldAvailableReplacementOptions) && this.windshieldAvailableReplacementOptions.length < 1);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
<script>
|
||||
import { useField } from "vee-validate";
|
||||
import { toRef } from "vue";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
|
||||
export default {
|
||||
|
|
@ -177,7 +178,7 @@ export default {
|
|||
},
|
||||
selectedValues(newVal) {
|
||||
if (typeof newVal === "string") {
|
||||
this.handleChange(this.value);
|
||||
this.handleChange(newVal);
|
||||
this.checkValue = newVal == this.value;
|
||||
}
|
||||
else if (newVal !== undefined) {
|
||||
|
|
@ -203,8 +204,8 @@ export default {
|
|||
const {
|
||||
handleChange,
|
||||
errors,
|
||||
} = useField(props.groupName, props.validationRules, fieldOptions);
|
||||
|
||||
} = useField(toRef(props, "groupName"), toRef(props, "validationRules"), fieldOptions);
|
||||
|
||||
return {
|
||||
handleChange,
|
||||
errors,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { toRefs } from "vue";
|
||||
import { useField } from "vee-validate";
|
||||
export default {
|
||||
name: "radio",
|
||||
|
|
|
|||
Loading…
Reference in a new issue