diff --git a/src/common-components/base-input-button/base-input-button.vue b/src/common-components/base-input-button/base-input-button.vue new file mode 100644 index 00000000..c0204058 --- /dev/null +++ b/src/common-components/base-input-button/base-input-button.vue @@ -0,0 +1,170 @@ + + + + + diff --git a/src/common-components/base-input-button/button-functionality-props,js b/src/common-components/base-input-button/button-functionality-props,js new file mode 100644 index 00000000..1faa369e --- /dev/null +++ b/src/common-components/base-input-button/button-functionality-props,js @@ -0,0 +1,30 @@ +export const inputButtonProps = { + value: { + type: [String, Number], + required: true, + }, + modelValue: { + type: [Array, String, Number], + required: true, + }, + isMultiSelect: Boolean, + groupName: { + type: String, + required: true, + }, + validationRules: { + type: String, + default: "", + }, + valueToLogType: String, + isRequired: { + type: Boolean, + default: true, + }, + lastValuePushedToGa: [String, Number], + setLastValuePushedToGa: Function, + selectingInitiatesLoad: { + type: Boolean, + default: false, + }, +}; diff --git a/src/global-methods.js b/src/global-methods.js index ce66babb..d7a91893 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -25,14 +25,6 @@ export default { headers: headers, }) .then((response) => { - if (logApiCall) { - analyticsMixIn.methods.pushEventToGA( - GaCategories.API_RESPONSE, - GaActions.RESULT, - `${GaLabels.SUCCESS}_${endpoint}`, - true - ); - } return resolve(response); }, diff --git a/src/helpers/button-question-focus-helper.js b/src/helpers/button-question-focus-helper.js new file mode 100644 index 00000000..427f2546 --- /dev/null +++ b/src/helpers/button-question-focus-helper.js @@ -0,0 +1,38 @@ +/** + * Helper for GA click event. When the user mouse clicks on a `base-input-button`, we + * push the click event. When the user tabs through a list of radio buttons via a + * keyboard, we only want to push the GA click event if the selection was deliberate + * (space/enter key) or if there is a selection and the user tabs off of the radio group. + */ + + let lastFocusedInputGroupName = ""; + let onButtonQuestionLostFocusCallback = null; + + const handleAnyComponentFocus = (e) => { + const targetType = e.target.type; + if (targetType !== "radio" && targetType !== "checkbox") { + invokeButtonQuestionLostFocusCallback(); + } + }; + + const handleButtonComponentFocus = (e) => { + if (e && lastFocusedInputGroupName !== e.groupName) { + invokeButtonQuestionLostFocusCallback(); + } + }; + + const handleInputComponentBlur = (e) => { + if (e) { + lastFocusedInputGroupName = e.groupName; + onButtonQuestionLostFocusCallback = e.onButtonQuestionLostFocusCallback; + } + }; + + const invokeButtonQuestionLostFocusCallback = () => { + if (onButtonQuestionLostFocusCallback) { + onButtonQuestionLostFocusCallback(); + } + }; + + export { handleAnyComponentFocus, handleButtonComponentFocus, handleInputComponentBlur }; + \ No newline at end of file diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue index c16c4ce6..b015907a 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue @@ -67,7 +67,7 @@ export default { ? this.answersFromCms.filter((ans) => { const name = ans.Name.split("-"); return ( - name[0].toUpperCase() === this.mainStore.getters.vehicle.category && + name[0].toUpperCase() === this.mainStore.vehicle.category && this.damageOptionsMap[name[1]] ); }) diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue index d340c442..e7884c9e 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue @@ -74,7 +74,7 @@ export default { ? this.answersFromCms.filter((ans) => { const name = ans.Name.split("-"); return this.filterByVehicleCategory - ? name[0].toUpperCase() === this.mainStore.getters.vehicle.category && + ? name[0].toUpperCase() === this.mainStore.vehicle.category && this.replaceOptions.includes(name[1]) : this.replaceOptions.includes(ans.Name); }) diff --git a/src/layouts/vehicle-damage/side-door-options/side-door-options.vue b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue index d4ba7f0a..5a44ccfb 100644 --- a/src/layouts/vehicle-damage/side-door-options/side-door-options.vue +++ b/src/layouts/vehicle-damage/side-door-options/side-door-options.vue @@ -132,7 +132,7 @@ export default { const filteredAnswers = Array.isArray(this.answersFromCms) ? this.answersFromCms.filter((ans) => { const name = ans.Name.split("-"); - return name[0].toUpperCase() === this.mainStore.getters.vehicle.category; + return name[0].toUpperCase() === this.mainStore.vehicle.category; }) : []; diff --git a/src/mixins/input-button-wrapper-mixin.js b/src/mixins/input-button-wrapper-mixin.js new file mode 100644 index 00000000..1d34d652 --- /dev/null +++ b/src/mixins/input-button-wrapper-mixin.js @@ -0,0 +1,40 @@ +import { inputButtonProps } from "@/common-components/base-input-button/button-functionality-props"; + +export default { + model: { + prop: "modelValue", + event: "change", + }, + props: { + ...inputButtonProps, + buttonLabel: [Number, String], + buttonLabelSubCopy: String, + buttonBodyCopy: String, + buttonAuxillaryCopy: String, + buttonFooterCopy: String, + buttonImage: String, + buttonImageId: String, + altText: { + type: String, + default: "", + }, + textPosition: String, + screenReaderOnlyText: String, + isWide: Boolean, + additionalButtonStyling: String, + }, + computed: { + selectedValue: { + get() { + return this.modelValue; + }, + set(e) { + if (this.preHandleAnswerChange) { + this.preHandleAnswerChange(e); + } + + this.$emit("update:modelValue", e); + }, + }, + }, +}; diff --git a/src/router/index.js b/src/router/index.js index 4c3f435e..0b886dd9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -60,10 +60,10 @@ router.afterEach((to, from) => { store.updateLastPageVisited(to.name); // Push page view to GA - analyticsMixin.methods.pushPageViewToGA(); + //analyticsMixin.methods.pushPageViewToGA(); // Push experiments to Data Layer - analyticsMixin.methods.pushExperimentsToDataLayer(); + //analyticsMixin.methods.pushExperimentsToDataLayer(); }); // Get route information by page name. diff --git a/src/store/index.js b/src/store/index.js index 07b3ca80..ae6bbd6e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -204,8 +204,8 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ methods: endpoints.GetDamageOptions.method, endpoint: `${endpoints.GetDamageOptions.url}/${carId}`, - }); payload: {}, + }); }, setVehicle() { return globalMethods @@ -215,13 +215,17 @@ export const useMainStore = defineStore({ payload: {}, }) .then((response) => { - updateVehicle(response.vehicle); + this.updateVehicle(response.data); return response; }); }, updateVehicle(vehicle) { - this.order.vehicle = { ...this.order.vehicle, ...vehicle }; + this.order.vehicle.carId = vehicle.carId; + this.order.vehicle.category = vehicle.category; + this.order.vehicle.imageUrl = vehicle.imageUrl; + this.order.vehicle.imageVifNumber = vehicle.imageVifNumber; + this.order.vehicle.imageColor = vehicle.imageColor; }, resetVehicleState() diff --git a/src/ux-components/list-card/list-card.vue b/src/ux-components/list-card/list-card.vue index eb2897b2..9b68ab38 100644 --- a/src/ux-components/list-card/list-card.vue +++ b/src/ux-components/list-card/list-card.vue @@ -1,399 +1,254 @@ - - + + - \ No newline at end of file +} +