CSR-762 Fix for YMMS list-button keypresses
This commit is contained in:
parent
854300d677
commit
24ddb9f8a5
16 changed files with 216 additions and 184 deletions
|
|
@ -53,7 +53,9 @@
|
||||||
:modelValue="modelValue"
|
:modelValue="modelValue"
|
||||||
selectingInitiatesLoad
|
selectingInitiatesLoad
|
||||||
:isWide="isWide"
|
:isWide="isWide"
|
||||||
@change="(e) => handleAnswerChange(e)"
|
:validationRules="validationRules"
|
||||||
|
:textPosition="textPosition"
|
||||||
|
@change="handleAnswerChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- <component
|
<!-- <component
|
||||||
|
|
@ -269,7 +271,6 @@ export default {
|
||||||
listCard,
|
listCard,
|
||||||
ErrorMessage,
|
ErrorMessage,
|
||||||
radio,
|
radio,
|
||||||
// testButton,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<label :class="[ buttonWrapperClasses, { 'has-error': errors.length > 0 || hasError }]" :for="buttonId">
|
<label
|
||||||
|
:class="[buttonWrapperClasses, { 'has-error': errors.length > 0 }]"
|
||||||
|
:for="buttonId"
|
||||||
|
@mouseup.left="handleClick"
|
||||||
|
>
|
||||||
<!-- classes: {{classes}}<br/>
|
<!-- classes: {{classes}}<br/>
|
||||||
value: {{value}} <br/>
|
value: {{value}} <br/>
|
||||||
modelValue: {{modelValue}} <br/>
|
modelValue: {{modelValue}} <br/>
|
||||||
|
|
@ -12,7 +16,9 @@
|
||||||
:aria-required="isRequired"
|
:aria-required="isRequired"
|
||||||
:value="value"
|
:value="value"
|
||||||
:checked="isChecked"
|
:checked="isChecked"
|
||||||
@change="handleSelectionChange"
|
@keypress="handleSelectionChange"
|
||||||
|
@keypress.enter="handleClick"
|
||||||
|
@keypress.space="handleClick"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
|
@ -25,7 +31,7 @@ import { useField } from "vee-validate";
|
||||||
import { toRef } from "vue";
|
import { toRef } from "vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "button-wrapper",
|
name: "input-button-wrapper",
|
||||||
emits: ["change"],
|
emits: ["change"],
|
||||||
model: {
|
model: {
|
||||||
prop: "modelValue",
|
prop: "modelValue",
|
||||||
|
|
@ -60,11 +66,19 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
validationRules: String,
|
validationRules: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
buttonWrapperClasses: [String, Array, Object],
|
buttonWrapperClasses: [String, Array, Object],
|
||||||
inputClasses: [String, Array, Object],
|
inputClasses: [String, Array, Object],
|
||||||
valueToLogType: String,
|
valueToLogType: String,
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
valueToEmit: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSelectionChange(event) {
|
handleSelectionChange(event) {
|
||||||
// console.log(event);
|
// console.log(event);
|
||||||
|
|
@ -72,7 +86,7 @@ export default {
|
||||||
// console.log(this.modelValue);
|
// console.log(this.modelValue);
|
||||||
let isChecked = event.target.checked;
|
let isChecked = event.target.checked;
|
||||||
// console.log("BM value: ", this.value);
|
// console.log("BM value: ", this.value);
|
||||||
let valueToEmit;
|
// let valueToEmit;
|
||||||
if (this.isMultiSelect && this.modelValue instanceof Array) {
|
if (this.isMultiSelect && this.modelValue instanceof Array) {
|
||||||
let newValue = [...this.modelValue];
|
let newValue = [...this.modelValue];
|
||||||
if (isChecked && !this.modelValue.includes(this.value)) {
|
if (isChecked && !this.modelValue.includes(this.value)) {
|
||||||
|
|
@ -81,16 +95,25 @@ export default {
|
||||||
newValue.splice(newValue.indexOf(this.value), 1);
|
newValue.splice(newValue.indexOf(this.value), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
valueToEmit = newValue;
|
this.valueToEmit = newValue;
|
||||||
} else {
|
} else {
|
||||||
valueToEmit = this.value;
|
this.valueToEmit = this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log("ButtonWrapper is emitting: ", valueToEmit);
|
// console.log("ButtonWrapper is emitting: ", valueToEmit);
|
||||||
this.$emit("change", valueToEmit);
|
|
||||||
|
console.log("Not emitting");
|
||||||
|
this.handleChange(this.valueToEmit);
|
||||||
|
|
||||||
this.pushClickEventToGA();
|
this.pushClickEventToGA();
|
||||||
},
|
},
|
||||||
|
handleClick(e) {
|
||||||
|
console.log("emitting");
|
||||||
|
console.log(e);
|
||||||
|
this.handleSelectionChange(e);
|
||||||
|
console.log(this.valueToEmit)
|
||||||
|
this.$emit("change", this.valueToEmit);
|
||||||
|
},
|
||||||
pushClickEventToGA() {
|
pushClickEventToGA() {
|
||||||
this.pushEventToGA(
|
this.pushEventToGA(
|
||||||
this.$route.query[queryStrings.FMG_PAGE],
|
this.$route.query[queryStrings.FMG_PAGE],
|
||||||
|
|
@ -119,8 +142,8 @@ export default {
|
||||||
const inputType = props.isMultiSelect ? "checkbox" : "radio";
|
const inputType = props.isMultiSelect ? "checkbox" : "radio";
|
||||||
|
|
||||||
const fieldOptions = {
|
const fieldOptions = {
|
||||||
// type: inputType,
|
type: inputType,
|
||||||
// checkedValue: props.value,
|
checkedValue: props.value,
|
||||||
// potentialInitialValue: props.selectedValues,
|
// potentialInitialValue: props.selectedValues,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -134,6 +157,14 @@ export default {
|
||||||
// fieldOptions["initialValue"] = fieldOptions.potentialInitialValue;
|
// fieldOptions["initialValue"] = fieldOptions.potentialInitialValue;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// const { handleChange, errors, value } = useField(
|
||||||
|
// toRef(props, "groupName"),
|
||||||
|
// toRef(props, "validationRules"),
|
||||||
|
// fieldOptions
|
||||||
|
// );
|
||||||
|
|
||||||
|
console.log(props.validationRules);
|
||||||
|
|
||||||
const { handleChange, errors, value } = useField(
|
const { handleChange, errors, value } = useField(
|
||||||
toRef(props, "groupName"),
|
toRef(props, "groupName"),
|
||||||
toRef(props, "validationRules"),
|
toRef(props, "validationRules"),
|
||||||
|
|
@ -152,7 +183,8 @@ export default {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<!-- TODO KO Scope this? -->
|
||||||
|
<style lang="scss">
|
||||||
input {
|
input {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
height: 0.1px; // NOTE: cannot be zero or Safari can't put focus on it
|
height: 0.1px; // NOTE: cannot be zero or Safari can't put focus on it
|
||||||
|
|
@ -43,12 +43,12 @@ export default ({
|
||||||
initializeComponent(replaceOptions){
|
initializeComponent(replaceOptions){
|
||||||
this.replaceOptions = replaceOptions;
|
this.replaceOptions = replaceOptions;
|
||||||
},
|
},
|
||||||
updateSelectedValues() {
|
// updateSelectedValues() {
|
||||||
// UPDATE SELECTEDVALUES IF ONLY ONE ANSWER
|
// // UPDATE SELECTEDVALUES IF ONLY ONE ANSWER
|
||||||
if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1) {
|
// if(Array.isArray(this.answersToDisplay) && this.answersToDisplay.length === 1) {
|
||||||
this.selectedValues = [this.answersToDisplay[0].Name];
|
// this.selectedValues = [this.answersToDisplay[0].Name];
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
questionText(){
|
questionText(){
|
||||||
|
|
@ -57,14 +57,14 @@ export default ({
|
||||||
answersFromCms(){
|
answersFromCms(){
|
||||||
return this.getCmsContent(this.cmsWidgetName, 'Answers');
|
return this.getCmsContent(this.cmsWidgetName, 'Answers');
|
||||||
},
|
},
|
||||||
selectedValues: {
|
// selectedValues: {
|
||||||
get: function() {
|
// get: function() {
|
||||||
return this.modelValue;
|
// return this.modelValue;
|
||||||
},
|
// },
|
||||||
set: function(newValue) {
|
// set: function(newValue) {
|
||||||
this.$emit("update:modelValue", newValue);
|
// this.$emit("update:modelValue", newValue);
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
answersToDisplay(){
|
answersToDisplay(){
|
||||||
const filteredAnswers = Array.isArray(this.answersFromCms)
|
const filteredAnswers = Array.isArray(this.answersFromCms)
|
||||||
? this.answersFromCms.filter(ans =>
|
? this.answersFromCms.filter(ans =>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<Form
|
<Form
|
||||||
@submit="onSubmit"
|
@submit.prevent="onSubmit"
|
||||||
@invalid-submit="onInvalidSubmit"
|
@invalid-submit="onInvalidSubmit"
|
||||||
ref="theForm"
|
ref="theForm"
|
||||||
v-slot="{ meta }"
|
v-slot="{ meta }"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
:answers="makes"
|
:answers="makes"
|
||||||
groupName="ChooseVehicleMake"
|
groupName="ChooseVehicleMake"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
v-model="selectedMake"
|
v-model="selectedValue"
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -18,17 +18,17 @@ import buttonQuestion from "@/common-components/button-question/button-question"
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import buttonQuestionWrapperMixin from "../../../mixins/button-question-wrapper-mixin";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "make-question",
|
name: "make-question",
|
||||||
|
mixins: [buttonQuestionWrapperMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
makes: [],
|
makes: [],
|
||||||
selectedMake: null
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
modelValue: String,
|
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -50,10 +50,5 @@ export default {
|
||||||
this.makes = initialData;
|
this.makes = initialData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
selectedMake(selectedMake) {
|
|
||||||
this.$emit("update:modelValue", selectedMake)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
:answers="models"
|
:answers="models"
|
||||||
groupName="ChooseVehicleModel"
|
groupName="ChooseVehicleModel"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
v-model="selectedModel"
|
v-model="selectedValue"
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -18,17 +18,17 @@ import buttonQuestion from "@/common-components/button-question/button-question"
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import buttonQuestionWrapperMixin from "@/mixins/button-question-wrapper-mixin";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "model-question",
|
name: "model-question",
|
||||||
|
mixins: [buttonQuestionWrapperMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
models: [],
|
models: [],
|
||||||
selectedModel: null
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
modelValue: String,
|
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -50,10 +50,5 @@ export default {
|
||||||
this.models = initialData;
|
this.models = initialData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
selectedModel(selectedModel) {
|
|
||||||
this.$emit("update:modelValue", selectedModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
:answers="styles"
|
:answers="styles"
|
||||||
groupName="ChooseVehicleStyle"
|
groupName="ChooseVehicleStyle"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
v-model="selectedStyle"
|
v-model="selectedValue"
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -18,17 +18,17 @@ import buttonQuestion from "@/common-components/button-question/button-question"
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import buttonQuestionWrapperMixin from "@/mixins/button-question-wrapper-mixin";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "style-question",
|
name: "style-question",
|
||||||
|
mixins: [buttonQuestionWrapperMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
styles: [],
|
styles: [],
|
||||||
selectedStyle: null
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
modelValue: String,
|
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -54,10 +54,5 @@ export default {
|
||||||
this.styles = initialData;
|
this.styles = initialData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
selectedStyle(selectedStyle) {
|
|
||||||
this.$emit("update:modelValue", selectedStyle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ export default {
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
selectedYear(year) {
|
selectedYear(year) {
|
||||||
|
console.log("selectedYear: ", year)
|
||||||
const parsedYear = parseInt(year);
|
const parsedYear = parseInt(year);
|
||||||
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
|
this.dispatchStoreAction(storeActions.SAVE_VEHICLE_YEAR, parsedYear);
|
||||||
this.$router.navigateWithSaving(
|
this.$router.navigateWithSaving(
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
:answers="years"
|
:answers="years"
|
||||||
groupName="ChooseVehicleYear"
|
groupName="ChooseVehicleYear"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
v-model="selectedYear"
|
v-model="selectedValue"
|
||||||
isRequired
|
isRequired
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -19,20 +19,21 @@ import buttonQuestion from "@/common-components/button-question/button-question"
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import buttonQuestionWrapperMixin from "@/mixins/button-question-wrapper-mixin";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "year-question",
|
name: "year-question",
|
||||||
|
mixins: [buttonQuestionWrapperMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
years: [],
|
years: [],
|
||||||
selectedYear: null,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
modelValue: String,
|
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
buttonQuestion,
|
buttonQuestion
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
questionText() {
|
questionText() {
|
||||||
|
|
@ -50,10 +51,5 @@ export default {
|
||||||
this.years = initialData;
|
this.years = initialData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
selectedYear(selectedYear) {
|
|
||||||
this.$emit("update:modelValue", selectedYear)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default {
|
||||||
savePageDataToStore(page, data) {
|
savePageDataToStore(page, data) {
|
||||||
store.commit(storeMutations.UPDATE_PAGE_DATA, { page: page, data: data });
|
store.commit(storeMutations.UPDATE_PAGE_DATA, { page: page, data: data });
|
||||||
},
|
},
|
||||||
onSubmit() { }, // DO NOT REMOVE; needed to prevent default form submit behavior
|
// onSubmit() { }, // DO NOT REMOVE; needed to prevent default form submit behavior
|
||||||
onInvalidSubmit({ values, errors, results }) {
|
onInvalidSubmit({ values, errors, results }) {
|
||||||
// identify the first error field and put focus on it
|
// identify the first error field and put focus on it
|
||||||
// get error names array
|
// get error names array
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
|
|
||||||
};
|
|
||||||
16
src/mixins/button-question-wrapper-mixin.js
Normal file
16
src/mixins/button-question-wrapper-mixin.js
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
modelValue: String,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
selectedValue: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
selectedValue(selectedValue) {
|
||||||
|
console.log("selectedValue: ", selectedValue)
|
||||||
|
this.$emit("update:modelValue", selectedValue);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -3,7 +3,7 @@ html {
|
||||||
&.list-button,
|
&.list-button,
|
||||||
&.list-card,
|
&.list-card,
|
||||||
&.list-card.list-button {
|
&.list-card.list-button {
|
||||||
border: none;
|
// border: none;
|
||||||
color: $red;
|
color: $red;
|
||||||
input[type=checkbox]:focus + label,
|
input[type=checkbox]:focus + label,
|
||||||
input[type=radio]:focus + label {
|
input[type=radio]:focus + label {
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@
|
||||||
LB modelValue: {{ modelValue }}
|
LB modelValue: {{ modelValue }}
|
||||||
LB groupName: {{ groupName }} -->
|
LB groupName: {{ groupName }} -->
|
||||||
<!-- , {'has-error': errors.length > 0 || hasError} -->
|
<!-- , {'has-error': errors.length > 0 || hasError} -->
|
||||||
<!-- <buttonWrapper
|
<!-- <inputButtonWrapper
|
||||||
v-bind="$props"
|
v-bind="$props"
|
||||||
:classes="['list-group list-button rounded-3 d-flex flex-column w-100 mb-2', {'has-error': errors.length > 0 || hasError}]"
|
:classes="['list-group list-button rounded-3 d-flex flex-column w-100 mb-2', {'has-error': errors.length > 0 || hasError}]"
|
||||||
@change="(e) => $emit('change', e)"
|
@change="(e) => $emit('change', e)"
|
||||||
> -->
|
> -->
|
||||||
|
|
||||||
<buttonWrapper
|
<inputButtonWrapper
|
||||||
:isMultiSelect="isMultiSelect"
|
:isMultiSelect="isMultiSelect"
|
||||||
:modelValue="modelValue"
|
:modelValue="modelValue"
|
||||||
:value="value"
|
:value="value"
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
:class="[this.loaderColor, this.loaderPosition]"
|
:class="[this.loaderColor, this.loaderPosition]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</buttonWrapper>
|
</inputButtonWrapper>
|
||||||
<!-- </label> -->
|
<!-- </label> -->
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -65,13 +65,10 @@
|
||||||
// import { useField } from "vee-validate";
|
// import { useField } from "vee-validate";
|
||||||
// import { toRef } from "vue";
|
// import { toRef } from "vue";
|
||||||
import loader from "@/ux-components/loader/loader";
|
import loader from "@/ux-components/loader/loader";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import inputButtonWrapper from "@/common-components/input-button-wrapper/input-button-wrapper";
|
||||||
import buttonMixin from "@/mixins/button-mixin";
|
|
||||||
import buttonWrapper from "@/common-components/button-wrapper/button-wrapper";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "listButton",
|
name: "listButton",
|
||||||
mixins: [buttonMixin],
|
|
||||||
props: {
|
props: {
|
||||||
// groupName: String,
|
// groupName: String,
|
||||||
buttonLabel: [Number, String],
|
buttonLabel: [Number, String],
|
||||||
|
|
@ -120,10 +117,18 @@ export default {
|
||||||
this.isLoaderDisplayed = true;
|
this.isLoaderDisplayed = true;
|
||||||
},
|
},
|
||||||
handleAnswerChange(e) {
|
handleAnswerChange(e) {
|
||||||
|
// TODO KO make it work on YMMS with keypresses
|
||||||
|
// There must be a way to tell the difference between keypress and
|
||||||
|
// submit via veevalidate. Check out the Form in vehicle-damage
|
||||||
if (this.selectingInitiatesLoad) {
|
if (this.selectingInitiatesLoad) {
|
||||||
this.displayLoader();
|
this.displayLoader();
|
||||||
}
|
}
|
||||||
console.log("lbTest event: ", e);
|
// else {
|
||||||
|
// console.log("lbTest event: ", e);
|
||||||
|
// // this.$emit("change", e);
|
||||||
|
// }
|
||||||
|
|
||||||
|
console.log(e)
|
||||||
this.$emit("change", e);
|
this.$emit("change", e);
|
||||||
},
|
},
|
||||||
// handleInputChange() {
|
// handleInputChange() {
|
||||||
|
|
@ -143,14 +148,14 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO KO THIS IS IMPORTANT
|
// TODO KO THIS IS IMPORTANT
|
||||||
// Move this to button-wrapper?
|
// Move this to input-button-wrapper?
|
||||||
this.pushEventToGA(
|
// this.pushEventToGA(
|
||||||
this.$route.query[queryStrings.FMG_PAGE],
|
// this.$route.query[queryStrings.FMG_PAGE],
|
||||||
this.GaActions.CLICKED,
|
// this.GaActions.CLICKED,
|
||||||
this.value.toString(),
|
// this.value.toString(),
|
||||||
true,
|
// true,
|
||||||
this.valueToLogType
|
// this.valueToLogType
|
||||||
);
|
// );
|
||||||
},
|
},
|
||||||
// handleCheckChange() {
|
// handleCheckChange() {
|
||||||
// const emitEvent = {
|
// const emitEvent = {
|
||||||
|
|
@ -166,7 +171,7 @@ export default {
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
loader,
|
loader,
|
||||||
buttonWrapper,
|
inputButtonWrapper,
|
||||||
},
|
},
|
||||||
// setup(props) {
|
// setup(props) {
|
||||||
// const inputType = props.isMultiSelect ? "checkbox" : "radio";
|
// const inputType = props.isMultiSelect ? "checkbox" : "radio";
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<buttonWrapper
|
<inputButtonWrapper
|
||||||
:buttonWrapperClasses="[
|
:buttonWrapperClasses="[
|
||||||
'list-card w-100 rounded-3 d-flex align-items-center h-100',
|
'list-card w-100 rounded-3 d-flex align-items-center h-100',
|
||||||
{ 'horizontal': isWide, 'has-error': errors.length > 0 || hasError }
|
{ 'horizontal': isWide }
|
||||||
]"
|
]"
|
||||||
:isMultiSelect="isMultiSelect"
|
:isMultiSelect="isMultiSelect"
|
||||||
:modelValue="modelValue"
|
:modelValue="modelValue"
|
||||||
:value="value"
|
:value="value"
|
||||||
:groupName="groupName"
|
:groupName="groupName"
|
||||||
|
:validationRules="validationRules"
|
||||||
@change="handleAnswerChange"
|
@change="handleAnswerChange"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
@ -65,19 +66,19 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- </div>
|
<!-- </div>
|
||||||
</div> -->
|
</div> -->
|
||||||
</buttonWrapper>
|
</inputButtonWrapper>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
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 buttonWrapper from "@/common-components/button-wrapper/button-wrapper";
|
import inputButtonWrapper from "@/common-components/input-button-wrapper/input-button-wrapper";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "listCard",
|
name: "listCard",
|
||||||
components: {
|
components: {
|
||||||
buttonWrapper
|
inputButtonWrapper
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
isMultiSelect: Boolean, //Defines use as checkbox
|
isMultiSelect: Boolean, //Defines use as checkbox
|
||||||
|
|
@ -97,29 +98,29 @@ export default {
|
||||||
},
|
},
|
||||||
// colLength: String,
|
// colLength: String,
|
||||||
validationRules: String,
|
validationRules: String,
|
||||||
selectedValues: [Array, String],
|
// selectedValues: [Array, String],
|
||||||
hasError: Boolean,
|
// hasError: Boolean,
|
||||||
valueToLogType: String,
|
valueToLogType: String,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
checkValue: null,
|
// checkValue: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
// mounted() {
|
||||||
if (Array.isArray(this.validateValue)) {
|
// if (Array.isArray(this.validateValue)) {
|
||||||
this.checkValue = this.isValueSelectedByArray(this.selectedValues);
|
// this.checkValue = this.isValueSelectedByArray(this.selectedValues);
|
||||||
const isSelectedByValidator = this.isValueSelectedByArray(
|
// const isSelectedByValidator = this.isValueSelectedByArray(
|
||||||
this.validateValue
|
// this.validateValue
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (this.checkValue != isSelectedByValidator) {
|
// if (this.checkValue != isSelectedByValidator) {
|
||||||
this.handleChange(this.value);
|
// this.handleChange(this.value);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
this.checkValue = this.selectedValues == this.value;
|
// this.checkValue = this.selectedValues == this.value;
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
computed: {
|
computed: {
|
||||||
getLabelClasses() {
|
getLabelClasses() {
|
||||||
if (this.isWide) {
|
if (this.isWide) {
|
||||||
|
|
@ -134,47 +135,47 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isValueSelectedByArray(arr) {
|
// isValueSelectedByArray(arr) {
|
||||||
return this.isMultiSelect ? arr.includes(this.value) : arr[0];
|
// return this.isMultiSelect ? arr.includes(this.value) : arr[0];
|
||||||
},
|
// },
|
||||||
handleInputChange() {
|
// handleInputChange() {
|
||||||
if (!this.selectingInitiatesLoad) {
|
// if (!this.selectingInitiatesLoad) {
|
||||||
this.handleCheckChange();
|
// this.handleCheckChange();
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
handleKeyupArrow() {
|
// handleKeyupArrow() {
|
||||||
if (this.isMultiSelect) {
|
// if (this.isMultiSelect) {
|
||||||
return; // Prevent arrow keys from doing anything if element is a checkbox
|
// return; // Prevent arrow keys from doing anything if element is a checkbox
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!this.selectingInitiatesLoad) {
|
// if (!this.selectingInitiatesLoad) {
|
||||||
this.handleCheckChange();
|
// this.handleCheckChange();
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
triggerButton() {
|
// triggerButton() {
|
||||||
if (this.selectingInitiatesLoad) {
|
// if (this.selectingInitiatesLoad) {
|
||||||
this.displayLoader();
|
// this.displayLoader();
|
||||||
this.handleCheckChange();
|
// this.handleCheckChange();
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.pushEventToGA(
|
// this.pushEventToGA(
|
||||||
this.$route.query[queryStrings.FMG_PAGE],
|
// this.$route.query[queryStrings.FMG_PAGE],
|
||||||
this.GaActions.CLICKED,
|
// this.GaActions.CLICKED,
|
||||||
this.value.toString(),
|
// this.value.toString(),
|
||||||
true,
|
// true,
|
||||||
this.valueToLogType
|
// this.valueToLogType
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
handleCheckChange() {
|
// handleCheckChange() {
|
||||||
const emitEvent = {
|
// const emitEvent = {
|
||||||
checkValue: this.checkValue, // only read on checkboxes, on handleCheckedChanged on button-question
|
// checkValue: this.checkValue, // only read on checkboxes, on handleCheckedChanged on button-question
|
||||||
value: this.value.toString(),
|
// value: this.value.toString(),
|
||||||
buttonId: this.buttonID && this.buttonID.toString(),
|
// buttonId: this.buttonID && this.buttonID.toString(),
|
||||||
};
|
// };
|
||||||
|
|
||||||
this.handleChange(this.value);
|
// this.handleChange(this.value);
|
||||||
this.$emit("isCheckedChanged", emitEvent);
|
// this.$emit("isCheckedChanged", emitEvent);
|
||||||
},
|
// },
|
||||||
handleAnswerChange(e) {
|
handleAnswerChange(e) {
|
||||||
this.$emit("change", e);
|
this.$emit("change", e);
|
||||||
},
|
},
|
||||||
|
|
@ -182,49 +183,49 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
// Changing this will impact pre-selection data loads on vehicle-parts.
|
// Changing this will impact pre-selection data loads on vehicle-parts.
|
||||||
// If changed, please regression test that vehicle-parts data still loads correctly with previous selections.
|
// If changed, please regression test that vehicle-parts data still loads correctly with previous selections.
|
||||||
selectedValues(newVal) {
|
// selectedValues(newVal) {
|
||||||
if (typeof newVal === "string") {
|
// if (typeof newVal === "string") {
|
||||||
this.checkValue = newVal == this.value;
|
// this.checkValue = newVal == this.value;
|
||||||
} else if (newVal !== undefined) {
|
// } else if (newVal !== undefined) {
|
||||||
this.checkValue = newVal.value;
|
// this.checkValue = newVal.value;
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
setup(props) {
|
// setup(props) {
|
||||||
const inputType = props.isMultiSelect ? "checkbox" : "radio";
|
// const inputType = props.isMultiSelect ? "checkbox" : "radio";
|
||||||
|
|
||||||
const fieldOptions = {
|
// const fieldOptions = {
|
||||||
type: inputType,
|
// type: inputType,
|
||||||
checkedValue: props.value, // EX: "Single" or "Passenger"
|
// checkedValue: props.value, // EX: "Single" or "Passenger"
|
||||||
potentialInitialValue: props.selectedValues,
|
// potentialInitialValue: props.selectedValues,
|
||||||
};
|
// };
|
||||||
|
|
||||||
// Set initialValue for validation setup if pre-selected
|
// // Set initialValue for validation setup if pre-selected
|
||||||
// NOTE: props.selectedValues could be an array of strings, or an array of integers...
|
// // NOTE: props.selectedValues could be an array of strings, or an array of integers...
|
||||||
if (
|
// if (
|
||||||
props.selectedValues &&
|
// props.selectedValues &&
|
||||||
(props.selectedValues.includes(props.value) ||
|
// (props.selectedValues.includes(props.value) ||
|
||||||
props.selectedValues.includes(parseInt(props.value)))
|
// props.selectedValues.includes(parseInt(props.value)))
|
||||||
) {
|
// ) {
|
||||||
fieldOptions["initialValue"] = fieldOptions.potentialInitialValue;
|
// fieldOptions["initialValue"] = fieldOptions.potentialInitialValue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const { handleChange, errors, value } = useField(
|
// const { handleChange, errors, value } = useField(
|
||||||
toRef(props, "groupName"),
|
// toRef(props, "groupName"),
|
||||||
toRef(props, "validationRules"),
|
// toRef(props, "validationRules"),
|
||||||
fieldOptions
|
// fieldOptions
|
||||||
);
|
// );
|
||||||
|
|
||||||
// First land on the blank, unselected page, no handleChange
|
// // First land on the blank, unselected page, no handleChange
|
||||||
// Land on page with initial values, handleChange
|
// // Land on page with initial values, handleChange
|
||||||
const validateValue = value;
|
// const validateValue = value;
|
||||||
return {
|
// return {
|
||||||
handleChange,
|
// handleChange,
|
||||||
errors,
|
// errors,
|
||||||
validateValue,
|
// validateValue,
|
||||||
fieldOptions, // only need to expose this for unit test purposes
|
// fieldOptions, // only need to expose this for unit test purposes
|
||||||
};
|
// };
|
||||||
},
|
// },
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -232,7 +233,7 @@ export default {
|
||||||
.list-card {
|
.list-card {
|
||||||
border: 1px solid $gray-500;
|
border: 1px solid $gray-500;
|
||||||
|
|
||||||
&.invalid {
|
&.has-error {
|
||||||
//Red border if invalid
|
//Red border if invalid
|
||||||
border: 1px solid $red;
|
border: 1px solid $red;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
process.env.VUE_APP_CONSUMER_CF_DISTRO =
|
process.env.VUE_APP_CONSUMER_CF_DISTRO =
|
||||||
"https://consumerapidev.safelite.com";
|
"https://consumerapialbdev.safelite.com";
|
||||||
process.env.VUE_APP_HERITAGE_FUNNEL =
|
process.env.VUE_APP_HERITAGE_FUNNEL =
|
||||||
"http://localhost:38000/default.aspx";
|
"http://localhost:38000/default.aspx";
|
||||||
process.env.VUE_APP_GOOGLE_PLACES_API_KEY =
|
process.env.VUE_APP_GOOGLE_PLACES_API_KEY =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue