CSR-762 Fix vehicle-parts preselecting issue
This commit is contained in:
parent
d7115f2ac6
commit
dcd35f1724
3 changed files with 51 additions and 25 deletions
|
|
@ -126,7 +126,6 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selectedValues: "",
|
|
||||||
lastValuePushedToGa: null,
|
lastValuePushedToGa: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -199,6 +198,14 @@ export default {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
selectedValues: {
|
||||||
|
get() {
|
||||||
|
return this.modelValue;
|
||||||
|
},
|
||||||
|
set(selectedAnswers) {
|
||||||
|
this.$emit("update:modelValue", selectedAnswers);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatString(str) {
|
formatString(str) {
|
||||||
|
|
@ -226,7 +233,6 @@ export default {
|
||||||
this.selectedValues = selectedAnswers;
|
this.selectedValues = selectedAnswers;
|
||||||
|
|
||||||
this.$emit("buttonQuestionChange", selectedAnswers);
|
this.$emit("buttonQuestionChange", selectedAnswers);
|
||||||
this.$emit("update:modelValue", selectedAnswers);
|
|
||||||
},
|
},
|
||||||
setLastValuePushedToGa(lastValuePushedToGa) {
|
setLastValuePushedToGa(lastValuePushedToGa) {
|
||||||
this.lastValuePushedToGa = lastValuePushedToGa;
|
this.lastValuePushedToGa = lastValuePushedToGa;
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@
|
||||||
altText=""
|
altText=""
|
||||||
isRequired
|
isRequired
|
||||||
:groupName="`${glassLocation}-${glassName}`"
|
:groupName="`${glassLocation}-${glassName}`"
|
||||||
:validationRules="tintValidationRules"
|
:validationRules="tintValidationRules">
|
||||||
>
|
|
||||||
<div class="row my-2" aria-live="polite">
|
<div class="row my-2" aria-live="polite">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<buttonQuestion
|
<buttonQuestion
|
||||||
|
|
@ -28,8 +27,9 @@
|
||||||
isRequired
|
isRequired
|
||||||
:groupName="`${glassLocation}-${glassName}-${selectedTint}`"
|
:groupName="`${glassLocation}-${glassName}-${selectedTint}`"
|
||||||
:validationRules="partValidationRules"
|
:validationRules="partValidationRules"
|
||||||
:shouldPushClickEventToGAOnMount="shouldPushClickEventToGAOnMount"
|
:shouldPushClickEventToGAOnMount="
|
||||||
/>
|
shouldPushClickEventToGAOnMount
|
||||||
|
" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</buttonQuestion>
|
</buttonQuestion>
|
||||||
|
|
@ -57,7 +57,7 @@ export default {
|
||||||
glassColorQuestion: "",
|
glassColorQuestion: "",
|
||||||
glassFeatureQuestion: "",
|
glassFeatureQuestion: "",
|
||||||
selectedTint: "",
|
selectedTint: "",
|
||||||
shouldPushClickEventToGAOnMount: true
|
shouldPushClickEventToGAOnMount: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -67,8 +67,8 @@ export default {
|
||||||
modelValue: Object,
|
modelValue: Object,
|
||||||
alreadyPopulatedPartsData: {
|
alreadyPopulatedPartsData: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => [],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.LoadPreselectedValues();
|
this.LoadPreselectedValues();
|
||||||
|
|
@ -79,12 +79,18 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
tintValidationRules() {
|
tintValidationRules() {
|
||||||
const validationRuleName = `${this.glassLocation}-${this.glassName}-tint-required`;
|
const validationRuleName = `${this.glassLocation}-${this.glassName}-tint-required`;
|
||||||
defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED));
|
defineRule(
|
||||||
|
validationRuleName,
|
||||||
|
required(errorMessages.OPTION_REQUIRED)
|
||||||
|
);
|
||||||
return validationRuleName;
|
return validationRuleName;
|
||||||
},
|
},
|
||||||
partValidationRules() {
|
partValidationRules() {
|
||||||
const validationRuleName = `${this.glassLocation}-${this.glassName}-part-required`;
|
const validationRuleName = `${this.glassLocation}-${this.glassName}-part-required`;
|
||||||
defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED));
|
defineRule(
|
||||||
|
validationRuleName,
|
||||||
|
required(errorMessages.OPTION_REQUIRED)
|
||||||
|
);
|
||||||
return validationRuleName;
|
return validationRuleName;
|
||||||
},
|
},
|
||||||
colorQuestionText() {
|
colorQuestionText() {
|
||||||
|
|
@ -115,16 +121,29 @@ export default {
|
||||||
return this.modelValue?.partNumber;
|
return this.modelValue?.partNumber;
|
||||||
},
|
},
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
this.$emit("update:modelValue", this.partsForSelectedTint.filter(part => part.partNumber == newValue)[0]);
|
this.$emit(
|
||||||
|
"update:modelValue",
|
||||||
|
this.partsForSelectedTint.filter(
|
||||||
|
(part) => part.partNumber == newValue
|
||||||
|
)[0]
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
partsForSelectedTint() {
|
partsForSelectedTint() {
|
||||||
const matchingGlass = this.PartDataFromApi.partsOrQuestions?.filter(dataForGlassLocationAndName =>
|
const matchingGlass = this.PartDataFromApi.partsOrQuestions?.filter(
|
||||||
dataForGlassLocationAndName.glassName == this.glassName &&
|
(dataForGlassLocationAndName) =>
|
||||||
dataForGlassLocationAndName.glassLocation == this.glassLocation);
|
dataForGlassLocationAndName.glassName == this.glassName &&
|
||||||
const matchingGlassParts = matchingGlass?.length == 1 ? matchingGlass[0].parts : [];
|
dataForGlassLocationAndName.glassLocation ==
|
||||||
return matchingGlassParts.filter(part => part.color == this.selectedTint) ?? [];
|
this.glassLocation
|
||||||
|
);
|
||||||
|
const matchingGlassParts =
|
||||||
|
matchingGlass?.length == 1 ? matchingGlass[0].parts : [];
|
||||||
|
return (
|
||||||
|
matchingGlassParts.filter(
|
||||||
|
(part) => part.color == this.selectedTint
|
||||||
|
) ?? []
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Creates a map of the feature list data in the correct Name/Value
|
// Creates a map of the feature list data in the correct Name/Value
|
||||||
|
|
@ -156,7 +175,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
PartDataFromApi() {
|
PartDataFromApi() {
|
||||||
return this.$store.getters.pageData(this.$route.query.fmgPage) ?? {};
|
return (
|
||||||
|
this.$store.getters.pageData(this.$route.query.fmgPage) ?? {}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -193,7 +214,8 @@ export default {
|
||||||
// Check if only a single part is present for the tint and set the v-model if it is.
|
// Check if only a single part is present for the tint and set the v-model if it is.
|
||||||
AutoSelectIfSinglePart() {
|
AutoSelectIfSinglePart() {
|
||||||
if (this.partsForSelectedTint?.length == 1) {
|
if (this.partsForSelectedTint?.length == 1) {
|
||||||
this.selectedPartNumber = this.partsForSelectedTint[0].partNumber;
|
this.selectedPartNumber =
|
||||||
|
this.partsForSelectedTint[0].partNumber;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -203,7 +225,7 @@ export default {
|
||||||
if (this.modelValue !== undefined) {
|
if (this.modelValue !== undefined) {
|
||||||
// Populate button-question model-value if parts data already exists in VueX
|
// Populate button-question model-value if parts data already exists in VueX
|
||||||
this.shouldPushClickEventToGAOnMount = false;
|
this.shouldPushClickEventToGAOnMount = false;
|
||||||
this.selectedTint = this.alreadyPopulatedPartsData.filter(part => part.partNumber === this.selectedPartNumber)[0]?.color;
|
this.selectedTint = this.modelValue?.color
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -211,8 +233,8 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
selectedTint() {
|
selectedTint() {
|
||||||
this.AutoSelectIfSinglePart();
|
this.AutoSelectIfSinglePart();
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,9 +204,7 @@ export default {
|
||||||
const partNumber = this.alreadyPopulatedPartsData[key].partNumber;
|
const partNumber = this.alreadyPopulatedPartsData[key].partNumber;
|
||||||
g.parts.forEach((p) => {
|
g.parts.forEach((p) => {
|
||||||
if (p.partNumber === partNumber) {
|
if (p.partNumber === partNumber) {
|
||||||
this.glassParts[g.glassLocation + "-" + g.glassName] = {
|
this.glassParts[g.glassLocation + "-" + g.glassName] = p;
|
||||||
[g.glassLocation]: [partNumber],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue