WIP update code for checkbox.

This commit is contained in:
Bryan Mauger 2023-06-02 10:11:34 -04:00
parent 3fd18cb442
commit 52daca07a7
2 changed files with 13 additions and 29 deletions

View file

@ -20,37 +20,18 @@
<script>
export default {
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: {
checkboxLabelCopy() {
return this.getCmsContent("TextMeQuestionWidget", "QuestionText");
},
value: {
get: function () {
return this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);
},
},
},
props: {
cmsWidgetName: String,
@ -60,7 +41,10 @@ export default {
screenReaderOnlyText: String,
isRequired: Boolean,
hasError: Boolean,
modelValue: Boolean,
modelValue: {
type: Boolean,
default: false,
},
},
};
</script>

View file

@ -109,7 +109,7 @@ export default {
lastName: "",
emailAddress: "",
phoneNumber: "",
textMeUpdates: "",
textMeUpdates: null,
};
},
computed: {