fix: add new email template from email selector modal

This commit is contained in:
Shariq Ansari 2025-06-25 15:23:30 +05:30
parent 7cee017e20
commit 5932ccafec
2 changed files with 29 additions and 25 deletions

View File

@ -4,19 +4,33 @@
:options="{ title: __('Email Templates'), size: '4xl' }" :options="{ title: __('Email Templates'), size: '4xl' }"
> >
<template #body-content> <template #body-content>
<TextInput <div class="flex items-center gap-2">
ref="searchInput" <TextInput
v-model="search" class="w-full"
type="text" ref="searchInput"
:placeholder="__('Payment Reminder')" v-model="search"
> type="text"
<template #prefix> :placeholder="__('Payment Reminder')"
<FeatherIcon name="search" class="h-4 w-4 text-ink-gray-4" /> >
</template> <template #prefix>
</TextInput> <FeatherIcon name="search" class="h-4 w-4 text-ink-gray-4" />
</template>
</TextInput>
<Button
:label="__('Create')"
icon-left="plus"
@click="
() => {
show = false
showSettings = true
activeSettingsPage = 'Email Templates'
}
"
/>
</div>
<div <div
v-if="filteredTemplates.length" v-if="filteredTemplates.length"
class="mt-2 grid max-h-[560px] sm:grid-cols-3 gris-cols-1 gap-2 overflow-y-auto" class="mt-4 grid max-h-[560px] sm:grid-cols-3 gris-cols-1 gap-2 overflow-y-auto"
> >
<div <div
v-for="template in filteredTemplates" v-for="template in filteredTemplates"
@ -57,11 +71,8 @@
@click=" @click="
() => { () => {
show = false show = false
emailTemplate = { showSettings = true
reference_doctype: props.doctype, activeSettingsPage = 'Email Templates'
enabled: 1,
}
showEmailTemplateModal = true
} }
" "
/> />
@ -69,14 +80,10 @@
</div> </div>
</template> </template>
</Dialog> </Dialog>
<EmailTemplateModal
v-model="showEmailTemplateModal"
:emailTemplate="emailTemplate"
/>
</template> </template>
<script setup> <script setup>
import EmailTemplateModal from '@/components/Modals/EmailTemplateModal.vue' import { showSettings, activeSettingsPage } from '@/composables/settings'
import { TextEditor, createListResource } from 'frappe-ui' import { TextEditor, createListResource } from 'frappe-ui'
import { ref, computed, nextTick, watch, onMounted } from 'vue' import { ref, computed, nextTick, watch, onMounted } from 'vue'
@ -89,9 +96,6 @@ const props = defineProps({
const show = defineModel() const show = defineModel()
const searchInput = ref('') const searchInput = ref('')
const showEmailTemplateModal = ref(false)
const emailTemplate = ref({})
const emit = defineEmits(['apply']) const emit = defineEmits(['apply'])

View File

@ -189,7 +189,7 @@ const createTemplate = () => {
} }
onMounted(() => { onMounted(() => {
if (props.templateData) { if (props.templateData?.name) {
Object.assign(template.value, props.templateData) Object.assign(template.value, props.templateData)
template.value.name = template.value.name + ' - Copy' template.value.name = template.value.name + ' - Copy'
template.value.enabled = false // Default to disabled for new templates template.value.enabled = false // Default to disabled for new templates