CSR-762 Refactor to use v-model
This commit is contained in:
parent
39d922fd4e
commit
4f5c71dcf9
7 changed files with 19 additions and 24 deletions
|
|
@ -30,11 +30,6 @@ import inputButtonWrapperMixin from "../../mixins/input-button-wrapper-mixin";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "base-input-button",
|
name: "base-input-button",
|
||||||
emits: ["change", "inputButtonClicked"],
|
|
||||||
model: {
|
|
||||||
prop: "modelValue",
|
|
||||||
event: "change",
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
// ...inputButtonWrapperMixin.props
|
// ...inputButtonWrapperMixin.props
|
||||||
value: {
|
value: {
|
||||||
|
|
@ -132,7 +127,7 @@ export default {
|
||||||
},
|
},
|
||||||
handleClick(e) {
|
handleClick(e) {
|
||||||
this.handleSelectionChange(e);
|
this.handleSelectionChange(e);
|
||||||
this.$emit("inputButtonClicked", this.valueToEmit);
|
this.$emit("update:modelValue", this.valueToEmit);
|
||||||
},
|
},
|
||||||
handleFocus() {
|
handleFocus() {
|
||||||
this.$root.handleInputFocus({
|
this.$root.handleInputFocus({
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@
|
||||||
:groupName="answer.groupName"
|
:groupName="answer.groupName"
|
||||||
:isMultiSelect="isMultiSelect"
|
:isMultiSelect="isMultiSelect"
|
||||||
:value="answer.value"
|
:value="answer.value"
|
||||||
:modelValue="modelValue"
|
|
||||||
:selectingInitiatesLoad="selectingInitiatesLoad"
|
:selectingInitiatesLoad="selectingInitiatesLoad"
|
||||||
:isWide="isWide"
|
:isWide="isWide"
|
||||||
:validationRules="validationRules"
|
:validationRules="validationRules"
|
||||||
|
|
@ -54,7 +53,8 @@
|
||||||
:lastValuePushedToGa="lastValuePushedToGa"
|
:lastValuePushedToGa="lastValuePushedToGa"
|
||||||
:setLastValuePushedToGa="setLastValuePushedToGa"
|
:setLastValuePushedToGa="setLastValuePushedToGa"
|
||||||
:shouldPushClickEventToGAOnMount="shouldPushClickEventToGAOnMount"
|
:shouldPushClickEventToGAOnMount="shouldPushClickEventToGAOnMount"
|
||||||
@inputButtonClicked="handleAnswerChange" />
|
v-model="selectedValues"
|
||||||
|
/>
|
||||||
<!-- For nested questions -->
|
<!-- For nested questions -->
|
||||||
<transition name="fade" mode="out-in">
|
<transition name="fade" mode="out-in">
|
||||||
<div
|
<div
|
||||||
|
|
@ -229,11 +229,6 @@ export default {
|
||||||
: this.formatString(answer.toString());
|
: this.formatString(answer.toString());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleAnswerChange(selectedAnswers) {
|
|
||||||
this.selectedValues = selectedAnswers;
|
|
||||||
|
|
||||||
this.$emit("buttonQuestionChange", selectedAnswers);
|
|
||||||
},
|
|
||||||
setLastValuePushedToGa(lastValuePushedToGa) {
|
setLastValuePushedToGa(lastValuePushedToGa) {
|
||||||
this.lastValuePushedToGa = lastValuePushedToGa;
|
this.lastValuePushedToGa = lastValuePushedToGa;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,20 @@ export default {
|
||||||
},
|
},
|
||||||
lastValuePushedToGa: [String, Number],
|
lastValuePushedToGa: [String, Number],
|
||||||
setLastValuePushedToGa: Function,
|
setLastValuePushedToGa: Function,
|
||||||
shouldPushClickEventToGAOnMount: Boolean
|
shouldPushClickEventToGAOnMount: Boolean,
|
||||||
},
|
},
|
||||||
methods: {
|
computed: {
|
||||||
handleAnswerChange(e) {
|
selectedValue: {
|
||||||
if (this.preHandleAnswerChange) {
|
get() {
|
||||||
this.preHandleAnswerChange(e);
|
return this.modelValue;
|
||||||
}
|
},
|
||||||
|
set(e) {
|
||||||
|
if (this.preHandleAnswerChange) {
|
||||||
|
this.preHandleAnswerChange(e);
|
||||||
|
}
|
||||||
|
|
||||||
this.$emit("change", e);
|
this.$emit("update:modelValue", e);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
'list-group list-button-horizontal d-flex flex-column w-100',
|
'list-group list-button-horizontal d-flex flex-column w-100',
|
||||||
{ 'radio-fancy': isCashOrInsurance },
|
{ 'radio-fancy': isCashOrInsurance },
|
||||||
]"
|
]"
|
||||||
@inputButtonClicked="handleAnswerChange">
|
v-model="selectedValue">
|
||||||
<div
|
<div
|
||||||
class="list-button-horizontal-content d-flex flex-column justify-content-center p-3">
|
class="list-button-horizontal-content d-flex flex-column justify-content-center p-3">
|
||||||
<span class="m-0" :class="textPosition">
|
<span class="m-0" :class="textPosition">
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<baseInputButton
|
<baseInputButton
|
||||||
v-bind="$props"
|
v-bind="$props"
|
||||||
buttonWrapperClasses="list-group list-button rounded-3 d-flex flex-column w-100 mb-2"
|
buttonWrapperClasses="list-group list-button rounded-3 d-flex flex-column w-100 mb-2"
|
||||||
@inputButtonClicked="handleAnswerChange">
|
v-model="selectedValue">
|
||||||
<div
|
<div
|
||||||
:aria-label="buttonLabel"
|
:aria-label="buttonLabel"
|
||||||
class="list-button-content d-flex flex-column justify-content-center py-3 px-4">
|
class="list-button-content d-flex flex-column justify-content-center py-3 px-4">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
'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 },
|
{ horizontal: isWide },
|
||||||
]"
|
]"
|
||||||
@inputButtonClicked="handleAnswerChange">
|
v-model="selectedValue">
|
||||||
<div
|
<div
|
||||||
class="d-flex w-100 align-items-center px-2 h-100 list-card-content"
|
class="d-flex w-100 align-items-center px-2 h-100 list-card-content"
|
||||||
:class="labelClasses">
|
:class="labelClasses">
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
v-bind="$props"
|
v-bind="$props"
|
||||||
buttonWrapperClasses="ui-radio form-check"
|
buttonWrapperClasses="ui-radio form-check"
|
||||||
inputClasses="form-check-input"
|
inputClasses="form-check-input"
|
||||||
@inputButtonClicked="handleAnswerChange">
|
v-model="selectedValue">
|
||||||
<div class="d-flex align-items-start form-check-label">
|
<div class="d-flex align-items-start form-check-label">
|
||||||
<p v-if="buttonLabel" class="m-0">{{ buttonLabel }}</p>
|
<p v-if="buttonLabel" class="m-0">{{ buttonLabel }}</p>
|
||||||
<span v-if="screenReaderOnlyText" class="sr-only">{{
|
<span v-if="screenReaderOnlyText" class="sr-only">{{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue