refactor: use v-model instead of value

This commit is contained in:
Shariq Ansari 2024-01-26 20:32:42 +05:30
parent f39b9b9666
commit 95fc17c4f5
2 changed files with 6 additions and 20 deletions

View File

@ -2,8 +2,8 @@
<TextEditor <TextEditor
ref="textEditor" ref="textEditor"
:editor-class="['prose-sm max-w-none', editable && 'min-h-[7rem]']" :editor-class="['prose-sm max-w-none', editable && 'min-h-[7rem]']"
:content="value" :content="content"
@change="editable ? $emit('change', $event) : null" @change="editable ? (content = $event) : null"
:starterkit-options="{ heading: { levels: [2, 3, 4, 5, 6] } }" :starterkit-options="{ heading: { levels: [2, 3, 4, 5, 6] } }"
:placeholder="placeholder" :placeholder="placeholder"
:editable="editable" :editable="editable"
@ -85,10 +85,6 @@ import { EditorContent } from '@tiptap/vue-3'
import { ref, computed, defineModel } from 'vue' import { ref, computed, defineModel } from 'vue'
const props = defineProps({ const props = defineProps({
value: {
type: String,
default: '',
},
placeholder: { placeholder: {
type: String, type: String,
default: null, default: null,
@ -115,9 +111,9 @@ const props = defineProps({
}, },
}) })
const emit = defineEmits(['change'])
const modelValue = defineModel() const modelValue = defineModel()
const attachments = defineModel('attachments') const attachments = defineModel('attachments')
const content = defineModel('content')
const { users: usersList } = usersStore() const { users: usersList } = usersStore()

View File

@ -43,8 +43,7 @@
> >
<EmailEditor <EmailEditor
ref="newEmailEditor" ref="newEmailEditor"
:value="newEmail" v-model:content="newEmail"
@change="onNewEmailChange"
:submitButtonProps="{ :submitButtonProps="{
variant: 'solid', variant: 'solid',
onClick: submitEmail, onClick: submitEmail,
@ -67,8 +66,7 @@
<div v-show="showCommentBox"> <div v-show="showCommentBox">
<CommentBox <CommentBox
ref="newCommentEditor" ref="newCommentEditor"
:value="newComment" v-model:content="newComment"
@change="onNewCommentChange"
:submitButtonProps="{ :submitButtonProps="{
variant: 'solid', variant: 'solid',
onClick: submitComment, onClick: submitComment,
@ -158,14 +156,6 @@ const emailEmpty = computed(() => {
return !newEmail.value || newEmail.value === '<p></p>' return !newEmail.value || newEmail.value === '<p></p>'
}) })
const onNewEmailChange = (value) => {
newEmail.value = value
}
const onNewCommentChange = (value) => {
newComment.value = value
}
async function sendMail() { async function sendMail() {
let recipients = newEmailEditor.value.toEmails let recipients = newEmailEditor.value.toEmails
let subject = newEmailEditor.value.subject let subject = newEmailEditor.value.subject
@ -187,7 +177,7 @@ async function sendMail() {
} }
async function sendComment() { async function sendComment() {
await call("frappe.desk.form.utils.add_comment", { await call('frappe.desk.form.utils.add_comment', {
reference_doctype: props.doctype, reference_doctype: props.doctype,
reference_name: doc.value.data.name, reference_name: doc.value.data.name,
content: newComment.value, content: newComment.value,