Merge pull request #620 from Safelite/feature/CSR-108
CSR-108: refactors
This commit is contained in:
commit
48e3a040b2
1 changed files with 24 additions and 32 deletions
|
|
@ -12,6 +12,7 @@
|
||||||
<div class="fade-on-route-transition sub-container make-tall">
|
<div class="fade-on-route-transition sub-container make-tall">
|
||||||
<alert
|
<alert
|
||||||
ref="alertFewMoreQuestions"
|
ref="alertFewMoreQuestions"
|
||||||
|
cmsWidgetName="AlertFewMoreQuestionsWidget"
|
||||||
class="my-5"
|
class="my-5"
|
||||||
alertClass="alert-warning"
|
alertClass="alert-warning"
|
||||||
:manualHeadline="AlertFewMoreQuestionsHeader"
|
:manualHeadline="AlertFewMoreQuestionsHeader"
|
||||||
|
|
@ -31,7 +32,7 @@
|
||||||
<funnel-footer
|
<funnel-footer
|
||||||
ref="funnelFooter"
|
ref="funnelFooter"
|
||||||
cmsWidgetName="FunnelFooterWidget"
|
cmsWidgetName="FunnelFooterWidget"
|
||||||
:isForwardActionDisabled="waitingForLoad || !meta.valid"
|
:isForwardActionDisabled="!meta.valid"
|
||||||
@back-clicked="backButtonAction"
|
@back-clicked="backButtonAction"
|
||||||
@ForwardClicked="forwardButtonAction"
|
@ForwardClicked="forwardButtonAction"
|
||||||
/>
|
/>
|
||||||
|
|
@ -87,11 +88,16 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedModel: [],
|
selectedModel: [],
|
||||||
partsQuestionsData: [],
|
partsQuestionsData: this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS).partsOrQuestions.filter((p) => {
|
||||||
waitingForLoad: true,
|
if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
|
||||||
|
return {
|
||||||
|
glassName: p.glassName,
|
||||||
|
glassLocation: p.glassLocation,
|
||||||
|
partQuestions: p.partQuestions,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}),
|
||||||
currentPartNum: 0,
|
currentPartNum: 0,
|
||||||
glassNameAndParts: [],
|
|
||||||
hasMultipleParts: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -102,22 +108,6 @@ export default {
|
||||||
return this.getCmsContent("AlertPartsQuestions", "BodyText");
|
return this.getCmsContent("AlertPartsQuestions", "BodyText");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async mounted() {
|
|
||||||
const questionData = await this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS);
|
|
||||||
|
|
||||||
// Map API result data, to part-questions data structure
|
|
||||||
this.partsQuestionsData = questionData.partsOrQuestions.filter((p) => {
|
|
||||||
if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
|
|
||||||
return {
|
|
||||||
glassName: p.glassName,
|
|
||||||
glassLocation: p.glassLocation,
|
|
||||||
partQuestions: p.partQuestions,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.waitingForLoad = false;
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
showThisPartQuestionChain(part, i) {
|
showThisPartQuestionChain(part, i) {
|
||||||
if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion
|
if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion
|
||||||
|
|
@ -152,14 +142,14 @@ export default {
|
||||||
|
|
||||||
if (!partsLookup) { return }
|
if (!partsLookup) { return }
|
||||||
|
|
||||||
this.glassNameAndParts = partsLookup.data.glassNameAndParts;
|
const glassNameAndParts = partsLookup.data.glassNameAndParts;
|
||||||
|
|
||||||
// test response data for multiple parts
|
// test response data for multiple parts
|
||||||
this.hasMultipleParts = this.glassNameAndParts.some((glass) => glass.parts?.length > 1);
|
const hasMultipleParts = glassNameAndParts.some((glass) => glass.parts?.length > 1);
|
||||||
|
|
||||||
// loop through all glass items
|
// loop through all glass items
|
||||||
const collectedGlassParts = [];
|
const collectedGlassParts = [];
|
||||||
this.glassNameAndParts.forEach((glass) => {
|
glassNameAndParts.forEach((glass) => {
|
||||||
if (Array.isArray(glass.parts) && glass.parts.length === 1) {
|
if (Array.isArray(glass.parts) && glass.parts.length === 1) {
|
||||||
const singlePart = glass.parts[0];
|
const singlePart = glass.parts[0];
|
||||||
collectedGlassParts.push({
|
collectedGlassParts.push({
|
||||||
|
|
@ -172,14 +162,16 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
|
if (!hasMultipleParts) {
|
||||||
this.navigateForward();
|
store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
|
||||||
|
}
|
||||||
|
this.navigateForward(hasMultipleParts, glassNameAndParts);
|
||||||
},
|
},
|
||||||
async navigateForward() {
|
async navigateForward(hasMultipleParts, glassNameAndParts) {
|
||||||
if (this.hasMultipleParts) {
|
if (hasMultipleParts) {
|
||||||
// if multiple parts on any glass
|
// if multiple parts on any glass
|
||||||
// go to vehicle-parts page and pass the partsData
|
// go to vehicle-parts page and pass the partsData
|
||||||
this.$router.navigate(this.navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS,this.$route,{},{},{partsOrQuestions: this.glassNameAndParts});
|
this.$router.navigate(this.navigationScenarios.ANSWERED_QUESTIONS_WITH_MULTIPLE_PARTS,this.$route,{},{},{partsOrQuestions: glassNameAndParts});
|
||||||
} else {
|
} else {
|
||||||
// if single parts only
|
// if single parts only
|
||||||
// go to quote page
|
// go to quote page
|
||||||
|
|
@ -212,12 +204,12 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.part-questions {
|
.part-questions {
|
||||||
.question-text {
|
.question-text {
|
||||||
margin-bottom: .5rem;
|
margin-bottom: .5rem;
|
||||||
span {
|
span {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue