fix: focus on search when email templates modal is opened
This commit is contained in:
parent
95fc17c4f5
commit
405258cff6
@ -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"
|
||||||
@ -144,10 +144,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,
|
||||||
@ -178,9 +174,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 textEditor = ref(null)
|
const textEditor = ref(null)
|
||||||
const cc = ref(false)
|
const cc = ref(false)
|
||||||
@ -217,6 +213,7 @@ async function applyEmailTemplate(template) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (template.response) {
|
if (template.response) {
|
||||||
|
content.value = data.message
|
||||||
editor.value.commands.setContent(data.message)
|
editor.value.commands.setContent(data.message)
|
||||||
}
|
}
|
||||||
showEmailTemplateSelectorModal.value = false
|
showEmailTemplateSelectorModal.value = false
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<Dialog v-model="show" :options="{ title: 'Email Templates', size: '4xl' }">
|
<Dialog v-model="show" :options="{ title: 'Email Templates', size: '4xl' }">
|
||||||
<template #body-content>
|
<template #body-content>
|
||||||
<FormControl
|
<TextInput
|
||||||
|
ref="searchInput"
|
||||||
v-model="search"
|
v-model="search"
|
||||||
type="text"
|
type="text"
|
||||||
class="mb-2 w-full"
|
class="mb-2 w-full"
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
/>
|
/>
|
||||||
<div class="grid grid-cols-3 gap-2">
|
<div class="grid max-h-[560px] grid-cols-3 gap-2 overflow-y-auto">
|
||||||
<div
|
<div
|
||||||
v-for="template in filteredTemplates"
|
v-for="template in filteredTemplates"
|
||||||
:key="template.name"
|
:key="template.name"
|
||||||
@ -35,7 +36,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { TextEditor, createListResource } from 'frappe-ui'
|
import { TextEditor, createListResource } from 'frappe-ui'
|
||||||
import { defineModel, ref, computed } from 'vue'
|
import { defineModel, ref, computed, nextTick, watch } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
doctype: {
|
doctype: {
|
||||||
@ -45,6 +46,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const show = defineModel()
|
const show = defineModel()
|
||||||
|
const searchInput = ref('')
|
||||||
|
|
||||||
const emit = defineEmits(['apply'])
|
const emit = defineEmits(['apply'])
|
||||||
|
|
||||||
@ -79,4 +81,6 @@ const filteredTemplates = computed(() => {
|
|||||||
}) ?? []
|
}) ?? []
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(show, (value) => value && nextTick(() => searchInput.value?.el?.focus()))
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user