commit
aa149d6807
10 changed files with 405 additions and 127 deletions
|
|
@ -122,7 +122,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleCheckedChanged(val) {
|
handleCheckedChanged(val) {
|
||||||
if(this.isMultiSelect) {
|
if(this.isMultiSelect && this.selectedValues) {
|
||||||
// Add or remove item to array of data to emit
|
// Add or remove item to array of data to emit
|
||||||
const newSelectedValues = this.selectedValues;
|
const newSelectedValues = this.selectedValues;
|
||||||
val.isChecked ? newSelectedValues.push(val.buttonId) : newSelectedValues.splice(newSelectedValues.indexOf(val.buttonId), 1);
|
val.isChecked ? newSelectedValues.push(val.buttonId) : newSelectedValues.splice(newSelectedValues.indexOf(val.buttonId), 1);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ export default ({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1) {
|
if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1 && this.selectedValues) {
|
||||||
const newSelectedValues = this.selectedValues;
|
const newSelectedValues = this.selectedValues;
|
||||||
newSelectedValues.push(this.answersToDisplay[0].Name);
|
newSelectedValues.push(this.answersToDisplay[0].Name);
|
||||||
this.selectedValues = newSelectedValues;
|
this.selectedValues = newSelectedValues;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
||||||
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
||||||
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
||||||
import damageLocationQuestion from "@/layouts/vehicle-damage/damage-location-question/damage-location-question";
|
import damageLocationQuestion from "@/layouts/vehicle-damage/damage-location-question/damage-location-question";
|
||||||
|
import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/windshield-options";
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
|
|
@ -177,7 +178,7 @@ function setupMocks({
|
||||||
availableReplacementOptions: ["Front", "Back", "Side"],
|
availableReplacementOptions: ["Front", "Back", "Side"],
|
||||||
},
|
},
|
||||||
windshieldOptions: {
|
windshieldOptions: {
|
||||||
availableReplacementOptions: ["Front", "Back", "Side"],
|
availableReplacementOptions: ["Single", "Driver", "Passenger"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -198,8 +199,8 @@ function setupMocks({
|
||||||
availableReplacementOptions: ["Front", "Back", "Side"],
|
availableReplacementOptions: ["Front", "Back", "Side"],
|
||||||
},
|
},
|
||||||
windshieldOptions: {
|
windshieldOptions: {
|
||||||
availableReplacementOptions: ["Front", "Back", "Side"],
|
availableReplacementOptions: ["Single", "Driver", "Passenger"],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -226,12 +227,11 @@ function setupMocks({
|
||||||
initializeComponent: jest.fn(),
|
initializeComponent: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const windshieldOptions = replaceOptionsQuestion
|
damageLocationQuestion.methods = {
|
||||||
windshieldOptions.methods = {
|
|
||||||
initializeComponent: jest.fn(),
|
initializeComponent: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
damageLocationQuestion.methods = {
|
windshieldOptions.methods = {
|
||||||
initializeComponent: jest.fn(),
|
initializeComponent: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -262,11 +262,13 @@ function setupMocks({
|
||||||
driverSideOptionsWrapper.vm.initializeComponent =
|
driverSideOptionsWrapper.vm.initializeComponent =
|
||||||
replaceOptionsQuestion.methods.initializeComponent;
|
replaceOptionsQuestion.methods.initializeComponent;
|
||||||
|
|
||||||
const windshieldOptionsWrapper = wrapper.findAllComponents({
|
const windshieldOptionsWrapper = wrapper.findComponent({
|
||||||
name: "replaceOptionsQuestion",
|
name: "windshieldOptions",
|
||||||
}).at(1);
|
});
|
||||||
|
|
||||||
windshieldOptionsWrapper.vm.initializeComponent =
|
windshieldOptionsWrapper.vm.initializeComponent =
|
||||||
replaceOptionsQuestion.methods.initializeComponent;
|
windshieldOptions.methods.initializeComponent;
|
||||||
|
|
||||||
|
|
||||||
const damageLocationQuestionWrapper = wrapper.findComponent({
|
const damageLocationQuestionWrapper = wrapper.findComponent({
|
||||||
name: "damageLocationQuestion",
|
name: "damageLocationQuestion",
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
<damageLocationQuestion ref="damageLocation" v-model="selectedDamageLocations" groupName="DamageLocationQuestion" />
|
<damageLocationQuestion ref="damageLocation" v-model="selectedDamageLocations" groupName="DamageLocationQuestion" />
|
||||||
<replaceOptionsQuestion ref="driverSideOptions" isAvailable filterByVehicleCategory v-model="driverSideOptionsData" groupName="DriverSideReplaceOptionsQuestion" />
|
<replaceOptionsQuestion ref="driverSideOptions" isAvailable filterByVehicleCategory v-model="driverSideOptionsData" groupName="DriverSideReplaceOptionsQuestion" />
|
||||||
<replaceOptionsQuestion ref="windshieldOptions" isAvailable groupName="windshieldOptions" v-model="windshieldOptionsData" />
|
<replaceOptionsQuestion ref="windshieldOptions" isAvailable groupName="windshieldOptions" v-model="windshieldOptionsData" />
|
||||||
|
<windshieldOptions ref="windshieldOptions"
|
||||||
|
v-model="selectedWindshieldOptions"
|
||||||
|
:selectedDamageLocations="selectedDamageLocations"
|
||||||
|
/>
|
||||||
<funnelFooter ref="funnelFooter" @back-clicked="backButtonAction" />
|
<funnelFooter ref="funnelFooter" @back-clicked="backButtonAction" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -16,8 +20,9 @@ import funnelHeader from "@/common-components/funnel-header/funnel-header";
|
||||||
import funnelFooter from "@/common-components/funnel-footer/funnel-footer";
|
import funnelFooter from "@/common-components/funnel-footer/funnel-footer";
|
||||||
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
||||||
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
||||||
import replaceOptionsQuestion from "@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
import replaceOptionsQuestion from"@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
||||||
import damageLocationQuestion from "@/layouts/vehicle-damage/damage-location-question/damage-location-question";
|
import damageLocationQuestion from"@/layouts/vehicle-damage/damage-location-question/damage-location-question";
|
||||||
|
import windshieldOptions from "@/layouts/vehicle-damage/windshield-options/windshield-options";
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
|
@ -70,6 +75,7 @@ export default {
|
||||||
resultMap.cmsContent.DamageLocationQuestion, resultMap.damageOptions
|
resultMap.cmsContent.DamageLocationQuestion, resultMap.damageOptions
|
||||||
);
|
);
|
||||||
vm.$refs.windshieldOptions.initializeComponent(
|
vm.$refs.windshieldOptions.initializeComponent(
|
||||||
|
resultMap.cmsContent.WindshieldDamageTypeQuestion, resultMap.cmsContent.WindshieldChipCountQuestion,
|
||||||
resultMap.cmsContent.WindshieldReplaceOptionsQuestion, resultMap.damageOptions.windshieldOptions.availableReplacementOptions
|
resultMap.cmsContent.WindshieldReplaceOptionsQuestion, resultMap.damageOptions.windshieldOptions.availableReplacementOptions
|
||||||
);
|
);
|
||||||
vm.$refs.funnelFooter.initializeComponent(
|
vm.$refs.funnelFooter.initializeComponent(
|
||||||
|
|
@ -81,7 +87,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
selectedDamageLocations: [],
|
selectedDamageLocations: [],
|
||||||
driverSideOptionsData: [],
|
driverSideOptionsData: [],
|
||||||
windshieldOptionsData: [],
|
selectedWindshieldOptions: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -107,6 +113,7 @@ export default {
|
||||||
funnelSubHeader,
|
funnelSubHeader,
|
||||||
replaceOptionsQuestion,
|
replaceOptionsQuestion,
|
||||||
damageLocationQuestion,
|
damageLocationQuestion,
|
||||||
|
windshieldOptions,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="windshield-damage-type-question">
|
|
||||||
<buttonQuestion
|
|
||||||
v-if="isAvailable && answersToDisplay.length > 1"
|
|
||||||
:questionText="questionText"
|
|
||||||
:answers="answersToDisplay"
|
|
||||||
:groupName="groupName"
|
|
||||||
buttonType="listCard"
|
|
||||||
v-model="selectedValues"
|
|
||||||
validationRules="windshield-damage-required|checkForRepairAndReplace:@DamageLocationQuestion"
|
|
||||||
:suppressError="suppressError"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import buttonQuestion from "@/common-components/button-question/button-question";
|
|
||||||
import store from "@/store";
|
|
||||||
import { defineRule } from "vee-validate";
|
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
|
||||||
defineRule("windshield-damage-required", (value) => {
|
|
||||||
if (!value || value.length < 1) {
|
|
||||||
return "Please select windshield damage";
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
defineRule("checkForRepairAndReplace", (value, [other]) => {
|
|
||||||
if (value === "Windshield-Chip" && other.toString().includes("Windshield") && other.length > 1) {
|
|
||||||
return "checkForRepairAndReplace error"
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default ({
|
|
||||||
name: "windshieldDamageTypeQuestion",
|
|
||||||
data(){
|
|
||||||
return {
|
|
||||||
questionText: String,
|
|
||||||
answersFromCms: Array,
|
|
||||||
damageOptions: Object,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
isMultiSelect: Boolean,
|
|
||||||
modelValue: Array,
|
|
||||||
isAvailable: Boolean,
|
|
||||||
name: String,
|
|
||||||
groupName: String,
|
|
||||||
suppressError: Boolean,
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
initializeComponent(cmsContent, damageOptions){
|
|
||||||
this.questionText = cmsContent.QuestionText;
|
|
||||||
this.answersFromCms = cmsContent.Answers;
|
|
||||||
this.damageOptions = damageOptions;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
selectedValues: {
|
|
||||||
get: function() {
|
|
||||||
return this.modelValue;
|
|
||||||
},
|
|
||||||
set: function(newValue) {
|
|
||||||
this.$emit("update:modelValue", newValue);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
damageOptionsMap(){
|
|
||||||
return {
|
|
||||||
Windshield: true,
|
|
||||||
SideDoor: this.damageOptions.driverSideOptions.availableReplacementOptions || this.damageOptions.passengerSideOptions.availableReplacementOption ? true : false,
|
|
||||||
RearWindow: this.damageOptions.backGlassOptions.availableReplacementOptions ? true : false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
answersToDisplay(){
|
|
||||||
// HARD CODED MOCK DATA FOR NOW
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
"Name": "Windshield-Crack",
|
|
||||||
"Text": "Crack",
|
|
||||||
"SubText": "My damage is larger than six inches.",
|
|
||||||
"ImageId": "2cf13fbb-22d8-4b61-bd3d-3d413ea58c87",
|
|
||||||
"AnswerImageUrl": "https://fixmyglass.safelite.com/Shared/images/icon-replace-desktop-ds.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "Windshield-Chip",
|
|
||||||
"Text": "Chip(s)",
|
|
||||||
"SubText": "I have three or fewer chips smaller than six inches.",
|
|
||||||
"ImageId": "faaa14d9-3650-4949-a687-7665962337b8",
|
|
||||||
"AnswerImageUrl": "https://fixmyglass.safelite.com/Shared/images/icon-repair-desktop-ds.png"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
buttonQuestion,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import windshieldChipCountQuestion from "@/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
|
jest.mock("@/store", () => { return {}; }, {virtual: true});
|
||||||
|
|
||||||
|
describe("windshield-chip-count-question.vue", () => {
|
||||||
|
test("Selected chip count is emitted upon selection.", async () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({modelValueProp: ["One"]});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
wrapper.setValue({ modelValue: ["Two"] });
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.selectedChipCountValues).toEqual(["One"]);
|
||||||
|
expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: ["Two"] }]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Windshield-chip-count-question.vue", () => {
|
||||||
|
test("Should display question and answers from api.", async () => {
|
||||||
|
|
||||||
|
//Arrange
|
||||||
|
const { wrapper, cmsContent } = setupMocks({modelValueProp: ["One"]});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
windshieldChipCountQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.questionText).toStrictEqual("How many chips are we repairing?");
|
||||||
|
expect(wrapper.vm.answersFromCms).toStrictEqual([ { Name: 'One' }, { Name: 'Two' }, { Name: 'Three'} ]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function setupMocks({
|
||||||
|
modelValueProp = ["Two"],
|
||||||
|
groupName = "WindshieldChipCountQuestion",
|
||||||
|
cmsQuestionText = "How many chips are we repairing?",
|
||||||
|
cmsAnswers = [{Name: "One"}, {Name: "Two"}, {Name: "Three"}],
|
||||||
|
dataFromStoreApi = [],
|
||||||
|
}) {
|
||||||
|
|
||||||
|
//Mock store
|
||||||
|
store.dispatch = jest.fn(() => dataFromStoreApi);
|
||||||
|
store.getters = { vehicle: {year: 2019, make: 'honda', model: 'civc', style: '2 Door', category: 'CAR'} };
|
||||||
|
const mountOptions = getMountOptions({
|
||||||
|
store: {
|
||||||
|
dispatch: store.dispatch,
|
||||||
|
getters: store.getters,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
//Mock props
|
||||||
|
mountOptions.propsData = {
|
||||||
|
modelValue: modelValueProp
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = shallowMount(windshieldChipCountQuestion, mountOptions);
|
||||||
|
|
||||||
|
//Mock CMS content
|
||||||
|
const cmsContent = {
|
||||||
|
groupName: groupName,
|
||||||
|
QuestionText: cmsQuestionText,
|
||||||
|
Answers: cmsAnswers,
|
||||||
|
};
|
||||||
|
const damageOptions = dataFromStoreApi;
|
||||||
|
return { wrapper, cmsContent, damageOptions };
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<template>
|
||||||
|
<transition name="fade">
|
||||||
|
<div class="windshield-chip-count-question">
|
||||||
|
<buttonQuestion
|
||||||
|
v-if="isAvailable"
|
||||||
|
:questionText="questionText"
|
||||||
|
:answers="answersFromCms"
|
||||||
|
:groupName="groupName"
|
||||||
|
buttonType="listButtonHorizontal"
|
||||||
|
v-model="selectedChipCountValues"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||||
|
|
||||||
|
export default ({
|
||||||
|
name: "windshieldOptions",
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
questionText: String,
|
||||||
|
answersFromCms: Array
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
modelValue: Array,
|
||||||
|
groupName: String,
|
||||||
|
isAvailable: Boolean,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initializeComponent(cmsContent){
|
||||||
|
this.questionText = cmsContent.QuestionText;
|
||||||
|
this.answersFromCms = cmsContent.Answers;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
selectedChipCountValues: {
|
||||||
|
get: function() {
|
||||||
|
return this.modelValue;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
this.$emit("update:modelValue", newValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
buttonQuestion,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import windshieldDamageTypeQuestion from"@/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
|
jest.mock("@/store", () => { return {}; }, {virtual: true});
|
||||||
|
|
||||||
|
describe("windshield-damage-type-question.vue", () => {
|
||||||
|
test("Selected chip count is emitted upon selection.", async () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({modelValueProp: ["Repair"]});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
wrapper.setValue({ modelValue: ["Replace"] });
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.selectedValues).toEqual(["Repair"]);
|
||||||
|
expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: ["Replace"] }]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("windshield-damage-type-question.vue", () => {
|
||||||
|
test("Should display question and answers from api.", async () => {
|
||||||
|
|
||||||
|
//Arrange
|
||||||
|
const { wrapper, cmsContent } = setupMocks({modelValueProp: ["Repair"]});
|
||||||
|
|
||||||
|
//Act
|
||||||
|
windshieldDamageTypeQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.questionText).toStrictEqual("What's your windshield damage?");
|
||||||
|
expect(wrapper.vm.answersFromCms).toStrictEqual([ { Name: 'Repair' }, { Name: 'Replace' } ]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function setupMocks({
|
||||||
|
modelValueProp = ["Two"],
|
||||||
|
groupName = "WindshieldDamageTypeQuestion",
|
||||||
|
cmsQuestionText = "What's your windshield damage?",
|
||||||
|
cmsAnswers = [{Name: "Repair"}, {Name: "Replace"}],
|
||||||
|
dataFromStoreApi = [],
|
||||||
|
}) {
|
||||||
|
|
||||||
|
//Mock store
|
||||||
|
store.dispatch = jest.fn(() => dataFromStoreApi);
|
||||||
|
store.getters = { vehicle: {year: 2019, make: 'honda', model: 'civc', style: '2 Door', category: 'CAR'} };
|
||||||
|
const mountOptions = getMountOptions({
|
||||||
|
store: {
|
||||||
|
dispatch: store.dispatch,
|
||||||
|
getters: store.getters,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
//Mock props
|
||||||
|
mountOptions.propsData = {
|
||||||
|
modelValue: modelValueProp
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = shallowMount(windshieldDamageTypeQuestion, mountOptions);
|
||||||
|
|
||||||
|
//Mock CMS content
|
||||||
|
const cmsContent = {
|
||||||
|
groupName: groupName,
|
||||||
|
QuestionText: cmsQuestionText,
|
||||||
|
Answers: cmsAnswers,
|
||||||
|
};
|
||||||
|
const damageOptions = dataFromStoreApi;
|
||||||
|
return { wrapper, cmsContent, damageOptions };
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
<template>
|
||||||
|
<transition name="fade">
|
||||||
|
<div class="windshield-damage-type-question">
|
||||||
|
<buttonQuestion
|
||||||
|
v-if="isAvailable"
|
||||||
|
:questionText="questionText"
|
||||||
|
:answers="answersFromCms"
|
||||||
|
:groupName="groupName"
|
||||||
|
buttonType="listCard"
|
||||||
|
v-model="selectedValues"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||||
|
//import { defineRule } from "vee-validate";
|
||||||
|
|
||||||
|
//DEFINE VALIDATION RULES
|
||||||
|
// add these to the button component above:
|
||||||
|
// validationRules="windshield-damage-required|checkForRepairAndReplace:@DamageLocationQuestion"
|
||||||
|
// :suppressError="suppressError"
|
||||||
|
// defineRule("windshield-damage-required", (value) => {
|
||||||
|
// if (!value || value.length < 1) {
|
||||||
|
// return "Please select windshield damage";
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
// defineRule("checkForRepairAndReplace", (value, [other]) => {
|
||||||
|
// if (value === "Windshield-Chip" && other.toString().includes("Windshield") && other.length > 1) {
|
||||||
|
// return "checkForRepairAndReplace error"
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
|
||||||
|
export default ({
|
||||||
|
name: "windshieldDamageTypeQuestion",
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
questionText: String,
|
||||||
|
answersFromCms: Array
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
modelValue: Array,
|
||||||
|
groupName: String,
|
||||||
|
isAvailable: Boolean,
|
||||||
|
suppressError: Boolean,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initializeComponent(cmsContent){
|
||||||
|
this.questionText = cmsContent.QuestionText;
|
||||||
|
this.answersFromCms = cmsContent.Answers;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
selectedValues: {
|
||||||
|
get: function() {
|
||||||
|
return this.modelValue;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
this.$emit("update:modelValue", newValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
buttonQuestion,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -1,26 +1,129 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="windshield-options">
|
<transition name="fade">
|
||||||
<windshieldDamageTypeQuestion
|
<div class="windshield-options" aria-live="polite">
|
||||||
ref="windshieldDamageType"
|
<windshieldDamageTypeQuestion ref="windshieldDamageTypeQuestion"
|
||||||
v-model="selectedWindshieldDamageTypes"
|
:isAvailable=isWindshieldDamageLocation
|
||||||
groupName="windshieldDamageTypeQuestion"
|
:suppressError="suppressError"
|
||||||
:isAvailable="showWindshieldDamageTypeQuestion"
|
groupName="WindshieldDamageTypeQuestion"
|
||||||
:suppressError="suppressError"
|
v-model="selectedWindshieldDamageTypeValues"
|
||||||
/>
|
/>
|
||||||
</div>
|
<windshieldChipCountQuestion ref="windshieldChipCountQuestion"
|
||||||
|
:isAvailable=isRepairOptionSelected
|
||||||
|
groupName="WindshieldChipCountQuestion"
|
||||||
|
v-model="selectedWindshieldChipCountValues"
|
||||||
|
/>
|
||||||
|
<replaceOptionsQuestion ref="replaceOptionsQuestion"
|
||||||
|
:isAvailable=isReplaceOptionSelected
|
||||||
|
groupName="WindshieldReplaceOptions"
|
||||||
|
v-model="selectedWindshieldReplaceOptionsValues"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import windshieldDamageTypeQuestion from "@/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question";
|
import windshieldDamageTypeQuestion from"@/layouts/vehicle-damage/windshield-options/windshield-damage-type-question/windshield-damage-type-question";
|
||||||
|
import windshieldChipCountQuestion from"@/layouts/vehicle-damage/windshield-options/windshield-chip-count-question/windshield-chip-count-question";
|
||||||
|
import replaceOptionsQuestion from"@/layouts/vehicle-damage/replace-options-question/replace-options-question";
|
||||||
export default ({
|
export default ({
|
||||||
name: "windshieldOptions",
|
name: "windshieldOptions",
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
chipCountQuestionText: String,
|
||||||
|
chipCountAnswersFromCms: Array,
|
||||||
|
|
||||||
|
selectedWindshieldDamageType: null,
|
||||||
|
selectedWindshieldChipCount: null,
|
||||||
|
selectedWindshieldReplaceOptions: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
showWindshieldDamageTypeQuestion: Boolean,
|
modelValue: Array,
|
||||||
suppressError: Boolean,
|
selectedDamageLocations: Array,
|
||||||
|
selectedChipCount: Array,
|
||||||
|
selectedReplaceOptions: Array,
|
||||||
|
suppressError: Boolean
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
initializeComponent(windshieldDamageTypeQuestionFromCms, windshieldChipCountQuestionFromCms,
|
||||||
|
windshieldReplaceOptionsQuestionFromCms, windshieldAvailableReplacementOptions){
|
||||||
|
|
||||||
|
this.chipCountQuestionText = windshieldChipCountQuestionFromCms.QuestionText;
|
||||||
|
this.chipCountAnswersFromCms = windshieldChipCountQuestionFromCms.Answers;
|
||||||
|
|
||||||
|
this.$refs.windshieldDamageTypeQuestion.initializeComponent(windshieldDamageTypeQuestionFromCms);
|
||||||
|
this.$refs.windshieldChipCountQuestion.initializeComponent(windshieldChipCountQuestionFromCms);
|
||||||
|
this.$refs.replaceOptionsQuestion.initializeComponent(windshieldReplaceOptionsQuestionFromCms, windshieldAvailableReplacementOptions);
|
||||||
|
},
|
||||||
|
getWindshieldOptions(selectedWindshieldDamageType, selectedWindshieldChipCount, selectedWindshieldReplaceOptions){
|
||||||
|
return {
|
||||||
|
selectedWindshieldDamageType: selectedWindshieldDamageType,
|
||||||
|
selectedWindshieldChipCount: selectedWindshieldChipCount,
|
||||||
|
selectedWindshieldReplaceOptions: selectedWindshieldReplaceOptions
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
selectedValues: {
|
||||||
|
get: function() {
|
||||||
|
return this.modelValue;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
this.$emit("update:modelValue", newValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedWindshieldDamageTypeValues:{
|
||||||
|
get: function() {
|
||||||
|
return this.selectedValues.selectedWindshieldDamageType;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
this.selectedValues.selectedWindshieldChipCount = null;
|
||||||
|
this.selectedValues.selectedWindshieldReplaceOptions = null;
|
||||||
|
this.selectedValues = this.getWindshieldOptions(newValue, this.selectedWindshieldChipCountValues, this.selectedWindshieldReplaceOptionsValues);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedWindshieldChipCountValues: {
|
||||||
|
get: function() {
|
||||||
|
return this.selectedValues.selectedChipCount;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
this.selectedValues.selectedWindshieldReplaceOptions = null;
|
||||||
|
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, newValue, this.selectedWindshieldReplaceOptionsValues);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedWindshieldReplaceOptionsValues: {
|
||||||
|
get: function() {
|
||||||
|
return this.selectedValues.selectedWindshieldReplaceOptions;
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
this.selectedValues.selectedWindshieldChipCount = null;
|
||||||
|
this.selectedValues = this.getWindshieldOptions(this.selectedWindshieldDamageTypeValues, this.selectedWindshieldChipCountValues, newValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isWindshieldDamageLocation() {
|
||||||
|
return this.selectedDamageLocations.some(selectedDamages =>
|
||||||
|
{
|
||||||
|
const categoryAndGlass = selectedDamages.split('-'); //ie: "Suv-Windshield" Splits the answers into [0]"Suv" [1]"Windshield"
|
||||||
|
return Boolean(categoryAndGlass[1].toUpperCase() === "WINDSHIELD");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isRepairOptionSelected(){
|
||||||
|
if (!this.selectedWindshieldDamageTypeValues) return false;
|
||||||
|
|
||||||
|
return this.selectedWindshieldDamageTypeValues.some(val => val.toUpperCase() === "REPAIR") && this.isWindshieldDamageLocation;
|
||||||
|
},
|
||||||
|
isReplaceOptionSelected(){
|
||||||
|
if (!this.selectedWindshieldDamageTypeValues) return false;
|
||||||
|
|
||||||
|
return this.selectedWindshieldDamageTypeValues.some(val => val.toUpperCase() === "REPLACE") && this.isWindshieldDamageLocation;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
windshieldDamageTypeQuestion,
|
windshieldDamageTypeQuestion,
|
||||||
|
windshieldChipCountQuestion,
|
||||||
|
replaceOptionsQuestion
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in a new issue