Vehicle parts linting
This commit is contained in:
parent
4f14fa0612
commit
c22a4fc09f
1 changed files with 23 additions and 40 deletions
|
|
@ -84,7 +84,7 @@ export default {
|
|||
vehicleBanner,
|
||||
siteSubHeader,
|
||||
siteFooter,
|
||||
alert,
|
||||
alert
|
||||
},
|
||||
mixins: [BaseFormMixin, vehicleQuestionsMixin],
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
|
|
@ -94,8 +94,8 @@ export default {
|
|||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: 'cmsContent',
|
||||
promise: cmsContentPromise,
|
||||
},
|
||||
promise: cmsContentPromise
|
||||
}
|
||||
];
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
|
|
@ -104,33 +104,26 @@ export default {
|
|||
|
||||
// Glass Part Question dynamic component
|
||||
Object.keys(vm.$refs)
|
||||
.filter(
|
||||
(r) =>
|
||||
r.includes(vm.RefPrefix) && vm.$refs[r][0] !== undefined
|
||||
)
|
||||
.filter((r) => r.includes(vm.RefPrefix) && vm.$refs[r][0] !== undefined)
|
||||
.forEach((c) =>
|
||||
vm.$refs[c][0].initializeComponent({
|
||||
ColorQuestionWidget:
|
||||
resultMap.cmsContent.ColorQuestionWidget,
|
||||
FeatureQuestionWidget:
|
||||
resultMap.cmsContent.FeatureQuestionWidget,
|
||||
})
|
||||
);
|
||||
resultMap.cmsContent.FeatureQuestionWidget
|
||||
}));
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selectedGlassParts: {},
|
||||
alertWidgetData: Object,
|
||||
alreadyPopulatedPartsData: [],
|
||||
alreadyPopulatedPartsData: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isForwardActionDisabled() {
|
||||
return (
|
||||
this.selectedGlassPartNumbers?.length !==
|
||||
this.PartsFromApi.partsOrQuestions?.length
|
||||
);
|
||||
return this.selectedGlassPartNumbers?.length !== this.PartsFromApi.partsOrQuestions?.length;
|
||||
},
|
||||
selectedGlassPartNumbers() {
|
||||
// Compile all selected parts from the page.
|
||||
|
|
@ -159,12 +152,12 @@ export default {
|
|||
p.description === ''
|
||||
? p.color
|
||||
: p.description,
|
||||
PartNumber: p.partNumber,
|
||||
},
|
||||
],
|
||||
PartNumber: p.partNumber
|
||||
}
|
||||
]
|
||||
});
|
||||
return arr;
|
||||
}, []),
|
||||
}, [])
|
||||
}));
|
||||
|
||||
return mappedData;
|
||||
|
|
@ -176,7 +169,7 @@ export default {
|
|||
|
||||
RefPrefix() {
|
||||
return 'partQuestion';
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.LoadInitialPartsData();
|
||||
|
|
@ -185,11 +178,9 @@ export default {
|
|||
arePagePrerequisitesValid() {
|
||||
// Check if isRepair is populated and if the pageData we need is here (Parts data)
|
||||
return (
|
||||
useMainStore().damage.isRepair != null &&
|
||||
useMainStore().pageData(issPageValues.VEHICLE_PARTS) &&
|
||||
Object.keys(
|
||||
useMainStore().pageData(issPageValues.VEHICLE_PARTS)
|
||||
).length !== 0
|
||||
useMainStore().damage.isRepair != null
|
||||
&& useMainStore().pageData(issPageValues.VEHICLE_PARTS)
|
||||
&& Object.keys(useMainStore().pageData(issPageValues.VEHICLE_PARTS)).length !== 0
|
||||
);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
|
|
@ -197,25 +188,19 @@ export default {
|
|||
|
||||
// Match them to the parts from the API.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const [key, value] of Object.entries(
|
||||
this.PartsFromApi.partsOrQuestions
|
||||
)) {
|
||||
for (const [key, value] of Object.entries(this.PartsFromApi.partsOrQuestions)) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const [partKey, partValue] of Object.entries(
|
||||
value.parts
|
||||
)) {
|
||||
for (const [partKey, partValue] of Object.entries(value.parts)) {
|
||||
const currentPart =
|
||||
this.PartsFromApi.partsOrQuestions[key].parts[partKey];
|
||||
|
||||
const isMatched = this.selectedGlassPartNumbers.some(
|
||||
(p) => p === currentPart.partNumber
|
||||
);
|
||||
const isMatched = this.selectedGlassPartNumbers.some((p) => p === currentPart.partNumber);
|
||||
|
||||
if (isMatched) {
|
||||
matchedParts.push({
|
||||
glassLocation: value.glassLocation,
|
||||
glassName: value.glassName,
|
||||
parts: [currentPart],
|
||||
parts: [currentPart]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -223,9 +208,7 @@ export default {
|
|||
// If no parts could be matched, throw an error (isForwardActionDisabled is based off of matchedParts)
|
||||
if (this.isForwardActionDisabled) {
|
||||
this.$refs.siteFooter.removeLoader();
|
||||
throw new Error(
|
||||
'Could not match any parts to the selected parts'
|
||||
);
|
||||
throw new Error('Could not match any parts to the selected parts');
|
||||
}
|
||||
|
||||
this.navigateForward(matchedParts, null);
|
||||
|
|
@ -251,8 +234,8 @@ export default {
|
|||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
Loading…
Reference in a new issue