fix: made doctype field select field and minor fixes

This commit is contained in:
Shariq Ansari 2024-01-26 18:56:33 +05:30
parent 975384ad43
commit 69cc2f1576
2 changed files with 22 additions and 8 deletions

View File

@ -2,7 +2,7 @@
<Dialog <Dialog
v-model="show" v-model="show"
:options="{ :options="{
title: editMode ? 'Edit Email Template' : 'Create Email Template', title: editMode ? emailTemplate.name : 'Create Email Template',
size: 'xl', size: 'xl',
actions: [ actions: [
{ {
@ -21,6 +21,7 @@
<span class="text-red-500">*</span> <span class="text-red-500">*</span>
</div> </div>
<TextInput <TextInput
ref="nameRef"
variant="outline" variant="outline"
v-model="_emailTemplate.name" v-model="_emailTemplate.name"
placeholder="Add name" placeholder="Add name"
@ -28,10 +29,11 @@
</div> </div>
<div> <div>
<div class="mb-1.5 text-sm text-gray-600">Doctype</div> <div class="mb-1.5 text-sm text-gray-600">Doctype</div>
<TextInput <Select
variant="outline" variant="outline"
v-model="_emailTemplate.reference_doctype" v-model="_emailTemplate.reference_doctype"
placeholder="Add Doctype" :options="['CRM Deal', 'CRM Lead']"
placeholder="Select Doctype"
/> />
</div> </div>
<div> <div>
@ -40,7 +42,7 @@
<span class="text-red-500">*</span> <span class="text-red-500">*</span>
</div> </div>
<TextInput <TextInput
ref="subject" ref="subjectRef"
variant="outline" variant="outline"
v-model="_emailTemplate.subject" v-model="_emailTemplate.subject"
placeholder="Add subject" placeholder="Add subject"
@ -71,7 +73,7 @@
</template> </template>
<script setup> <script setup>
import { Checkbox, TextEditor, call } from 'frappe-ui' import { Checkbox, Select, TextEditor, call } from 'frappe-ui'
import { ref, defineModel, nextTick, watch } from 'vue' import { ref, defineModel, nextTick, watch } from 'vue'
const props = defineProps({ const props = defineProps({
@ -87,7 +89,8 @@ const errorMessage = ref('')
const emit = defineEmits(['after']) const emit = defineEmits(['after'])
const subject = ref(null) const subjectRef = ref(null)
const nameRef = ref(null)
const editMode = ref(false) const editMode = ref(false)
let _emailTemplate = ref({}) let _emailTemplate = ref({})
@ -179,7 +182,11 @@ watch(
editMode.value = false editMode.value = false
errorMessage.value = '' errorMessage.value = ''
nextTick(() => { nextTick(() => {
subject.value.el.focus() if (_emailTemplate.value.name) {
subjectRef.value.el.focus()
} else {
nameRef.value.el.focus()
}
_emailTemplate.value = { ...props.emailTemplate } _emailTemplate.value = { ...props.emailTemplate }
if (_emailTemplate.value.name) { if (_emailTemplate.value.name) {
editMode.value = true editMode.value = true

View File

@ -83,7 +83,14 @@ const rows = computed(() => {
const showEmailTemplateModal = ref(false) const showEmailTemplateModal = ref(false)
const emailTemplate = ref({}) const emailTemplate = ref({
subject: '',
response: '',
name: '',
enabled: 1,
owner: '',
reference_doctype: 'CRM Deal',
})
function showEmailTemplate(name) { function showEmailTemplate(name) {
let et = rows.value?.find((row) => row.name === name) let et = rows.value?.find((row) => row.name === name)