Add copy for multi-glass scenarios.
This commit is contained in:
parent
843105a9ac
commit
e9fd49f137
1 changed files with 89 additions and 7 deletions
|
|
@ -23,17 +23,39 @@ export default {
|
|||
editClicked() {
|
||||
this.$emit("edit-clicked");
|
||||
},
|
||||
getAnswersNullSafe(widgetName) {
|
||||
const rawAnswers = this.getCmsContent(widgetName, "Answers");
|
||||
|
||||
return rawAnswers ? rawAnswers : [];
|
||||
},
|
||||
getLocationAnswer(damageLocation) {
|
||||
if(!this.locationAnswers) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.locationAnswers.find((answer) => answer.Name === damageLocation);
|
||||
return this.locationAnswers?.find((answer) => answer.Name === damageLocation);
|
||||
},
|
||||
getGlassPieces(damageLocation) {
|
||||
return this.damage?.glassToReplace?.filter(
|
||||
(item) => item.glassLocation === damageLocation
|
||||
);
|
||||
},
|
||||
generateBulletedListFromAnswers(answers) {
|
||||
let list = "<ul>";
|
||||
|
||||
answers.forEach((answer) => {
|
||||
list += `<li>${answer.Text}</li>`;
|
||||
});
|
||||
|
||||
list += "</ul>";
|
||||
|
||||
return list;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
displayContent() {
|
||||
return [...this.windshieldCopy];
|
||||
return [
|
||||
...this.windshieldCopy,
|
||||
...this.driverSideCopy,
|
||||
...this.passengerSideCopy,
|
||||
...this.rearCopy,
|
||||
];
|
||||
},
|
||||
hasWindshieldDamage() {
|
||||
return (
|
||||
|
|
@ -43,6 +65,21 @@ export default {
|
|||
)
|
||||
);
|
||||
},
|
||||
hasDriverSideDamage() {
|
||||
const driverPieces = this.getGlassPieces(damageLocationsSelected.DRIVER);
|
||||
|
||||
return !!driverPieces?.length;
|
||||
},
|
||||
hasPassengerSideDamage() {
|
||||
const passengerPieces = this.getGlassPieces(damageLocationsSelected.PASSENGER);
|
||||
|
||||
return !!passengerPieces?.length;
|
||||
},
|
||||
hasRearDamage() {
|
||||
const rearPieces = this.getGlassPieces(damageLocationsSelected.REAR);
|
||||
|
||||
return !!rearPieces?.length;
|
||||
},
|
||||
windshieldCopy() {
|
||||
const answerContent = this.getLocationAnswer(damageLocationsSelected.WINDSHIELD);
|
||||
|
||||
|
|
@ -52,8 +89,53 @@ export default {
|
|||
return [];
|
||||
}
|
||||
},
|
||||
driverSideCopy() {
|
||||
const answerContent = this.getLocationAnswer(damageLocationsSelected.DRIVER);
|
||||
const damageAnswers = this.getAnswersNullSafe(answerContent?.SubWidgetName);
|
||||
const damageAnswersOnOrder = damageAnswers?.filter((answer) =>
|
||||
this.damage?.glassToReplace?.some(
|
||||
(glassPiece) => answer.Name === glassPiece.glassName
|
||||
)
|
||||
);
|
||||
|
||||
if (this.hasDriverSideDamage) {
|
||||
return [
|
||||
answerContent?.Text,
|
||||
this.generateBulletedListFromAnswers(damageAnswersOnOrder),
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
passengerSideCopy() {
|
||||
const answerContent = this.getLocationAnswer(damageLocationsSelected.PASSENGER);
|
||||
const damageAnswers = this.getAnswersNullSafe(answerContent?.SubWidgetName);
|
||||
const damageAnswersOnOrder = damageAnswers?.filter((answer) =>
|
||||
this.damage?.glassToReplace?.some(
|
||||
(glassPiece) => answer.Name === glassPiece.glassName
|
||||
)
|
||||
);
|
||||
|
||||
if (this.hasPassengerSideDamage) {
|
||||
return [
|
||||
answerContent?.Text,
|
||||
this.generateBulletedListFromAnswers(damageAnswersOnOrder),
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
rearCopy() {
|
||||
const answerContent = this.getLocationAnswer(damageLocationsSelected.REAR);
|
||||
|
||||
if (this.hasRearDamage) {
|
||||
return [answerContent?.Text];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
locationAnswers() {
|
||||
return this.getCmsContent(this.damageLocationsWidgetName, "Answers");
|
||||
return this.getAnswersNullSafe(this.damageLocationsWidgetName);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue