87 lines
No EOL
2.8 KiB
Vue
87 lines
No EOL
2.8 KiB
Vue
<template>
|
|
<div class="damage-location-question">
|
|
DLQ selectedValue: {{selectedValue}}
|
|
<buttonQuestion
|
|
:questionText="questionText"
|
|
isMultiSelect
|
|
:answers="answersToDisplay"
|
|
:groupName="groupName"
|
|
buttonType="listCard"
|
|
isRequired
|
|
v-model="selectedValue"
|
|
:selectOnKeypress="true"
|
|
validationRules="damage-location-required"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
|
import store from "@/store";
|
|
import { defineRule } from "vee-validate";
|
|
import { required } from "@/helpers/validation-rules";
|
|
import { errorMessages } from "@/constants/error-messages";
|
|
import buttonQuestionWrapperMixin from "@/mixins/button-question-wrapper-mixin"
|
|
|
|
// DEFINE VALIDATION RULES
|
|
defineRule("damage-location-required", required(errorMessages.DAMAGE_LOCATION_REQUIRED));
|
|
|
|
export default ({
|
|
name: "damageLocationQuestion",
|
|
mixins: [buttonQuestionWrapperMixin],
|
|
data(){
|
|
return {
|
|
damageOptions: {},
|
|
// selectedValue: []
|
|
}
|
|
},
|
|
props: {
|
|
modelValue: Array,
|
|
groupName: String,
|
|
cmsWidgetName: String,
|
|
},
|
|
methods: {
|
|
initializeComponent(damageOptions){
|
|
this.damageOptions = damageOptions;
|
|
},
|
|
},
|
|
computed: {
|
|
questionText(){
|
|
return this.getCmsContent(this.cmsWidgetName, 'QuestionText');
|
|
},
|
|
answersFromCms(){
|
|
return this.getCmsContent(this.cmsWidgetName, 'Answers');
|
|
},
|
|
damageOptionsMap(){
|
|
return {
|
|
Windshield: true,
|
|
SideDoor: this.damageOptions.driverSideOptions.availableReplacementOptions.length || this.damageOptions.passengerSideOptions.availableReplacementOptions.length,
|
|
RearWindow: this.damageOptions.backGlassOptions.availableReplacementOptions.length,
|
|
}
|
|
},
|
|
answersToDisplay(){
|
|
const filteredAnswers = Array.isArray(this.answersFromCms)
|
|
? this.answersFromCms.filter(ans =>
|
|
{
|
|
const name = ans.Name.split('-');
|
|
return name[0].toUpperCase() === store.getters.vehicle.category && this.damageOptionsMap[name[1]];
|
|
})
|
|
: [];
|
|
return filteredAnswers.map(ans => {
|
|
const newName = ans.Name.includes('-') ? ans.Name.split('-')[1] : ans.Name;
|
|
ans.Name = newName;
|
|
return ans;
|
|
});
|
|
},
|
|
},
|
|
components: {
|
|
buttonQuestion,
|
|
},
|
|
watch: {
|
|
selectedValue(selectedValue) {
|
|
// console.log("DLQ: ", selectedValue)
|
|
this.$emit("update:modelValue", selectedValue)
|
|
}
|
|
}
|
|
})
|
|
</script> |