Vehicle parts linting

This commit is contained in:
Josh Dassinger 2024-05-30 09:45:39 -05:00
parent 4f14fa0612
commit c22a4fc09f

View file

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