Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Add delete button for individual events on desktop and mobile
Murtaza Nasird1a12d83d6e0
diff --git a/static/js/modules/composables/ui.js b/static/js/modules/composables/ui.jsindex 3157cf08..6c8f02bc 100644--- a/static/js/modules/composables/ui.js+++ b/static/js/modules/composables/ui.js@@ -714,6 +714,44 @@ export function useUI(state, utils, processedTranscription) {}};+ const deleteEvent = async (event) => {+ if (!event || !event.id) {+ showToast('Invalid event data', 'fa-exclamation-circle');+ return;+ }++ // Confirm deletion+ if (!confirm(t('events.confirmDelete', { title: event.title }) || `Delete event "${event.title}"?`)) {+ return;+ }++ try {+ const response = await fetch(`/api/event/${event.id}`, {+ method: 'DELETE',+ headers: {+ 'Content-Type': 'application/json',+ 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]')?.content || ''+ }+ });++ if (!response.ok) {+ const error = await response.json();+ showToast(error.error || t('events.deleteFailed') || 'Failed to delete event', 'fa-exclamation-circle');+ return;+ }++ // Remove event from local state+ if (selectedRecording.value && selectedRecording.value.events) {+ selectedRecording.value.events = selectedRecording.value.events.filter(e => e.id !== event.id);+ }++ showToast(t('events.deleted') || 'Event deleted', 'fa-check-circle');+ } catch (error) {+ console.error('Delete event failed:', error);+ showToast(t('events.deleteFailed') || 'Failed to delete event', 'fa-exclamation-circle');+ }+ };+const formatEventDateTime = (dateTimeStr) => {if (!dateTimeStr) return '';try {@@ -1780,6 +1818,7 @@ export function useUI(state, utils, processedTranscription) {downloadNotes,downloadEventICS,downloadICS,+ deleteEvent,formatEventDateTime,// View modetoggleTranscriptionViewMode,diff --git a/static/locales/en.json b/static/locales/en.jsonindex 74494ec6..a8df5db3 100644--- a/static/locales/en.json+++ b/static/locales/en.json@@ -1077,7 +1077,11 @@"start": "Start","end": "End","location": "Location",- "attendees": "Attendees"+ "attendees": "Attendees",+ "delete": "Delete",+ "confirmDelete": "Delete event \"{title}\"?",+ "deleted": "Event deleted",+ "deleteFailed": "Failed to delete event"},"pwa": {"installApp": "Install App",diff --git a/templates/components/detail/desktop-events-tab.html b/templates/components/detail/desktop-events-tab.htmlindex aa9ab91b..cfa7d273 100644--- a/templates/components/detail/desktop-events-tab.html+++ b/templates/components/detail/desktop-events-tab.html@@ -13,12 +13,19 @@${ event.description }</p></div>- <button @click="downloadEventICS(event)"- class="px-3 py-1.5 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors text-sm flex items-center gap-1.5"- :title="t('events.addToCalendar')">- <i class="fas fa-download"></i>- <span v-text="t('events.addToCalendar')"></span>- </button>+ <div class="flex items-center gap-2">+ <button @click="downloadEventICS(event)"+ class="px-3 py-1.5 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors text-sm flex items-center gap-1.5"+ :title="t('events.addToCalendar')">+ <i class="fas fa-download"></i>+ <span v-text="t('events.addToCalendar')"></span>+ </button>+ <button @click="deleteEvent(event)"+ class="p-1.5 text-[var(--text-muted)] hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors"+ :title="t('events.delete')">+ <i class="fas fa-trash-alt"></i>+ </button>+ </div></div><div class="space-y-2 text-sm">diff --git a/templates/components/detail/mobile-events-panel.html b/templates/components/detail/mobile-events-panel.htmlindex 3303cf03..93e0cc4a 100644--- a/templates/components/detail/mobile-events-panel.html+++ b/templates/components/detail/mobile-events-panel.html@@ -12,7 +12,7 @@<div v-for="event in selectedRecording.events" :key="event.id"class="bg-[var(--bg-tertiary)] rounded-lg p-3 border border-[var(--border-primary)]"><div class="flex justify-between items-start mb-2">- <div class="flex-1">+ <div class="flex-1 min-w-0 pr-2"><h3 class="text-base font-semibold text-[var(--text-primary)] mb-1"><i class="fas fa-calendar-check mr-2 text-[var(--text-accent)] text-sm"></i>${ event.title }@@ -21,12 +21,19 @@${ event.description }</p></div>- <button @click="downloadEventICS(event)"- class="px-2 py-1 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors text-xs flex items-center gap-1"- :title="t('events.addToCalendar')">- <i class="fas fa-download text-xs"></i>- <span v-text="t('events.add')"></span>- </button>+ <div class="flex items-center gap-1 flex-shrink-0">+ <button @click="downloadEventICS(event)"+ class="px-2 py-1 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors text-xs flex items-center gap-1"+ :title="t('events.addToCalendar')">+ <i class="fas fa-download text-xs"></i>+ <span v-text="t('events.add')"></span>+ </button>+ <button @click="deleteEvent(event)"+ class="p-1.5 text-[var(--text-muted)] hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors"+ :title="t('events.delete')">+ <i class="fas fa-trash-alt text-xs"></i>+ </button>+ </div></div><div class="grid grid-cols-1 gap-2 text-xs"><div class="flex items-center text-[var(--text-muted)]">