WIP update computed and other code.

This commit is contained in:
Bryan Mauger 2023-05-09 15:14:06 -04:00
parent 40414580da
commit 10d0f24f5a
2 changed files with 54 additions and 5 deletions

View file

@ -1,6 +1,8 @@
<template> <template>
<div class="textarea-question"> <div class="textarea-question">
<label for="textarea-comments" class="fw-bold mb-1">{{ labelText }} <span v-if="isRequired" class="fw-normal">(Optional)</span></label> <div class="label-wrapper mb-1" :aria-label="TextAreaContentWidget"><!-- Wrap label and span because v-html prevents v-if from displaying if v-if <span> is inside <label>-->
<label for="textarea-comments" class="fw-bold" v-html="TextAreaContentWidget"></label> <span v-if="isRequired" class="fw-normal ms-1">(Optional)</span>
</div>
<textarea <textarea
id="textarea-comments" id="textarea-comments"
class="p-4" class="p-4"
@ -25,6 +27,49 @@ export default {
modelValue: String, modelValue: String,
labelText: String, labelText: String,
}, },
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 "number":
initialValue = modelValue;
break;
default:
initialValue = modelValue && modelValue.length > 0 ? modelValue : "";
break;
}
const fieldOptions = {
type: "text",
value: modelValue,
initialValue: initialValue,
};
},
computed: {
TextAreaContentWidget() {
return this.getCmsContent(this.cmsWidgetName, "QuestionText");
},
value: {
get: function () {
return this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);
},
},
},
value: {
get: function () {
return this.modelValue;
},
set: function (newValue) {
this.$emit("update:modelValue", newValue);
},
},
mounted: function () { mounted: function () {
const my_textarea = document.getElementById("textarea-comments"); const my_textarea = document.getElementById("textarea-comments");
const remaining = document.getElementById("charactersremaining"); const remaining = document.getElementById("charactersremaining");
@ -44,9 +89,13 @@ export default {
.textarea-question { .textarea-question {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
label { .label-wrapper {
span { display: flex;
color: $gray-500; align-items: center;
label {
span {
color: $gray-500;
}
} }
} }
textarea { textarea {

View file

@ -1,6 +1,6 @@
<template> <template>
<textareaquestion <textareaquestion
cmsWidgetName="CustomerDetailsTextAreaLabelText" cmsWidgetName="TextAreaContentWidget"
:labelText="textAreaLabelCopy" :labelText="textAreaLabelCopy"
maxLength=250 maxLength=250
isRequired isRequired