fix: Duplicate email template
(cherry picked from commit 7e6d5c3e544b784b07ae0975b4ae784fb9f9ee46)
This commit is contained in:
parent
ab6ea90c66
commit
3f51da59ad
@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<NewEmailTemplate v-if="step === 'new-template'" @updateStep="updateStep" />
|
<NewEmailTemplate
|
||||||
|
v-if="step === 'new-template'"
|
||||||
|
:templateData="template"
|
||||||
|
@updateStep="updateStep"
|
||||||
|
/>
|
||||||
<EmailTemplates
|
<EmailTemplates
|
||||||
v-else-if="step === 'template-list'"
|
v-else-if="step === 'template-list'"
|
||||||
@updateStep="updateStep"
|
@updateStep="updateStep"
|
||||||
|
|||||||
@ -197,7 +197,14 @@ function toggleEmailTemplate(template) {
|
|||||||
|
|
||||||
function deleteTemplate(template) {
|
function deleteTemplate(template) {
|
||||||
confirmDelete.value = false
|
confirmDelete.value = false
|
||||||
templates.delete.submit(template.name)
|
templates.delete.submit(template.name, {
|
||||||
|
onSuccess: () => {
|
||||||
|
toast.success(__('Template deleted successfully'))
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
toast.error(error.messages[0] || __('Failed to delete template'))
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDropdownOptions(template) {
|
function getDropdownOptions(template) {
|
||||||
@ -209,9 +216,7 @@ function getDropdownOptions(template) {
|
|||||||
option: __('Edit'),
|
option: __('Edit'),
|
||||||
icon: 'edit-2',
|
icon: 'edit-2',
|
||||||
active: props.active,
|
active: props.active,
|
||||||
onClick: () => {
|
onClick: () => emit('updateStep', 'edit-template', { ...template }),
|
||||||
emit('updateStep', 'edit-template', { ...template })
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -221,7 +226,7 @@ function getDropdownOptions(template) {
|
|||||||
option: __('Duplicate'),
|
option: __('Duplicate'),
|
||||||
icon: 'copy',
|
icon: 'copy',
|
||||||
active: props.active,
|
active: props.active,
|
||||||
onClick: () => {},
|
onClick: () => emit('updateStep', 'new-template', { ...template }),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,12 +10,16 @@
|
|||||||
@click="() => emit('updateStep', 'template-list')"
|
@click="() => emit('updateStep', 'template-list')"
|
||||||
>
|
>
|
||||||
<FeatherIcon name="chevron-left" class="size-5" />
|
<FeatherIcon name="chevron-left" class="size-5" />
|
||||||
<span class="text-xl font-semibold">{{ __('New Template') }}</span>
|
<span class="text-xl font-semibold">
|
||||||
|
{{
|
||||||
|
templateData?.name ? __('Duplicate template') : __('New template')
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex item-center space-x-2 w-3/12 justify-end">
|
<div class="flex item-center space-x-2 w-3/12 justify-end">
|
||||||
<Button
|
<Button
|
||||||
:label="__('Create')"
|
:label="templateData?.name ? __('Duplicate') : __('Create')"
|
||||||
icon-left="plus"
|
icon-left="plus"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
@click="createTemplate"
|
@click="createTemplate"
|
||||||
@ -126,7 +130,14 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { TextEditor, FormControl, Switch, toast } from 'frappe-ui'
|
import { TextEditor, FormControl, Switch, toast } from 'frappe-ui'
|
||||||
import { inject, ref } from 'vue'
|
import { inject, onMounted, ref } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
templateData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['updateStep'])
|
const emit = defineEmits(['updateStep'])
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
@ -176,4 +187,12 @@ const createTemplate = () => {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.templateData) {
|
||||||
|
Object.assign(template.value, props.templateData)
|
||||||
|
template.value.name = template.value.name + ' - Copy'
|
||||||
|
template.value.enabled = false // Default to disabled for new templates
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user