CSR-715 Add check-for-repair-and-replace validation back in

This commit is contained in:
Katie 2022-07-05 10:19:46 -04:00
parent ba1764b9e6
commit 15718a6403
3 changed files with 9 additions and 4 deletions

View file

@ -383,7 +383,7 @@ export default {
return this.isWindshieldDamageLocation && this.selectedDamageLocations.length > 1 && this.isWindshieldRepair;
},
hasSplitSingleConflict() {
if (!this.selectedDamageLocations?.includes("Windshield") || this.selectedWindshieldOptions.selectedWindshieldDamageType?.toUpperCase() === damageLocationsSelected.REPAIR || !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions) return false;
if (!this.selectedDamageLocations?.includes("Windshield") || this.selectedWindshieldOptions.selectedWindshieldDamageType?.toUpperCase() === damageLocationsSelected.REPAIR.toUpperCase() || !this.selectedWindshieldOptions.selectedWindshieldReplaceOptions) return false;
return this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.some(selectedSingleWindshield =>
{

View file

@ -55,6 +55,11 @@ 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", (selectedWindshieldDamageType, [selectedDamageLocations]) => {
return selectedWindshieldDamageType.toString() != damageLocationsSelected.REPAIR ||
!selectedDamageLocations.includes(damageLocationsSelected.WINDSHIELD) ||
selectedDamageLocations.length === 1;
});
defineRule("repair-only", (value) => {
return value.toString().toUpperCase() === damageLocationsSelected.REPAIR.toUpperCase();
});
@ -165,7 +170,7 @@ export default ({
},
windshieldDamageTypeQuestionValidationRules() {
// Note: the validation rules string is not dynamic (it cannot be changed once component has been created)
let validationRules = "windshield-damage-type-required";
let validationRules = "windshield-damage-type-required|check-for-repair-and-replace:@DamageLocationQuestion";
// if vehicle has no windshield replacement option
if (!this.isWindshieldReplaceAvailable) {
validationRules = validationRules.concat('|repair-only');

View file

@ -134,7 +134,7 @@ export default {
},
},
methods: {
handleInputChange(x) {
handleInputChange() {
if(!this.selectingInitiatesLoad) {
this.handleCheckChange();
}
@ -149,7 +149,7 @@ export default {
}
this.handleChange(this.value);
},
triggerButton(x) {
triggerButton() {
if(this.selectingInitiatesLoad) {
this.displayLoader();
this.handleCheckChange();