Self-hosted email delivery platform that enables applications to send emails via HTTP APIs while handling SMTP delivery, templates, storage, security, and analytics. Fully self-hostable alternative to services like SendGrid or Mailgun.
Go email-relayemail-routinghttp-to-smtpmail-deliverymailchimp-alternativemailgun-alternativemailsendermailservermailtemplatemailtestpostmark-alternativesend-emailsendgrid-alternativesendmailtransactional-emailtransactional-outbox
refactor(ui): standardize modal closure logic across 17 pages
Jude mpoyo12f19c545583
diff --git a/web/src/views/admin/ServerDetail.vue b/web/src/views/admin/ServerDetail.vueindex 60f22c5..36d0afb 100644--- a/web/src/views/admin/ServerDetail.vue+++ b/web/src/views/admin/ServerDetail.vue@@ -1,151 +1,158 @@<script setup lang="ts">-import { ref, onMounted } from 'vue'-import { useRoute, useRouter } from 'vue-router'-import { serversApi } from '../../api/servers'-import { useNotificationStore } from '../../stores/notification'-import { useConfirm } from '../../composables/useConfirm'-import type { SharedServer, SharedServerInput } from '../../api/types'+import { ref, onMounted } from "vue";+import { useRoute, useRouter } from "vue-router";+import { serversApi } from "../../api/servers";+import { useNotificationStore } from "../../stores/notification";+import { useConfirm } from "../../composables/useConfirm";+import type { SharedServer, SharedServerInput } from "../../api/types";+import { useModalSafeClose } from '../../composables/useModalSafeClose';-const route = useRoute()-const router = useRouter()-const notify = useNotificationStore()-const { confirm } = useConfirm()+const route = useRoute();+const router = useRouter();+const notify = useNotificationStore();+const { confirm } = useConfirm();-const server = ref<SharedServer | null>(null)-const loading = ref(true)+const server = ref<SharedServer | null>(null);+const loading = ref(true);-const showModal = ref(false)+const showModal = ref(false);const form = ref<SharedServerInput>({- name: '',- host: '',+ name: "",+ host: "",port: 587,- username: '',- password: '',- encryption: 'starttls',+ username: "",+ password: "",+ encryption: "starttls",max_retries: 0,allowed_domains: [],- security_mode: 'permissive',-})-const allowedDomainsText = ref('')-const saving = ref(false)+ security_mode: "permissive",+});+const allowedDomainsText = ref("");+const saving = ref(false);async function fetchServer() {- loading.value = true+ loading.value = true;try {- const id = Number(route.params.id)- const res = await serversApi.get(id)- server.value = res.data.data+ const id = Number(route.params.id);+ const res = await serversApi.get(id);+ server.value = res.data.data;} catch {- notify.error('Failed to load server')+ notify.error("Failed to load server");} finally {- loading.value = false+ loading.value = false;}}function openEdit() {- if (!server.value) return+ if (!server.value) return;form.value = {name: server.value.name,host: server.value.host,port: server.value.port,username: server.value.username,- password: '',+ password: "",encryption: server.value.encryption,max_retries: server.value.max_retries ?? 0,allowed_domains: server.value.allowed_domains ?? [],- security_mode: server.value.security_mode ?? 'permissive',- }- allowedDomainsText.value = (server.value.allowed_domains ?? []).join(', ')- showModal.value = true+ security_mode: server.value.security_mode ?? "permissive",+ };+ allowedDomainsText.value = (server.value.allowed_domains ?? []).join(", ");+ showModal.value = true;}async function save() {- if (!server.value) return- saving.value = true+ if (!server.value) return;+ saving.value = true;const data: SharedServerInput = {...form.value,allowed_domains: allowedDomainsText.value- .split(',')- .map(d => d.trim().toLowerCase())- .filter(d => d.length > 0),- }+ .split(",")+ .map((d) => d.trim().toLowerCase())+ .filter((d) => d.length > 0),+ };try {- await serversApi.update(server.value.id, data)- notify.success('Server updated')- showModal.value = false- await fetchServer()+ await serversApi.update(server.value.id, data);+ notify.success("Server updated");+ showModal.value = false;+ await fetchServer();} catch {- notify.error('Failed to update server')+ notify.error("Failed to update server");} finally {- saving.value = false+ saving.value = false;}}async function toggleStatus() {- if (!server.value) return+ if (!server.value) return;try {- if (server.value.status !== 'disabled') {- await serversApi.disable(server.value.id)- notify.success(`"${server.value.name}" disabled`)+ if (server.value.status !== "disabled") {+ await serversApi.disable(server.value.id);+ notify.success(`"${server.value.name}" disabled`);} else {- await serversApi.enable(server.value.id)- notify.success(`"${server.value.name}" enabled`)+ await serversApi.enable(server.value.id);+ notify.success(`"${server.value.name}" enabled`);}- await fetchServer()+ await fetchServer();} catch {- notify.error('Failed to update server status')+ notify.error("Failed to update server status");}}async function testServer() {- if (!server.value) return+ if (!server.value) return;try {- const res = await serversApi.test(server.value.id)+ const res = await serversApi.test(server.value.id);if (res.data.data.success) {- notify.success('Connection test successful')+ notify.success("Connection test successful");} else {- notify.error('Connection test failed: ' + res.data.data.message)+ notify.error("Connection test failed: " + res.data.data.message);}- await fetchServer()+ await fetchServer();} catch {- notify.error('Connection test failed')+ notify.error("Connection test failed");}}async function deleteServer() {- if (!server.value) return+ if (!server.value) return;const confirmed = await confirm({- title: 'Delete Shared Server',+ title: "Delete Shared Server",message: `Are you sure you want to delete "${server.value.name}"? Any accounts relying on this server will stop receiving email delivery.`,- confirmText: 'Delete',- variant: 'danger',- })- if (!confirmed) return+ confirmText: "Delete",+ variant: "danger",+ });+ if (!confirmed) return;try {- await serversApi.delete(server.value.id)- notify.success('Server deleted')- router.push('/admin/servers')+ await serversApi.delete(server.value.id);+ notify.success("Server deleted");+ router.push("/admin/servers");} catch {- notify.error('Failed to delete server')+ notify.error("Failed to delete server");}}function formatDate(date: string | null) {- if (!date) return '-'- return new Date(date).toLocaleString()+ if (!date) return "-";+ return new Date(date).toLocaleString();}-onMounted(fetchServer)+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showModal.value = false;+});++onMounted(fetchServer);</script><template><div><div class="page-header"><div>- <h1>{{ server?.name ?? 'Server Details' }}</h1>+ <h1>{{ server?.name ?? "Server Details" }}</h1></div><div class="flex gap-2">- <button class="btn btn-secondary" @click="router.push('/admin/servers')">Back</button>+ <button class="btn btn-secondary" @click="router.push('/admin/servers')">+ Back+ </button></div></div>@@ -155,14 +162,20 @@ onMounted(fetchServer)<template v-else-if="server"><!-- Info card -->- <div class="card" style="margin-bottom: 24px;">+ <div class="card" style="margin-bottom: 24px"><div class="card-header"><h2>{{ server.name }}</h2><div class="flex gap-2">- <span class="badge badge-success" v-if="server.status === 'enabled'">Enabled</span>- <span class="badge badge-danger" v-else-if="server.status === 'invalid'">Invalid</span>+ <span class="badge badge-success" v-if="server.status === 'enabled'"+ >Enabled</span+ >+ <span class="badge badge-danger" v-else-if="server.status === 'invalid'"+ >Invalid</span+ ><span class="badge badge-neutral" v-else>Disabled</span>- <span class="badge badge-warning" v-if="server.security_mode === 'strict'">Strict</span>+ <span class="badge badge-warning" v-if="server.security_mode === 'strict'"+ >Strict</span+ ><span class="badge badge-neutral" v-else>Permissive</span></div></div>@@ -170,67 +183,86 @@ onMounted(fetchServer)<table><tbody><tr>- <td style="font-weight: 600; width: 160px;">Host</td>+ <td style="font-weight: 600; width: 160px">Host</td><td>{{ server.host }}</td></tr><tr>- <td style="font-weight: 600;">Port</td>+ <td style="font-weight: 600">Port</td><td>{{ server.port }}</td></tr><tr>- <td style="font-weight: 600;">Encryption</td>+ <td style="font-weight: 600">Encryption</td><td>- <span class="badge badge-success" v-if="server.encryption === 'ssl'">SSL</span>- <span class="badge badge-info" v-else-if="server.encryption === 'starttls'">STARTTLS</span>+ <span class="badge badge-success" v-if="server.encryption === 'ssl'"+ >SSL</span+ >+ <span+ class="badge badge-info"+ v-else-if="server.encryption === 'starttls'"+ >STARTTLS</span+ ><span class="badge badge-neutral" v-else>None</span></td></tr><tr>- <td style="font-weight: 600;">Username</td>- <td>{{ server.username || '-' }}</td>+ <td style="font-weight: 600">Username</td>+ <td>{{ server.username || "-" }}</td></tr><tr>- <td style="font-weight: 600;">Max Retries</td>+ <td style="font-weight: 600">Max Retries</td><td>{{ server.max_retries }}</td></tr><tr>- <td style="font-weight: 600;">Security Mode</td>+ <td style="font-weight: 600">Security Mode</td><td>- <span class="badge badge-warning" v-if="server.security_mode === 'strict'">Strict</span>+ <span+ class="badge badge-warning"+ v-if="server.security_mode === 'strict'"+ >Strict</span+ ><span class="badge badge-neutral" v-else>Permissive</span>- <span class="text-muted" style="margin-left: 8px; font-size: 13px;">- {{ server.security_mode === 'strict' ? 'Requires verified domain ownership' : 'Allows any matching domain' }}+ <span class="text-muted" style="margin-left: 8px; font-size: 13px">+ {{+ server.security_mode === "strict"+ ? "Requires verified domain ownership"+ : "Allows any matching domain"+ }}</span></td></tr><tr>- <td style="font-weight: 600;">Allowed Domains</td>+ <td style="font-weight: 600">Allowed Domains</td><td>- <span v-if="server.allowed_domains && server.allowed_domains.length > 0">+ <span+ v-if="server.allowed_domains && server.allowed_domains.length > 0"+ ><spanv-for="d in server.allowed_domains":key="d"class="badge badge-neutral"- style="margin-right: 6px;"- >{{ d }}</span>+ style="margin-right: 6px"+ >{{ d }}</span+ ></span><span v-else class="text-muted">All domains</span></td></tr><tr v-if="server.status === 'invalid' && server.validation_error">- <td style="font-weight: 600;">Validation Error</td>- <td style="color: var(--color-danger, #e53e3e);">{{ server.validation_error }}</td>+ <td style="font-weight: 600">Validation Error</td>+ <td style="color: var(--color-danger, #e53e3e)">+ {{ server.validation_error }}+ </td></tr><tr>- <td style="font-weight: 600;">Last Validated</td>+ <td style="font-weight: 600">Last Validated</td><td>{{ formatDate(server.validated_at) }}</td></tr><tr>- <td style="font-weight: 600;">Created</td>+ <td style="font-weight: 600">Created</td><td>{{ formatDate(server.created_at) }}</td></tr><tr>- <td style="font-weight: 600;">Updated</td>+ <td style="font-weight: 600">Updated</td><td>{{ formatDate(server.updated_at) }}</td></tr></tbody>@@ -239,7 +271,7 @@ onMounted(fetchServer)</div><!-- Stats -->- <div class="stats-grid" style="margin-bottom: 24px;">+ <div class="stats-grid" style="margin-bottom: 24px"><div class="stat-card"><div class="stat-label">Sent</div><div class="stat-value">{{ server.sent_count.toLocaleString() }}</div>@@ -257,10 +289,9 @@ onMounted(fetchServer)<div class="flex gap-2"><button class="btn btn-primary" @click="openEdit">Edit</button><button class="btn btn-secondary" @click="testServer">Test Connection</button>- <button- class="btn btn-secondary"- @click="toggleStatus"- >{{ server.status !== 'disabled' ? 'Disable' : 'Enable' }}</button>+ <button class="btn btn-secondary" @click="toggleStatus">+ {{ server.status !== "disabled" ? "Disable" : "Enable" }}+ </button><button class="btn btn-danger" @click="deleteServer">Delete</button></div></div>@@ -272,8 +303,13 @@ onMounted(fetchServer)</div><!-- Edit Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="showModal = false">- <div class="modal">+ <div+ v-if="showModal"+ class="modal-overlay"+ @mousedown="watchClickStart"+ @mouseup="confirmClickEnd"+ >+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Edit Shared Server</h3></div>@@ -289,7 +325,12 @@ onMounted(fetchServer)</div><div class="form-group"><label class="form-label">Port</label>- <input v-model.number="form.port" type="number" class="form-input" required />+ <input+ v-model.number="form.port"+ type="number"+ class="form-input"+ required+ /></div><div class="form-group"><label class="form-label">Username</label>@@ -297,7 +338,12 @@ onMounted(fetchServer)</div><div class="form-group"><label class="form-label">Password</label>- <input v-model="form.password" type="password" class="form-input" placeholder="Leave blank to keep current" />+ <input+ v-model="form.password"+ type="password"+ class="form-input"+ placeholder="Leave blank to keep current"+ /></div><div class="form-group"><label class="form-label">Encryption</label>@@ -309,27 +355,50 @@ onMounted(fetchServer)</div><div class="form-group"><label class="form-label">Max Retries</label>- <input v-model.number="form.max_retries" type="number" class="form-input" min="0" max="10" />- <span class="form-hint">Number of times to retry a failed send. Set to 0 to disable retries.</span>+ <input+ v-model.number="form.max_retries"+ type="number"+ class="form-input"+ min="0"+ max="10"+ />+ <span class="form-hint"+ >Number of times to retry a failed send. Set to 0 to disable+ retries.</span+ ></div><div class="form-group"><label class="form-label">Allowed Domains</label>- <input v-model="allowedDomainsText" type="text" class="form-input" placeholder="example.com, acme.org" />- <span class="form-hint">Comma-separated. Leave empty to allow all domains.</span>+ <input+ v-model="allowedDomainsText"+ type="text"+ class="form-input"+ placeholder="example.com, acme.org"+ />+ <span class="form-hint"+ >Comma-separated. Leave empty to allow all domains.</span+ ></div><div class="form-group"><label class="form-label">Security Mode</label><select v-model="form.security_mode" class="form-select">- <option value="permissive">Permissive — allow any user whose sender domain matches</option>+ <option value="permissive">+ Permissive — allow any user whose sender domain matches+ </option><option value="strict">Strict — require verified domain ownership</option></select>- <span class="form-hint">In strict mode, users must verify ownership of their sender domain before this server is available to them.</span>+ <span class="form-hint"+ >In strict mode, users must verify ownership of their sender domain before+ this server is available to them.</span+ ></div></div><div class="modal-footer">- <button type="button" class="btn btn-secondary" @click="showModal = false">Cancel</button>+ <button type="button" class="btn btn-secondary" @click="showModal = false">+ Cancel+ </button><button type="submit" class="btn btn-primary" :disabled="saving">- {{ saving ? 'Saving...' : 'Update' }}+ {{ saving ? "Saving..." : "Update" }}</button></div></form>diff --git a/web/src/views/admin/Servers.vue b/web/src/views/admin/Servers.vueindex 8662515..1ba679b 100644--- a/web/src/views/admin/Servers.vue+++ b/web/src/views/admin/Servers.vue@@ -5,6 +5,7 @@ import { serversApi } from '../../api/servers'import type { SharedServer, SharedServerInput, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const router = useRouter()const notify = useNotificationStore()@@ -126,6 +127,10 @@ function nextPage() {}}+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showModal.value = false;+});+onMounted(fetchServers)</script>@@ -211,8 +216,8 @@ onMounted(fetchServers)</template><!-- Create/Edit Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="showModal = false">- <div class="modal">+ <div v-if="showModal" class="modal-overlay" @mousedown="watchClickStart" @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>{{ editing ? 'Edit Shared Server' : 'Add Shared Server' }}</h3></div>diff --git a/web/src/views/admin/Users.vue b/web/src/views/admin/Users.vueindex d0f75de..6fcb68c 100644--- a/web/src/views/admin/Users.vue+++ b/web/src/views/admin/Users.vue@@ -5,6 +5,7 @@ import { adminApi } from '../../api/admin'import type { User, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const router = useRouter()const notify = useNotificationStore()@@ -136,6 +137,9 @@ async function deleteUser(user: User) {notify.error('Failed to delete user')}}+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ cancelEdit()+});</script><template>@@ -250,8 +254,9 @@ async function deleteUser(user: User) {</template><!-- Edit User Modal -->- <div v-if="editingUser" class="modal-overlay" @click.self="cancelEdit">- <div class="modal">+ <div v-if="editingUser" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Edit User</h3></div>diff --git a/web/src/views/apikeys/ApiKeys.vue b/web/src/views/apikeys/ApiKeys.vueindex 26ad68e..10ebafe 100644--- a/web/src/views/apikeys/ApiKeys.vue+++ b/web/src/views/apikeys/ApiKeys.vue@@ -5,6 +5,7 @@ import { settingsApi } from '../../api/settings'import type { ApiKey, ApiKeyCreateResponse, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const notify = useNotificationStore()const { confirm } = useConfirm()@@ -155,6 +156,9 @@ function canDelete(key: ApiKey): boolean {function formatDate(dateStr: string): string {return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showCreateModal.value = false;+});onMounted(() => {loadSettings()@@ -259,8 +263,9 @@ onMounted(() => {</div><!-- Create Key Modal -->- <div v-if="showCreateModal" class="modal-overlay" @click.self="showCreateModal = false">- <div class="modal">+ <div v-if="showCreateModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Create API Key</h3></div>diff --git a/web/src/views/bounces/Bounces.vue b/web/src/views/bounces/Bounces.vueindex 52edab2..8f5b49a 100644--- a/web/src/views/bounces/Bounces.vue+++ b/web/src/views/bounces/Bounces.vue@@ -4,6 +4,7 @@ import { bouncesApi, suppressionsApi } from '../../api/bounces'import type { Bounce, Suppression, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const notify = useNotificationStore()const { confirm } = useConfirm()@@ -113,6 +114,9 @@ async function addSuppression() {notify.error('Failed to add suppression')}}+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showAddModal.value = false;+});</script><template>@@ -234,8 +238,9 @@ async function addSuppression() {</template><!-- Add Suppression Modal -->- <div v-if="showAddModal" class="modal-overlay" @click.self="showAddModal = false">- <div class="modal">+ <div v-if="showAddModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h2>Add Suppression</h2></div>diff --git a/web/src/views/contact-lists/ContactListMembers.vue b/web/src/views/contact-lists/ContactListMembers.vueindex 51a3b81..1928437 100644--- a/web/src/views/contact-lists/ContactListMembers.vue+++ b/web/src/views/contact-lists/ContactListMembers.vue@@ -5,6 +5,7 @@ import { contactListsApi } from '../../api/contactLists'import type { ContactListWithCount, ContactListMember, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const route = useRoute()const router = useRouter()@@ -90,7 +91,9 @@ async function removeMember(member: ContactListMember) {function formatDate(dateStr: string): string {return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showAddModal.value = false;+});onMounted(async () => {await loadList()await loadMembers()@@ -159,8 +162,9 @@ onMounted(async () => {</div><!-- Add Member Modal -->- <div v-if="showAddModal" class="modal-overlay" @click.self="showAddModal = false">- <div class="modal">+ <div v-if="showAddModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h2>Add Member</h2></div>diff --git a/web/src/views/contact-lists/ContactLists.vue b/web/src/views/contact-lists/ContactLists.vueindex 6555c87..02fc45f 100644--- a/web/src/views/contact-lists/ContactLists.vue+++ b/web/src/views/contact-lists/ContactLists.vue@@ -5,6 +5,7 @@ import { contactListsApi } from '../../api/contactLists'import type { ContactListWithCount, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const router = useRouter()const notify = useNotificationStore()@@ -92,7 +93,9 @@ function openMembers(list: ContactListWithCount) {function formatDate(dateStr: string): string {return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showModal.value = false;+});onMounted(() => loadLists())</script>@@ -158,8 +161,8 @@ onMounted(() => loadLists())</div><!-- Create/Edit Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="showModal = false">- <div class="modal">+ <div v-if="showModal" class="modal-overlay" @mousedown="watchClickStart" @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>{{ editingId ? 'Edit Contact List' : 'Create Contact List' }}</h3></div>diff --git a/web/src/views/contacts/ContactDetail.vue b/web/src/views/contacts/ContactDetail.vueindex c73d54d..563d76e 100644--- a/web/src/views/contacts/ContactDetail.vue+++ b/web/src/views/contacts/ContactDetail.vue@@ -7,6 +7,7 @@ import { contactListsApi } from '../../api/contactLists'import type { Contact, ContactListWithCount } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const route = useRoute()const router = useRouter()@@ -86,6 +87,9 @@ function formatDate(date: string | null) {if (!date) return '-'return new Date(date).toLocaleString()}+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showAddToListModal.value = false;+});</script><template>@@ -170,8 +174,9 @@ function formatDate(date: string | null) {</div><!-- Add to Contact List Modal -->- <div v-if="showAddToListModal" class="modal-overlay" @click.self="showAddToListModal = false">- <div class="modal">+ <div v-if="showAddToListModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h2>Add to Contact List</h2></div>diff --git a/web/src/views/contacts/Contacts.vue b/web/src/views/contacts/Contacts.vueindex 8049525..65b81bd 100644--- a/web/src/views/contacts/Contacts.vue+++ b/web/src/views/contacts/Contacts.vue@@ -9,6 +9,7 @@ import Pagination from '../../components/Pagination.vue'import { usePagination } from '../../composables/usePagination'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const router = useRouter()const notify = useNotificationStore()@@ -97,7 +98,9 @@ async function addToList() {function formatDate(dateStr: string): string {return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showAddToListModal.value = false;+});</script><template>@@ -178,8 +181,9 @@ function formatDate(dateStr: string): string {</div><!-- Add to Contact List Modal -->- <div v-if="showAddToListModal" class="modal-overlay" @click.self="showAddToListModal = false">- <div class="modal">+ <div v-if="showAddToListModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h2>Add to Contact List</h2></div>diff --git a/web/src/views/domains/Domains.vue b/web/src/views/domains/Domains.vueindex ea2880c..98ddd0f 100644--- a/web/src/views/domains/Domains.vue+++ b/web/src/views/domains/Domains.vue@@ -4,6 +4,7 @@ import { domainsApi } from '../../api/domains'import type { Domain, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const notify = useNotificationStore()const { confirm } = useConfirm()@@ -113,7 +114,9 @@ function nextPage() {fetchDomains()}}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showAddModal.value = false;+});onMounted(fetchDomains)</script>@@ -235,8 +238,9 @@ onMounted(fetchDomains)</template><!-- Add Domain Modal -->- <div v-if="showAddModal" class="modal-overlay" @click.self="showAddModal = false">- <div class="modal">+ <div v-if="showAddModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Add Domain</h3></div>diff --git a/web/src/views/languages/Languages.vue b/web/src/views/languages/Languages.vueindex b566f53..e5326e6 100644--- a/web/src/views/languages/Languages.vue+++ b/web/src/views/languages/Languages.vue@@ -4,6 +4,7 @@ import { languagesApi } from '../../api/languages'import type { Language, LanguageInput, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const notify = useNotificationStore()const { confirm } = useConfirm()@@ -98,7 +99,9 @@ async function deleteLanguage(lang: Language) {function formatDate(dateStr: string): string {return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ closeModal()+});onMounted(() => loadLanguages())</script>@@ -171,8 +174,9 @@ onMounted(() => loadLanguages())</div><!-- Create/Edit Language Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="closeModal">- <div class="modal" style="max-width: 480px;">+ <div v-if="showModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" style="max-width: 480px;" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>{{ editing ? 'Edit Language' : 'Add Language' }}</h3></div>diff --git a/web/src/views/smtp/SmtpServerDetail.vue b/web/src/views/smtp/SmtpServerDetail.vueindex 2fd3881..2bc91b5 100644--- a/web/src/views/smtp/SmtpServerDetail.vue+++ b/web/src/views/smtp/SmtpServerDetail.vue@@ -5,6 +5,7 @@ import { smtpApi } from '../../api/smtp'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'import type { SmtpServer, SmtpServerInput } from '../../api/types'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const route = useRoute()const router = useRouter()@@ -126,7 +127,9 @@ function formatDate(date: string | null) {if (!date) return '-'return new Date(date).toLocaleString()}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showModal.value = false;+});onMounted(fetchServer)</script>@@ -236,9 +239,9 @@ onMounted(fetchServer)</div><!-- Edit Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="showModal = false">+ <div v-if="showModal" class="modal-overlay" @mousedown="watchClickStart" @mouseup="confirmClickEnd"><div class="modal">- <div class="modal-header">+ <div class="modal-header" @mousedown.stop @mouseup.stop><h3>Edit SMTP Server</h3></div><form @submit.prevent="save">diff --git a/web/src/views/smtp/SmtpServers.vue b/web/src/views/smtp/SmtpServers.vueindex ff5c1f1..6a2a0eb 100644--- a/web/src/views/smtp/SmtpServers.vue+++ b/web/src/views/smtp/SmtpServers.vue@@ -5,6 +5,7 @@ import { smtpApi } from '../../api/smtp'import type { SmtpServer, SmtpServerInput, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const router = useRouter()const notify = useNotificationStore()@@ -119,7 +120,9 @@ function nextPage() {fetchServers()}}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showModal.value = false;+});onMounted(fetchServers)</script>@@ -203,8 +206,8 @@ onMounted(fetchServers)</template><!-- Create/Edit Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="showModal = false">- <div class="modal">+ <div v-if="showModal" class="modal-overlay" @mousedown="watchClickStart" @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>{{ editing ? 'Edit SMTP Server' : 'Add SMTP Server' }}</h3></div>diff --git a/web/src/views/stylesheets/Stylesheets.vue b/web/src/views/stylesheets/Stylesheets.vueindex e0426e1..9b4659f 100644--- a/web/src/views/stylesheets/Stylesheets.vue+++ b/web/src/views/stylesheets/Stylesheets.vue@@ -4,6 +4,7 @@ import { stylesheetsApi } from '../../api/stylesheets'import type { StyleSheet, StyleSheetInput, Pageable } from '../../api/types'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const notify = useNotificationStore()const { confirm } = useConfirm()@@ -98,7 +99,9 @@ async function deleteStylesheet(sheet: StyleSheet) {function formatDate(dateStr: string): string {return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ closeModal()+});onMounted(() => loadStylesheets())</script>@@ -174,8 +177,9 @@ onMounted(() => loadStylesheets())</div><!-- Create/Edit Stylesheet Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="closeModal">- <div class="modal" style="max-width: 640px;">+ <div v-if="showModal" class="modal-overlay" @mousedown="watchClickStart"+ @mouseup="confirmClickEnd">+ <div class="modal" style="max-width: 640px;" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>{{ editing ? 'Edit Stylesheet' : 'Create Stylesheet' }}</h3></div>diff --git a/web/src/views/templates/TemplateDetail.vue b/web/src/views/templates/TemplateDetail.vueindex 3ee0770..c8f5542 100644--- a/web/src/views/templates/TemplateDetail.vue+++ b/web/src/views/templates/TemplateDetail.vue@@ -1,9 +1,9 @@<script setup lang="ts">-import { ref, onMounted, computed } from 'vue'-import { useRoute, useRouter } from 'vue-router'-import { templatesApi } from '../../api/templates'-import { stylesheetsApi } from '../../api/stylesheets'-import { languagesApi } from '../../api/languages'+import { ref, onMounted, computed } from "vue";+import { useRoute, useRouter } from "vue-router";+import { templatesApi } from "../../api/templates";+import { stylesheetsApi } from "../../api/stylesheets";+import { languagesApi } from "../../api/languages";import type {Template,TemplateVersion,@@ -12,349 +12,396 @@ import type {TemplatePreview,StyleSheet,Language,-} from '../../api/types'-import { useNotificationStore } from '../../stores/notification'-import { useConfirm } from '../../composables/useConfirm'--const route = useRoute()-const router = useRouter()-const notify = useNotificationStore()-const { confirm } = useConfirm()--const templateId = Number(route.params.id)--const template = ref<Template | null>(null)-const versions = ref<TemplateVersion[]>([])-const localizations = ref<TemplateLocalization[]>([])-const stylesheets = ref<StyleSheet[]>([])-const languages = ref<Language[]>([])-const loading = ref(true)-const selectedVersion = ref<TemplateVersion | null>(null)+} from "../../api/types";+import { useNotificationStore } from "../../stores/notification";+import { useConfirm } from "../../composables/useConfirm";+import { useModalSafeClose } from "../../composables/useModalSafeClose";++const route = useRoute();+const router = useRouter();+const notify = useNotificationStore();+const { confirm } = useConfirm();++const templateId = Number(route.params.id);++const template = ref<Template | null>(null);+const versions = ref<TemplateVersion[]>([]);+const localizations = ref<TemplateLocalization[]>([]);+const stylesheets = ref<StyleSheet[]>([]);+const languages = ref<Language[]>([]);+const loading = ref(true);+const selectedVersion = ref<TemplateVersion | null>(null);// Localization modal-const showLocModal = ref(false)-const editingLoc = ref<TemplateLocalization | null>(null)-const savingLoc = ref(false)+const showLocModal = ref(false);+const editingLoc = ref<TemplateLocalization | null>(null);+const savingLoc = ref(false);const locForm = ref<TemplateLocalizationInput>({- language: '',- subject_template: '',- html_template: '',- text_template: '',-})+ language: "",+ subject_template: "",+ html_template: "",+ text_template: "",+});// Preview-const showPreview = ref(false)-const previewLang = ref('')-const previewData = ref('{\n "name": "John",\n "company": "Acme"\n}')-const preview = ref<TemplatePreview | null>(null)-const previewLoading = ref(false)-const previewError = ref('')+const showPreview = ref(false);+const previewLang = ref("");+const previewData = ref('{\n "name": "John",\n "company": "Acme"\n}');+const preview = ref<TemplatePreview | null>(null);+const previewLoading = ref(false);+const previewError = ref("");// Send test-const showSendTest = ref(false)-const sendingTest = ref(false)+const showSendTest = ref(false);+const sendingTest = ref(false);const sendTestForm = ref({- to: '',- from: '',- language: '',+ to: "",+ from: "",+ language: "",data: '{\n "name": "John",\n "company": "Acme"\n}',-})+});// Version creation-const creatingVersion = ref(false)-const newVersionStylesheetId = ref<number | null>(null)+const creatingVersion = ref(false);+const newVersionStylesheetId = ref<number | null>(null);// Version stylesheet edit-const showVersionStylesheetModal = ref(false)-const editingVersion = ref<TemplateVersion | null>(null)-const editVersionStylesheetId = ref<number | null>(null)-const savingVersionStylesheet = ref(false)+const showVersionStylesheetModal = ref(false);+const editingVersion = ref<TemplateVersion | null>(null);+const editVersionStylesheetId = ref<number | null>(null);+const savingVersionStylesheet = ref(false);const isActive = computed(() => (v: TemplateVersion) =>- template.value?.active_version_id === v.id,-)+ template.value?.active_version_id === v.id+);async function loadAll() {- loading.value = true+ loading.value = true;try {const [tmplRes, versionsRes, ssRes, langRes] = await Promise.all([templatesApi.list(0, 100),templatesApi.listVersions(templateId),stylesheetsApi.list(0, 100),languagesApi.list(0, 100),- ])- template.value = tmplRes.data.data.find((t: Template) => t.id === templateId) || null- versions.value = versionsRes.data.data || []- stylesheets.value = ssRes.data.data || []- languages.value = langRes.data.data || []+ ]);+ template.value = tmplRes.data.data.find((t: Template) => t.id === templateId) || null;+ versions.value = versionsRes.data.data || [];+ stylesheets.value = ssRes.data.data || [];+ languages.value = langRes.data.data || [];if (!template.value) {- notify.error('Template not found')- return+ notify.error("Template not found");+ return;}// Auto-select the active version or the first oneif (versions.value.length > 0) {- const active = versions.value.find(v => v.id === template.value?.active_version_id)- selectVersion(active || versions.value[0])+ const active = versions.value.find(+ (v) => v.id === template.value?.active_version_id+ );+ selectVersion(active || versions.value[0]);}} catch {- notify.error('Failed to load template')+ notify.error("Failed to load template");} finally {- loading.value = false+ loading.value = false;}}function selectVersion(v: TemplateVersion) {- selectedVersion.value = v- localizations.value = v.localizations || []+ selectedVersion.value = v;+ localizations.value = v.localizations || [];}function syncLocalizationsToVersion() {- if (!selectedVersion.value) return- selectedVersion.value.localizations = [...localizations.value]- const idx = versions.value.findIndex(v => v.id === selectedVersion.value!.id)- if (idx >= 0) versions.value[idx].localizations = [...localizations.value]+ if (!selectedVersion.value) return;+ selectedVersion.value.localizations = [...localizations.value];+ const idx = versions.value.findIndex((v) => v.id === selectedVersion.value!.id);+ if (idx >= 0) versions.value[idx].localizations = [...localizations.value];}async function createVersion() {- creatingVersion.value = true+ creatingVersion.value = true;try {const res = await templatesApi.createVersion(templateId, {stylesheet_id: newVersionStylesheetId.value,- sample_data: template.value?.sample_data || '',- })- versions.value.unshift(res.data.data)- selectVersion(res.data.data)- notify.success(`Version ${res.data.data.version} created`)- newVersionStylesheetId.value = null+ sample_data: template.value?.sample_data || "",+ });+ versions.value.unshift(res.data.data);+ selectVersion(res.data.data);+ notify.success(`Version ${res.data.data.version} created`);+ newVersionStylesheetId.value = null;} catch {- notify.error('Failed to create version')+ notify.error("Failed to create version");} finally {- creatingVersion.value = false+ creatingVersion.value = false;}}function openEditVersionStylesheet(v: TemplateVersion) {- editingVersion.value = v- editVersionStylesheetId.value = v.stylesheet_id ?? null- showVersionStylesheetModal.value = true+ editingVersion.value = v;+ editVersionStylesheetId.value = v.stylesheet_id ?? null;+ showVersionStylesheetModal.value = true;}async function saveVersionStylesheet() {- if (!editingVersion.value) return- savingVersionStylesheet.value = true+ if (!editingVersion.value) return;+ savingVersionStylesheet.value = true;try {const res = await templatesApi.updateVersion(templateId, editingVersion.value.id, {stylesheet_id: editVersionStylesheetId.value,- })- const idx = versions.value.findIndex(v => v.id === editingVersion.value!.id)- if (idx >= 0) versions.value[idx] = res.data.data+ });+ const idx = versions.value.findIndex((v) => v.id === editingVersion.value!.id);+ if (idx >= 0) versions.value[idx] = res.data.data;if (selectedVersion.value?.id === editingVersion.value.id) {- selectedVersion.value = res.data.data+ selectedVersion.value = res.data.data;}- notify.success('Version stylesheet updated')- showVersionStylesheetModal.value = false+ notify.success("Version stylesheet updated");+ showVersionStylesheetModal.value = false;} catch {- notify.error('Failed to update version stylesheet')+ notify.error("Failed to update version stylesheet");} finally {- savingVersionStylesheet.value = false+ savingVersionStylesheet.value = false;}}async function activateVersion(v: TemplateVersion) {try {- const res = await templatesApi.activateVersion(templateId, v.id)- template.value = res.data.data- notify.success(`Version ${v.version} activated`)+ const res = await templatesApi.activateVersion(templateId, v.id);+ template.value = res.data.data;+ notify.success(`Version ${v.version} activated`);} catch {- notify.error('Failed to activate version')+ notify.error("Failed to activate version");}}async function deleteVersion(v: TemplateVersion) {if (template.value?.active_version_id === v.id) {- notify.error('Cannot delete the active version')- return+ notify.error("Cannot delete the active version");+ return;}const confirmed = await confirm({- title: 'Delete Version',+ title: "Delete Version",message: `Delete version ${v.version}? All its localizations will also be deleted.`,- confirmText: 'Delete',- variant: 'danger',- })- if (!confirmed) return+ confirmText: "Delete",+ variant: "danger",+ });+ if (!confirmed) return;try {- await templatesApi.deleteVersion(templateId, v.id)- versions.value = versions.value.filter(x => x.id !== v.id)+ await templatesApi.deleteVersion(templateId, v.id);+ versions.value = versions.value.filter((x) => x.id !== v.id);if (selectedVersion.value?.id === v.id) {- selectedVersion.value = versions.value[0] || null- if (selectedVersion.value) selectVersion(selectedVersion.value)- else localizations.value = []+ selectedVersion.value = versions.value[0] || null;+ if (selectedVersion.value) selectVersion(selectedVersion.value);+ else localizations.value = [];}- notify.success('Version deleted')+ notify.success("Version deleted");} catch {- notify.error('Failed to delete version')+ notify.error("Failed to delete version");}}function openCreateLoc() {- editingLoc.value = null- locForm.value = { language: '', subject_template: '', html_template: '', text_template: '' }- showLocModal.value = true+ editingLoc.value = null;+ locForm.value = {+ language: "",+ subject_template: "",+ html_template: "",+ text_template: "",+ };+ showLocModal.value = true;}function openEditLoc(l: TemplateLocalization) {- editingLoc.value = l+ editingLoc.value = l;locForm.value = {language: l.language,subject_template: l.subject_template,html_template: l.html_template,text_template: l.text_template,- }- showLocModal.value = true+ };+ showLocModal.value = true;}async function saveLoc() {- if (!selectedVersion.value) return- savingLoc.value = true+ if (!selectedVersion.value) return;+ savingLoc.value = true;try {if (editingLoc.value) {const res = await templatesApi.updateLocalization(editingLoc.value.id, {subject_template: locForm.value.subject_template,html_template: locForm.value.html_template,text_template: locForm.value.text_template,- })- const idx = localizations.value.findIndex(l => l.id === editingLoc.value!.id)- if (idx >= 0) localizations.value[idx] = res.data.data- notify.success('Localization updated')+ });+ const idx = localizations.value.findIndex((l) => l.id === editingLoc.value!.id);+ if (idx >= 0) localizations.value[idx] = res.data.data;+ notify.success("Localization updated");} else {- const res = await templatesApi.createLocalization(templateId, selectedVersion.value.id, locForm.value)- localizations.value.push(res.data.data)- notify.success('Localization created')+ const res = await templatesApi.createLocalization(+ templateId,+ selectedVersion.value.id,+ locForm.value+ );+ localizations.value.push(res.data.data);+ notify.success("Localization created");}- syncLocalizationsToVersion()- showLocModal.value = false+ syncLocalizationsToVersion();+ showLocModal.value = false;} catch {- notify.error(editingLoc.value ? 'Failed to update localization' : 'Language already exists for this version')+ notify.error(+ editingLoc.value+ ? "Failed to update localization"+ : "Language already exists for this version"+ );} finally {- savingLoc.value = false+ savingLoc.value = false;}}async function deleteLoc(l: TemplateLocalization) {const confirmed = await confirm({- title: 'Delete Localization',+ title: "Delete Localization",message: `Delete the "${l.language}" localization? This cannot be undone.`,- confirmText: 'Delete',- variant: 'danger',- })- if (!confirmed) return+ confirmText: "Delete",+ variant: "danger",+ });+ if (!confirmed) return;try {- await templatesApi.deleteLocalization(l.id)- localizations.value = localizations.value.filter(x => x.id !== l.id)- syncLocalizationsToVersion()- notify.success('Localization deleted')+ await templatesApi.deleteLocalization(l.id);+ localizations.value = localizations.value.filter((x) => x.id !== l.id);+ syncLocalizationsToVersion();+ notify.success("Localization deleted");} catch {- notify.error('Failed to delete localization')+ notify.error("Failed to delete localization");}}async function renderPreview() {- if (!selectedVersion.value || !previewLang.value) return- previewLoading.value = true- previewError.value = ''- preview.value = null+ if (!selectedVersion.value || !previewLang.value) return;+ previewLoading.value = true;+ previewError.value = "";+ preview.value = null;- let data: Record<string, any> = {}+ let data: Record<string, any> = {};try {- data = JSON.parse(previewData.value)+ data = JSON.parse(previewData.value);} catch {- previewError.value = 'Invalid JSON in sample data'- previewLoading.value = false- return+ previewError.value = "Invalid JSON in sample data";+ previewLoading.value = false;+ return;}try {- const res = await templatesApi.previewLocalization(templateId, selectedVersion.value.id, {- language: previewLang.value,- template_data: data,- })- preview.value = res.data.data+ const res = await templatesApi.previewLocalization(+ templateId,+ selectedVersion.value.id,+ {+ language: previewLang.value,+ template_data: data,+ }+ );+ preview.value = res.data.data;} catch (e: any) {- previewError.value = e.response?.data?.error?.message || 'Failed to render preview'+ previewError.value = e.response?.data?.error?.message || "Failed to render preview";} finally {- previewLoading.value = false+ previewLoading.value = false;}}function openSendTest() {sendTestForm.value = {- to: '',- from: '',- language: template.value?.default_language || 'en',- data: selectedVersion.value?.sample_data || '{\n "name": "John",\n "company": "Acme"\n}',- }- showSendTest.value = true+ to: "",+ from: "",+ language: template.value?.default_language || "en",+ data:+ selectedVersion.value?.sample_data ||+ '{\n "name": "John",\n "company": "Acme"\n}',+ };+ showSendTest.value = true;}async function sendTest() {- if (!sendTestForm.value.to.trim()) return- sendingTest.value = true+ if (!sendTestForm.value.to.trim()) return;+ sendingTest.value = true;- let data: Record<string, any> = {}+ let data: Record<string, any> = {};try {- data = JSON.parse(sendTestForm.value.data)+ data = JSON.parse(sendTestForm.value.data);} catch {- notify.error('Invalid JSON in sample data')- sendingTest.value = false- return+ notify.error("Invalid JSON in sample data");+ sendingTest.value = false;+ return;}try {- const to = sendTestForm.value.to.split(',').map(e => e.trim()).filter(Boolean)+ const to = sendTestForm.value.to+ .split(",")+ .map((e) => e.trim())+ .filter(Boolean);await templatesApi.sendTest(templateId, {to,from: sendTestForm.value.from || undefined,language: sendTestForm.value.language || undefined,template_data: data,- })- notify.success('Test email sent')- showSendTest.value = false+ });+ notify.success("Test email sent");+ showSendTest.value = false;} catch (e: any) {- notify.error(e.response?.data?.error?.message || 'Failed to send test email')+ notify.error(e.response?.data?.error?.message || "Failed to send test email");} finally {- sendingTest.value = false+ sendingTest.value = false;}}function openPreview(lang: string) {- previewLang.value = lang- preview.value = null- previewError.value = ''+ previewLang.value = lang;+ preview.value = null;+ previewError.value = "";if (template.value?.sample_data) {- previewData.value = template.value.sample_data+ previewData.value = template.value.sample_data;} else if (selectedVersion.value?.sample_data) {- previewData.value = selectedVersion.value.sample_data+ previewData.value = selectedVersion.value.sample_data;}- showPreview.value = true- renderPreview()+ showPreview.value = true;+ renderPreview();}function formatDate(dateStr: string): string {- return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })+ return new Date(dateStr).toLocaleDateString(undefined, {+ year: "numeric",+ month: "short",+ day: "numeric",+ });}-onMounted(loadAll)+const closeActiveModal = () => {+ if (showVersionStylesheetModal.value) showVersionStylesheetModal.value = false;+ if (showPreview.value) showPreview.value = false;+ if (showSendTest.value) showSendTest.value = false;+ if (showLocModal.value) showLocModal.value = false;+};++const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ closeActiveModal();+});+onMounted(loadAll);</script><template><div><div class="page-header">- <h1>{{ template?.name || 'Template' }}</h1>+ <h1>{{ template?.name || "Template" }}</h1><div class="flex gap-2">- <button class="btn btn-primary" @click="openSendTest" :disabled="!template?.active_version_id">Send Test</button>- <button class="btn btn-secondary" @click="router.push('/templates')">Back to Templates</button>+ <button+ class="btn btn-primary"+ @click="openSendTest"+ :disabled="!template?.active_version_id"+ >+ Send Test+ </button>+ <button class="btn btn-secondary" @click="router.push('/templates')">+ Back to Templates+ </button></div></div>@@ -364,7 +411,7 @@ onMounted(loadAll)<template v-else-if="template"><!-- Template Info -->- <div class="card" style="margin-bottom: 24px;">+ <div class="card" style="margin-bottom: 24px"><div class="card-body"><table><tbody>@@ -378,7 +425,9 @@ onMounted(loadAll)</tr><tr><td class="info-label">Default Language</td>- <td><span class="badge badge-info">{{ template.default_language }}</span></td>+ <td>+ <span class="badge badge-info">{{ template.default_language }}</span>+ </td></tr><tr><td class="info-label">Active Version</td>@@ -399,16 +448,22 @@ onMounted(loadAll)</div><!-- Versions -->- <div class="card" style="margin-bottom: 24px;">+ <div class="card" style="margin-bottom: 24px"><div class="card-header"><h2>Versions</h2><div class="flex gap-2 align-center"><select v-model="newVersionStylesheetId" class="form-select form-select-sm"><option :value="null">No stylesheet</option>- <option v-for="ss in stylesheets" :key="ss.id" :value="ss.id">{{ ss.name }}</option>+ <option v-for="ss in stylesheets" :key="ss.id" :value="ss.id">+ {{ ss.name }}+ </option></select>- <button class="btn btn-primary btn-sm" @click="createVersion" :disabled="creatingVersion">- {{ creatingVersion ? 'Creating...' : 'New Version' }}+ <button+ class="btn btn-primary btn-sm"+ @click="createVersion"+ :disabled="creatingVersion"+ >+ {{ creatingVersion ? "Creating..." : "New Version" }}</button></div></div>@@ -433,12 +488,16 @@ onMounted(loadAll)v-for="v in versions":key="v.id":class="{ 'row-selected': selectedVersion?.id === v.id }"- style="cursor: pointer;"+ style="cursor: pointer"@click="selectVersion(v)">- <td><strong>v{{ v.version }}</strong></td><td>- <span v-if="v.stylesheet" class="badge badge-neutral">{{ v.stylesheet.name }}</span>+ <strong>v{{ v.version }}</strong>+ </td>+ <td>+ <span v-if="v.stylesheet" class="badge badge-neutral">{{+ v.stylesheet.name+ }}</span><span v-else class="text-muted">—</span></td><td>{{ formatDate(v.created_at) }}</td>@@ -451,17 +510,23 @@ onMounted(loadAll)<buttonclass="btn btn-secondary btn-sm"@click="openEditVersionStylesheet(v)"- >Edit</button>+ >+ Edit+ </button><buttonv-if="!isActive(v)"class="btn btn-primary btn-sm"@click="activateVersion(v)"- >Activate</button>+ >+ Activate+ </button><buttonv-if="!isActive(v)"class="btn btn-danger btn-sm"@click="deleteVersion(v)"- >Delete</button>+ >+ Delete+ </button></div></td></tr>@@ -474,7 +539,9 @@ onMounted(loadAll)<div v-if="selectedVersion" class="card"><div class="card-header"><h2>Localizations — v{{ selectedVersion.version }}</h2>- <button class="btn btn-primary btn-sm" @click="openCreateLoc">Add Language</button>+ <button class="btn btn-primary btn-sm" @click="openCreateLoc">+ Add Language+ </button></div><div v-if="localizations.length === 0" class="empty-state">@@ -495,18 +562,34 @@ onMounted(loadAll)<tr v-for="l in localizations" :key="l.id"><td><strong>{{ l.language }}</strong>- <span v-if="l.language === template.default_language" class="badge badge-info" style="margin-left: 6px;">default</span>+ <span+ v-if="l.language === template.default_language"+ class="badge badge-info"+ style="margin-left: 6px"+ >default</span+ >+ </td>+ <td class="truncate" style="max-width: 300px">+ {{ l.subject_template }}</td>- <td class="truncate" style="max-width: 300px;">{{ l.subject_template }}</td><td><span v-if="l.updated_at">{{ formatDate(l.updated_at) }}</span><span v-else>{{ formatDate(l.created_at) }}</span></td><td><div class="flex gap-2">- <button class="btn btn-secondary btn-sm" @click="openPreview(l.language)">Preview</button>- <button class="btn btn-secondary btn-sm" @click="openEditLoc(l)">Edit</button>- <button class="btn btn-danger btn-sm" @click="deleteLoc(l)">Delete</button>+ <button+ class="btn btn-secondary btn-sm"+ @click="openPreview(l.language)"+ >+ Preview+ </button>+ <button class="btn btn-secondary btn-sm" @click="openEditLoc(l)">+ Edit+ </button>+ <button class="btn btn-danger btn-sm" @click="deleteLoc(l)">+ Delete+ </button></div></td></tr>@@ -521,71 +604,122 @@ onMounted(loadAll)</div><!-- Localization Create/Edit Modal -->- <div v-if="showLocModal" class="modal-overlay" @click.self="showLocModal = false">- <div class="modal" style="max-width: 720px;">+ <div+ v-if="showLocModal"+ class="modal-overlay"+ @mousedown="watchClickStart"+ @mouseup="confirmClickEnd"+ >+ <div class="modal" style="max-width: 720px" @mousedown.stop @mouseup.stop><div class="modal-header">- <h3>{{ editingLoc ? `Edit Localization (${editingLoc.language})` : 'Add Localization' }}</h3>+ <h3>+ {{+ editingLoc+ ? `Edit Localization (${editingLoc.language})`+ : "Add Localization"+ }}+ </h3></div><div class="modal-body"><div v-if="!editingLoc" class="form-group"><label class="form-label">Language</label><select v-model="locForm.language" class="form-select"><option value="" disabled>Select a language</option>- <option v-for="lang in languages" :key="lang.id" :value="lang.code">{{ lang.name }} ({{ lang.code }})</option>+ <option v-for="lang in languages" :key="lang.id" :value="lang.code">+ {{ lang.name }} ({{ lang.code }})+ </option></select><span class="form-hint">Choose from your configured languages</span></div><div class="form-group"><label class="form-label">Subject Template</label>- <input v-model="locForm.subject_template" class="form-input" placeholder="e.g. Welcome {{name}}!" />+ <input+ v-model="locForm.subject_template"+ class="form-input"+ placeholder="e.g. Welcome {{name}}!"+ /></div><div class="form-group"><label class="form-label">HTML Template</label>- <textarea v-model="locForm.html_template" class="form-textarea" rows="8" placeholder="<html>...</html>"></textarea>+ <textarea+ v-model="locForm.html_template"+ class="form-textarea"+ rows="8"+ placeholder="<html>...</html>"+ ></textarea></div><div class="form-group"><label class="form-label">Text Template</label>- <textarea v-model="locForm.text_template" class="form-textarea" rows="4" placeholder="Plain text version..."></textarea>+ <textarea+ v-model="locForm.text_template"+ class="form-textarea"+ rows="4"+ placeholder="Plain text version..."+ ></textarea></div></div><div class="modal-footer"><button class="btn btn-secondary" @click="showLocModal = false">Cancel</button><buttonclass="btn btn-primary"- :disabled="savingLoc || (!editingLoc && !locForm.language.trim()) || !locForm.subject_template.trim()"+ :disabled="+ savingLoc ||+ (!editingLoc && !locForm.language.trim()) ||+ !locForm.subject_template.trim()+ "@click="saveLoc">- {{ savingLoc ? 'Saving...' : (editingLoc ? 'Update' : 'Create') }}+ {{ savingLoc ? "Saving..." : editingLoc ? "Update" : "Create" }}</button></div></div></div><!-- Send Test Modal -->- <div v-if="showSendTest" class="modal-overlay" @click.self="showSendTest = false">- <div class="modal" style="max-width: 560px;">+ <div+ v-if="showSendTest"+ class="modal-overlay"+ @mousedown="watchClickStart"+ @mouseup="confirmClickEnd"+ >+ <div class="modal" style="max-width: 560px" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Send Test Email</h3></div><div class="modal-body"><div class="form-group"><label class="form-label">To</label>- <input v-model="sendTestForm.to" class="form-input" placeholder="[email protected]" />+ <input+ v-model="sendTestForm.to"+ class="form-input"+ placeholder="[email protected]"+ /><span class="form-hint">Comma-separated for multiple recipients</span></div><div class="form-group"><label class="form-label">From (optional)</label>- <input v-model="sendTestForm.from" class="form-input" placeholder="noreply@localhost" />+ <input+ v-model="sendTestForm.from"+ class="form-input"+ placeholder="noreply@localhost"+ /></div><div class="form-group"><label class="form-label">Language</label><select v-model="sendTestForm.language" class="form-select">- <option v-for="l in localizations" :key="l.language" :value="l.language">{{ l.language }}</option>+ <option v-for="l in localizations" :key="l.language" :value="l.language">+ {{ l.language }}+ </option></select></div><div class="form-group"><label class="form-label">Sample Data (JSON)</label>- <textarea v-model="sendTestForm.data" class="form-textarea" rows="4" placeholder='{"name": "John"}'></textarea>+ <textarea+ v-model="sendTestForm.data"+ class="form-textarea"+ rows="4"+ placeholder='{"name": "John"}'+ ></textarea></div></div><div class="modal-footer">@@ -595,25 +729,40 @@ onMounted(loadAll):disabled="sendingTest || !sendTestForm.to.trim()"@click="sendTest">- {{ sendingTest ? 'Sending...' : 'Send Test' }}+ {{ sendingTest ? "Sending..." : "Send Test" }}</button></div></div></div><!-- Preview Modal -->- <div v-if="showPreview" class="modal-overlay" @click.self="showPreview = false">- <div class="modal" style="max-width: 800px;">+ <div+ v-if="showPreview"+ class="modal-overlay"+ @mousedown="watchClickStart"+ @mouseup="confirmClickEnd"+ >+ <div class="modal" style="max-width: 800px" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Preview — {{ previewLang }}</h3></div><div class="modal-body"><div class="form-group"><label class="form-label">Sample Data (JSON)</label>- <textarea v-model="previewData" class="form-textarea" rows="3" placeholder='{"name": "John"}'></textarea>+ <textarea+ v-model="previewData"+ class="form-textarea"+ rows="3"+ placeholder='{"name": "John"}'+ ></textarea></div>- <button class="btn btn-secondary btn-sm" style="margin-bottom: 16px;" @click="renderPreview" :disabled="previewLoading">- {{ previewLoading ? 'Rendering...' : 'Refresh Preview' }}+ <button+ class="btn btn-secondary btn-sm"+ style="margin-bottom: 16px"+ @click="renderPreview"+ :disabled="previewLoading"+ >+ {{ previewLoading ? "Rendering..." : "Refresh Preview" }}</button><div v-if="previewError" class="preview-error">{{ previewError }}</div>@@ -641,8 +790,13 @@ onMounted(loadAll)</div></div><!-- Edit Version Stylesheet Modal -->- <div v-if="showVersionStylesheetModal" class="modal-overlay" @click.self="showVersionStylesheetModal = false">- <div class="modal" style="max-width: 420px;">+ <div+ v-if="showVersionStylesheetModal"+ class="modal-overlay"+ @mousedown="watchClickStart"+ @mouseup="confirmClickEnd"+ >+ <div class="modal" style="max-width: 420px" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Edit Version v{{ editingVersion?.version }} Stylesheet</h3></div>@@ -651,18 +805,22 @@ onMounted(loadAll)<label class="form-label">Stylesheet</label><select v-model="editVersionStylesheetId" class="form-select"><option :value="null">No stylesheet</option>- <option v-for="ss in stylesheets" :key="ss.id" :value="ss.id">{{ ss.name }}</option>+ <option v-for="ss in stylesheets" :key="ss.id" :value="ss.id">+ {{ ss.name }}+ </option></select></div></div><div class="modal-footer">- <button class="btn btn-secondary" @click="showVersionStylesheetModal = false">Cancel</button>+ <button class="btn btn-secondary" @click="showVersionStylesheetModal = false">+ Cancel+ </button><buttonclass="btn btn-primary":disabled="savingVersionStylesheet"@click="saveVersionStylesheet">- {{ savingVersionStylesheet ? 'Saving...' : 'Save' }}+ {{ savingVersionStylesheet ? "Saving..." : "Save" }}</button></div></div>@@ -731,7 +889,7 @@ onMounted(loadAll)background: var(--bg-tertiary);border: 1px solid var(--border-primary);border-radius: var(--radius);- font-family: 'JetBrains Mono', 'Fira Code', monospace;+ font-family: "JetBrains Mono", "Fira Code", monospace;font-size: 13px;color: var(--text-secondary);white-space: pre-wrap;diff --git a/web/src/views/templates/Templates.vue b/web/src/views/templates/Templates.vueindex 902a3b2..3080140 100644--- a/web/src/views/templates/Templates.vue+++ b/web/src/views/templates/Templates.vue@@ -1,170 +1,192 @@<script setup lang="ts">-import { ref, onMounted } from 'vue'-import { useRouter } from 'vue-router'-import { templatesApi } from '../../api/templates'-import { languagesApi } from '../../api/languages'-import type { Template, TemplateInput, TemplateExport, Language, Pageable } from '../../api/types'-import { useNotificationStore } from '../../stores/notification'-import { useConfirm } from '../../composables/useConfirm'+import { ref, onMounted } from "vue";+import { useRouter } from "vue-router";+import { templatesApi } from "../../api/templates";+import { languagesApi } from "../../api/languages";+import type {+ Template,+ TemplateInput,+ TemplateExport,+ Language,+ Pageable,+} from "../../api/types";+import { useNotificationStore } from "../../stores/notification";+import { useConfirm } from "../../composables/useConfirm";+import { useModalSafeClose } from "../../composables/useModalSafeClose";-const router = useRouter()-const notify = useNotificationStore()-const { confirm } = useConfirm()+const router = useRouter();+const notify = useNotificationStore();+const { confirm } = useConfirm();-const templates = ref<Template[]>([])-const pageable = ref<Pageable>({ current_page: 0, size: 20, total_pages: 0, total_elements: 0, empty: true })-const loading = ref(true)+const templates = ref<Template[]>([]);+const pageable = ref<Pageable>({+ current_page: 0,+ size: 20,+ total_pages: 0,+ total_elements: 0,+ empty: true,+});+const loading = ref(true);-const showModal = ref(false)-const editing = ref<Template | null>(null)-const saving = ref(false)+const showModal = ref(false);+const editing = ref<Template | null>(null);+const saving = ref(false);-const languages = ref<Language[]>([])+const languages = ref<Language[]>([]);const form = ref<TemplateInput>({- name: '',- sample_data: '',- default_language: 'en',- description: '',-})+ name: "",+ sample_data: "",+ default_language: "en",+ description: "",+});async function loadLanguages() {try {- const res = await languagesApi.list(0, 100)- languages.value = res.data.data+ const res = await languagesApi.list(0, 100);+ languages.value = res.data.data;} catch {// Non-critical}}function resetForm() {- form.value = { name: '', sample_data: '', default_language: 'en', description: '' }- editing.value = null+ form.value = { name: "", sample_data: "", default_language: "en", description: "" };+ editing.value = null;}function openCreate() {- resetForm()- showModal.value = true+ resetForm();+ showModal.value = true;}function openEdit(template: Template) {- editing.value = template+ editing.value = template;form.value = {name: template.name,- sample_data: template.sample_data || '',- default_language: template.default_language || 'en',- description: template.description || '',- }- showModal.value = true+ sample_data: template.sample_data || "",+ default_language: template.default_language || "en",+ description: template.description || "",+ };+ showModal.value = true;}function closeModal() {- showModal.value = false- resetForm()+ showModal.value = false;+ resetForm();}async function loadTemplates(page = 0) {- loading.value = true+ loading.value = true;try {- const res = await templatesApi.list(page, pageable.value.size)- templates.value = res.data.data- pageable.value = res.data.pageable+ const res = await templatesApi.list(page, pageable.value.size);+ templates.value = res.data.data;+ pageable.value = res.data.pageable;} catch {- notify.error('Failed to load templates')+ notify.error("Failed to load templates");} finally {- loading.value = false+ loading.value = false;}}async function saveTemplate() {- if (!form.value.name.trim()) return- saving.value = true+ if (!form.value.name.trim()) return;+ saving.value = true;try {if (editing.value) {- await templatesApi.update(editing.value.id, form.value)- notify.success('Template updated')+ await templatesApi.update(editing.value.id, form.value);+ notify.success("Template updated");} else {- await templatesApi.create(form.value)- notify.success('Template created')+ await templatesApi.create(form.value);+ notify.success("Template created");}- closeModal()- await loadTemplates(pageable.value.current_page)+ closeModal();+ await loadTemplates(pageable.value.current_page);} catch {- notify.error(editing.value ? 'Failed to update template' : 'Failed to create template')+ notify.error(+ editing.value ? "Failed to update template" : "Failed to create template"+ );} finally {- saving.value = false+ saving.value = false;}}async function deleteTemplate(template: Template) {const confirmed = await confirm({- title: 'Delete Template',+ title: "Delete Template",message: `Are you sure you want to delete "${template.name}"? This action cannot be undone.`,- confirmText: 'Delete',- variant: 'danger',- })- if (!confirmed) return+ confirmText: "Delete",+ variant: "danger",+ });+ if (!confirmed) return;try {- await templatesApi.delete(template.id)- notify.success('Template deleted')- await loadTemplates(pageable.value.current_page)+ await templatesApi.delete(template.id);+ notify.success("Template deleted");+ await loadTemplates(pageable.value.current_page);} catch {- notify.error('Failed to delete template')+ notify.error("Failed to delete template");}}async function exportTemplate(template: Template) {try {- const res = await templatesApi.exportTemplate(template.id)- const data = res.data.data- const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })- const url = URL.createObjectURL(blob)- const a = document.createElement('a')- a.href = url- a.download = `${data.name}.json`- a.click()- URL.revokeObjectURL(url)- notify.success('Template exported')+ const res = await templatesApi.exportTemplate(template.id);+ const data = res.data.data;+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" });+ const url = URL.createObjectURL(blob);+ const a = document.createElement("a");+ a.href = url;+ a.download = `${data.name}.json`;+ a.click();+ URL.revokeObjectURL(url);+ notify.success("Template exported");} catch {- notify.error('Failed to export template')+ notify.error("Failed to export template");}}-const importInput = ref<HTMLInputElement | null>(null)-const importing = ref(false)+const importInput = ref<HTMLInputElement | null>(null);+const importing = ref(false);function triggerImport() {- importInput.value?.click()+ importInput.value?.click();}async function handleImportFile(event: Event) {- const input = event.target as HTMLInputElement- const file = input.files?.[0]- if (!file) return+ const input = event.target as HTMLInputElement;+ const file = input.files?.[0];+ if (!file) return;- importing.value = true+ importing.value = true;try {- const text = await file.text()- const data: TemplateExport = JSON.parse(text)- await templatesApi.importTemplate(data)- notify.success('Template imported')- await loadTemplates(pageable.value.current_page)+ const text = await file.text();+ const data: TemplateExport = JSON.parse(text);+ await templatesApi.importTemplate(data);+ notify.success("Template imported");+ await loadTemplates(pageable.value.current_page);} catch {- notify.error('Failed to import template. Please check the file format.')+ notify.error("Failed to import template. Please check the file format.");} finally {- importing.value = false- input.value = ''+ importing.value = false;+ input.value = "";}}function formatDate(dateStr: string): string {- return new Date(dateStr).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })+ return new Date(dateStr).toLocaleDateString(undefined, {+ year: "numeric",+ month: "short",+ day: "numeric",+ });}+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ closeModal()+});onMounted(() => {- loadTemplates()- loadLanguages()-})+ loadTemplates();+ loadLanguages();+});</script><template>@@ -172,9 +194,15 @@ onMounted(() => {<div class="page-header"><h1>Templates</h1><div class="flex gap-2">- <input ref="importInput" type="file" accept=".json" style="display: none" @change="handleImportFile" />+ <input+ ref="importInput"+ type="file"+ accept=".json"+ style="display: none"+ @change="handleImportFile"+ /><button class="btn btn-secondary" :disabled="importing" @click="triggerImport">- {{ importing ? 'Importing...' : 'Import' }}+ {{ importing ? "Importing..." : "Import" }}</button><button class="btn btn-primary" @click="openCreate">Create Template</button></div>@@ -203,24 +231,61 @@ onMounted(() => {</tr></thead><tbody>- <tr v-for="tmpl in templates" :key="tmpl.id" class="cursor-pointer" @click="router.push({ name: 'template-detail', params: { id: tmpl.id } })">+ <tr+ v-for="tmpl in templates"+ :key="tmpl.id"+ class="cursor-pointer"+ @click="router.push({ name: 'template-detail', params: { id: tmpl.id } })"+ ><td><div>{{ tmpl.name }}</div>- <div v-if="tmpl.description" class="text-muted text-sm">{{ tmpl.description }}</div>+ <div v-if="tmpl.description" class="text-muted text-sm">+ {{ tmpl.description }}+ </div>+ </td>+ <td>+ <span class="badge badge-neutral">{{ tmpl.default_language }}</span></td>- <td><span class="badge badge-neutral">{{ tmpl.default_language }}</span></td><td>- <span v-if="tmpl.active_version_id" class="badge badge-success">v{{ tmpl.active_version?.version || '?' }}</span>+ <span v-if="tmpl.active_version_id" class="badge badge-success"+ >v{{ tmpl.active_version?.version || "?" }}</span+ ><span v-else class="text-muted">—</span></td><td>{{ formatDate(tmpl.created_at) }}</td><td><div class="flex gap-2">- <button class="btn btn-primary btn-sm" @click.stop="router.push({ name: 'template-detail', params: { id: tmpl.id } })">Versions</button>- <button class="btn btn-secondary btn-sm" @click.stop="router.push({ name: 'template-preview', params: { id: tmpl.id } })">Preview</button>- <button class="btn btn-secondary btn-sm" @click.stop="openEdit(tmpl)">Edit</button>- <button class="btn btn-secondary btn-sm" @click.stop="exportTemplate(tmpl)">Export</button>- <button class="btn btn-danger btn-sm" @click.stop="deleteTemplate(tmpl)">Delete</button>+ <button+ class="btn btn-primary btn-sm"+ @click.stop="+ router.push({ name: 'template-detail', params: { id: tmpl.id } })+ "+ >+ Versions+ </button>+ <button+ class="btn btn-secondary btn-sm"+ @click.stop="+ router.push({ name: 'template-preview', params: { id: tmpl.id } })+ "+ >+ Preview+ </button>+ <button class="btn btn-secondary btn-sm" @click.stop="openEdit(tmpl)">+ Edit+ </button>+ <button+ class="btn btn-secondary btn-sm"+ @click.stop="exportTemplate(tmpl)"+ >+ Export+ </button>+ <button+ class="btn btn-danger btn-sm"+ @click.stop="deleteTemplate(tmpl)"+ >+ Delete+ </button></div></td></tr>@@ -230,7 +295,10 @@ onMounted(() => {<div class="pagination"><span class="pagination-info">- Page {{ pageable.current_page + 1 }} of {{ pageable.total_pages }} ({{ pageable.total_elements }} templates)+ Page {{ pageable.current_page + 1 }} of {{ pageable.total_pages }} ({{+ pageable.total_elements+ }}+ templates)</span><div class="pagination-buttons"><button@@ -253,32 +321,56 @@ onMounted(() => {</div><!-- Create/Edit Template Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="closeModal">- <div class="modal" style="max-width: 560px;">+ <div+ v-if="showModal"+ class="modal-overlay"+ @mousedown="watchClickStart"+ @mouseup="confirmClickEnd"+ >+ <div class="modal" style="max-width: 560px" @mousedown.stop @mouseup.stop><div class="modal-header">- <h3>{{ editing ? 'Edit Template' : 'Create Template' }}</h3>+ <h3>{{ editing ? "Edit Template" : "Create Template" }}</h3></div><div class="modal-body"><div class="form-group"><label class="form-label">Name</label>- <input v-model="form.name" class="form-input" placeholder="e.g. Welcome Email" />+ <input+ v-model="form.name"+ class="form-input"+ placeholder="e.g. Welcome Email"+ /></div><div class="form-group"><label class="form-label">Description</label>- <input v-model="form.description" class="form-input" placeholder="e.g. Sent after user registration" />+ <input+ v-model="form.description"+ class="form-input"+ placeholder="e.g. Sent after user registration"+ /></div><div class="form-group"><label class="form-label">Default Language</label><select v-model="form.default_language" class="form-select">- <option v-for="lang in languages" :key="lang.id" :value="lang.code">{{ lang.name }} ({{ lang.code }})</option>+ <option v-for="lang in languages" :key="lang.id" :value="lang.code">+ {{ lang.name }} ({{ lang.code }})+ </option></select>- <span class="form-hint">Fallback language when no localization matches the requested language</span>+ <span class="form-hint"+ >Fallback language when no localization matches the requested language</span+ ></div><div class="form-group"><label class="form-label">Sample Data (JSON)</label>- <textarea v-model="form.sample_data" class="form-textarea" rows="3" placeholder='{"name": "John", "company": "Acme"}'></textarea>- <span class="form-hint">Default sample data for previewing template localizations</span>+ <textarea+ v-model="form.sample_data"+ class="form-textarea"+ rows="3"+ placeholder='{"name": "John", "company": "Acme"}'+ ></textarea>+ <span class="form-hint"+ >Default sample data for previewing template localizations</span+ ></div></div>@@ -289,7 +381,7 @@ onMounted(() => {:disabled="saving || !form.name.trim()"@click="saveTemplate">- {{ saving ? 'Saving...' : (editing ? 'Update' : 'Create') }}+ {{ saving ? "Saving..." : editing ? "Update" : "Create" }}</button></div></div>diff --git a/web/src/views/webhooks/Webhooks.vue b/web/src/views/webhooks/Webhooks.vueindex a80dcf5..2a6ca5a 100644--- a/web/src/views/webhooks/Webhooks.vue+++ b/web/src/views/webhooks/Webhooks.vue@@ -6,6 +6,7 @@ import Pagination from '../../components/Pagination.vue'import { usePagination } from '../../composables/usePagination'import { useNotificationStore } from '../../stores/notification'import { useConfirm } from '../../composables/useConfirm'+import { useModalSafeClose } from '../../composables/useModalSafeClose';const notify = useNotificationStore()const { confirm } = useConfirm()@@ -124,7 +125,9 @@ function formatDate(dateStr: string): string {day: 'numeric',})}-+const { watchClickStart, confirmClickEnd } = useModalSafeClose(() => {+ showModal.value = false;+});</script><template>@@ -188,8 +191,8 @@ function formatDate(dateStr: string): string {</template><!-- Create Webhook Modal -->- <div v-if="showModal" class="modal-overlay" @click.self="showModal = false">- <div class="modal">+ <div v-if="showModal" class="modal-overlay" @mousedown="watchClickStart" @mouseup="confirmClickEnd">+ <div class="modal" @mousedown.stop @mouseup.stop><div class="modal-header"><h3>Add Webhook</h3></div>