CSR-108: refactors
This commit is contained in:
parent
ffad30387b
commit
b9ec2a4623
1 changed files with 24 additions and 32 deletions
|
|
@ -12,6 +12,7 @@
|
|||
<div class="fade-on-route-transition sub-container make-tall">
|
||||
<alert
|
||||
ref="alertFewMoreQuestions"
|
||||
cmsWidgetName="AlertFewMoreQuestionsWidget"
|
||||
class="my-5"
|
||||
alertClass="alert-warning"
|
||||
:manualHeadline="AlertFewMoreQuestionsHeader"
|
||||
|
|
@ -31,7 +32,7 @@
|
|||
<funnel-footer
|
||||
ref="funnelFooter"
|
||||
cmsWidgetName="FunnelFooterWidget"
|
||||
:isForwardActionDisabled="waitingForLoad || !meta.valid"
|
||||
:isForwardActionDisabled="!meta.valid"
|
||||
@back-clicked="backButtonAction"
|
||||
@ForwardClicked="forwardButtonAction"
|
||||
/>
|
||||
|
|
@ -87,11 +88,16 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
selectedModel: [],
|
||||
partsQuestionsData: [],
|
||||
waitingForLoad: true,
|
||||
partsQuestionsData: this.$store.getters.pageData(fmgPageValues.PART_QUESTIONS).partsOrQuestions.filter((p) => {
|
||||
if (Array.isArray(p.partQuestions) && p.partQuestions.length > 0) {
|
||||
return {
|
||||
glassName: p.glassName,
|
||||
glassLocation: p.glassLocation,
|
||||
partQuestions: p.partQuestions,
|
||||
};
|
||||
}
|
||||
}),
|
||||
currentPartNum: 0,
|
||||
glassNameAndParts: [],
|
||||
hasMultipleParts: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -102,22 +108,6 @@ export default {
|
|||
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: {
|
||||
showThisPartQuestionChain(part, i) {
|
||||
if (part.partQuestions?.length < 1) { return false; } // return false if only one partQuestion
|
||||
|
|
@ -152,14 +142,14 @@ export default {
|
|||
|
||||
if (!partsLookup) { return }
|
||||
|
||||
this.glassNameAndParts = partsLookup.data.glassNameAndParts;
|
||||
const glassNameAndParts = partsLookup.data.glassNameAndParts;
|
||||
|
||||
// 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
|
||||
const collectedGlassParts = [];
|
||||
this.glassNameAndParts.forEach((glass) => {
|
||||
glassNameAndParts.forEach((glass) => {
|
||||
if (Array.isArray(glass.parts) && glass.parts.length === 1) {
|
||||
const singlePart = glass.parts[0];
|
||||
collectedGlassParts.push({
|
||||
|
|
@ -172,14 +162,16 @@ export default {
|
|||
})
|
||||
}
|
||||
});
|
||||
store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
|
||||
this.navigateForward();
|
||||
if (!hasMultipleParts) {
|
||||
store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts);
|
||||
}
|
||||
this.navigateForward(hasMultipleParts, glassNameAndParts);
|
||||
},
|
||||
async navigateForward() {
|
||||
if (this.hasMultipleParts) {
|
||||
async navigateForward(hasMultipleParts, glassNameAndParts) {
|
||||
if (hasMultipleParts) {
|
||||
// if multiple parts on any glass
|
||||
// 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 {
|
||||
// if single parts only
|
||||
// go to quote page
|
||||
|
|
@ -212,12 +204,12 @@ export default {
|
|||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.part-questions {
|
||||
.question-text {
|
||||
.part-questions {
|
||||
.question-text {
|
||||
margin-bottom: .5rem;
|
||||
span {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in a new issue