WIP update code for checkbox.
This commit is contained in:
parent
3fd18cb442
commit
52daca07a7
2 changed files with 13 additions and 29 deletions
|
|
@ -20,37 +20,18 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "checkboxQuestion",
|
name: "checkboxQuestion",
|
||||||
setup(props) {
|
|
||||||
const inputId = !props.customInputId ? `input-${crypto.randomUUID()}` : props.customInputId;
|
|
||||||
|
|
||||||
const propsClone = Object.assign({}, props);
|
|
||||||
const modelValue = propsClone.modelValue;
|
|
||||||
let initialValue;
|
|
||||||
|
|
||||||
switch (typeof modelValue) {
|
|
||||||
case "checked":
|
|
||||||
initialValue = modelValue;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
initialValue = modelValue && modelValue.checked === false ? modelValue : "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fieldOptions = {
|
|
||||||
type: "checkbox",
|
|
||||||
value: modelValue,
|
|
||||||
initialValue: initialValue,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
value: [],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
checkboxLabelCopy() {
|
checkboxLabelCopy() {
|
||||||
return this.getCmsContent("TextMeQuestionWidget", "QuestionText");
|
return this.getCmsContent("TextMeQuestionWidget", "QuestionText");
|
||||||
},
|
},
|
||||||
|
value: {
|
||||||
|
get: function () {
|
||||||
|
return this.modelValue;
|
||||||
|
},
|
||||||
|
set: function (newValue) {
|
||||||
|
this.$emit("update:modelValue", newValue);
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
|
|
@ -60,7 +41,10 @@ export default {
|
||||||
screenReaderOnlyText: String,
|
screenReaderOnlyText: String,
|
||||||
isRequired: Boolean,
|
isRequired: Boolean,
|
||||||
hasError: Boolean,
|
hasError: Boolean,
|
||||||
modelValue: Boolean,
|
modelValue: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ export default {
|
||||||
lastName: "",
|
lastName: "",
|
||||||
emailAddress: "",
|
emailAddress: "",
|
||||||
phoneNumber: "",
|
phoneNumber: "",
|
||||||
textMeUpdates: "",
|
textMeUpdates: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue