CSR-762 Push correct value on vehicle-parts nested question
This commit is contained in:
parent
42eac1d08a
commit
b4a0024912
4 changed files with 31 additions and 3 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
import { useField } from "vee-validate";
|
import { useField } from "vee-validate";
|
||||||
import { toRef } from "vue";
|
import { toRef } from "vue";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
import inputButtonWrapperMixin from "../../mixins/input-button-wrapper-mixin";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "base-input-button",
|
name: "base-input-button",
|
||||||
|
|
@ -35,6 +36,7 @@ export default {
|
||||||
event: "change",
|
event: "change",
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
// ...inputButtonWrapperMixin.props
|
||||||
value: {
|
value: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
required: true,
|
required: true,
|
||||||
|
|
@ -62,6 +64,7 @@ export default {
|
||||||
isRequired: Boolean,
|
isRequired: Boolean,
|
||||||
lastValuePushedToGa: [String, Number],
|
lastValuePushedToGa: [String, Number],
|
||||||
setLastValuePushedToGa: Function,
|
setLastValuePushedToGa: Function,
|
||||||
|
shouldPushClickEventToGAOnMount: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -69,12 +72,23 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
console.log("mounted: ", {
|
||||||
|
isChecked: this.isChecked
|
||||||
|
})
|
||||||
if (this.isChecked) {
|
if (this.isChecked) {
|
||||||
this.handleChange(this.modelValue);
|
// if (this.shouldPushClickEventToGAOnMount) {
|
||||||
|
// this.handleEventAction(this.eventTypes.MOUNT)
|
||||||
|
// } else {
|
||||||
|
this.handleChange(this.modelValue);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleEventAction(eventType, e) {
|
handleEventAction(eventType, e) {
|
||||||
|
console.log("handleEventAction: ", {
|
||||||
|
eventType,
|
||||||
|
value: this.value,
|
||||||
|
});
|
||||||
if (this.isMultiSelect) {
|
if (this.isMultiSelect) {
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
case this.eventTypes.ENTER:
|
case this.eventTypes.ENTER:
|
||||||
|
|
@ -90,6 +104,7 @@ export default {
|
||||||
case this.eventTypes.CLICK:
|
case this.eventTypes.CLICK:
|
||||||
case this.eventTypes.ENTER:
|
case this.eventTypes.ENTER:
|
||||||
case this.eventTypes.SPACE:
|
case this.eventTypes.SPACE:
|
||||||
|
case this.eventTypes.MOUNT:
|
||||||
this.handleClick(e);
|
this.handleClick(e);
|
||||||
this.handlePushClickEventToGACheck(
|
this.handlePushClickEventToGACheck(
|
||||||
this.eventTypes.CLICK
|
this.eventTypes.CLICK
|
||||||
|
|
@ -189,6 +204,7 @@ export default {
|
||||||
ENTER: "enter",
|
ENTER: "enter",
|
||||||
SPACE: "space",
|
SPACE: "space",
|
||||||
CLICK: "click",
|
CLICK: "click",
|
||||||
|
MOUNT: "mount"
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@
|
||||||
:selectOnKeypress="selectOnKeypress"
|
:selectOnKeypress="selectOnKeypress"
|
||||||
:lastValuePushedToGa="lastValuePushedToGa"
|
:lastValuePushedToGa="lastValuePushedToGa"
|
||||||
:setLastValuePushedToGa="setLastValuePushedToGa"
|
:setLastValuePushedToGa="setLastValuePushedToGa"
|
||||||
|
:shouldPushClickEventToGAOnMount="shouldPushClickEventToGAOnMount"
|
||||||
@inputButtonClicked="handleAnswerChange" />
|
@inputButtonClicked="handleAnswerChange" />
|
||||||
<!-- For nested questions -->
|
<!-- For nested questions -->
|
||||||
<transition name="fade" mode="out-in">
|
<transition name="fade" mode="out-in">
|
||||||
|
|
@ -121,6 +122,7 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
shouldPushClickEventToGAOnMount: Boolean
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
isRequired
|
isRequired
|
||||||
:groupName="`${glassLocation}-${glassName}-${selectedTint}`"
|
:groupName="`${glassLocation}-${glassName}-${selectedTint}`"
|
||||||
:validationRules="partValidationRules"
|
:validationRules="partValidationRules"
|
||||||
|
:shouldPushClickEventToGAOnMount="shouldPushClickEventToGAOnMount"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -56,6 +57,7 @@ export default {
|
||||||
glassColorQuestion: "",
|
glassColorQuestion: "",
|
||||||
glassFeatureQuestion: "",
|
glassFeatureQuestion: "",
|
||||||
selectedTint: "",
|
selectedTint: "",
|
||||||
|
shouldPushClickEventToGAOnMount: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -110,7 +112,7 @@ export default {
|
||||||
|
|
||||||
selectedPartNumber: {
|
selectedPartNumber: {
|
||||||
get() {
|
get() {
|
||||||
return this.modelValue?.partNumber;
|
return this.modelValue ? this.modelValue[this.glassLocation][0] : undefined;
|
||||||
},
|
},
|
||||||
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]);
|
||||||
|
|
@ -198,9 +200,16 @@ export default {
|
||||||
// Loads the preselected values from the store.
|
// Loads the preselected values from the store.
|
||||||
LoadPreselectedValues() {
|
LoadPreselectedValues() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
console.log("LoadPreselectedValues: ", {
|
||||||
|
modelValue: this.modelValue,
|
||||||
|
alreadyPopulatedPartsData: this.alreadyPopulatedPartsData,
|
||||||
|
selectedPartNumber: this.selectedPartNumber
|
||||||
|
})
|
||||||
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.selectedTint = this.alreadyPopulatedPartsData.filter(part => part.partNumber === this.selectedPartNumber)[0]?.color;
|
this.selectedTint = this.alreadyPopulatedPartsData.filter(part => part.partNumber === this.selectedPartNumber)[0]?.color;
|
||||||
|
console.log({color: this.selectedTint})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ export default {
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
lastValuePushedToGa: [String, Number],
|
lastValuePushedToGa: [String, Number],
|
||||||
setLastValuePushedToGa: Function
|
setLastValuePushedToGa: Function,
|
||||||
|
shouldPushClickEventToGAOnMount: Boolean
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleAnswerChange(e) {
|
handleAnswerChange(e) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue