feat #14740: delete transcribed calls

Transcribed (Done) calls get a "Löschen" button next to the upload
control, with a confirmation dialog in the app's style instead of
window.confirm. Deleting reuses discard_call (not a parallel path),
which now also refuses while the call's transcript is being uploaded,
consistent with the existing refusals for recording/processing/
CleanupPending.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-09 14:45:17 +01:00
co-authored by Claude Opus 5.5
parent 697f13e13a
commit 36cefaab5f
2 changed files with 211 additions and 16 deletions
+136 -8
View File
@@ -45,6 +45,12 @@
let actionError = $state('')
let busy = $state(false)
// "Löschen" (transcribed calls): confirmed with a dialog instead of
// running straight away like the other actions.
let deleteDialogOpen = $state(false)
let deleteBusy = $state(false)
let deleteError = $state('')
// Uploads run per call and may outlive the selection (the login can
// take a while); their errors are kept per call too.
let uploading = $state<CallId[]>([])
@@ -105,6 +111,8 @@
actionError = ''
editingTitle = false
titleError = ''
deleteDialogOpen = false
deleteError = ''
refreshDetail()
}
@@ -115,6 +123,8 @@
actionError = ''
editingTitle = false
titleError = ''
deleteDialogOpen = false
deleteError = ''
}
onMount(() => {
@@ -189,6 +199,49 @@
refreshList()
})
/** "Löschen" on a transcribed call: asks for confirmation first. */
function askDelete() {
deleteError = ''
deleteDialogOpen = true
}
function cancelDelete() {
deleteDialogOpen = false
deleteError = ''
}
/** Confirmed delete: same backend path as "Verwerfen" (`discard_call`).
* On success the selection moves to the next call in the list, or clears
* if none is left. */
async function confirmDelete() {
if (!detail) return
const id = detail.call.id
deleteBusy = true
try {
await discardCall(id)
deleteDialogOpen = false
selectAfterDelete(id)
refreshList()
} catch (err) {
deleteError = errorText(err)
} finally {
deleteBusy = false
}
}
/** Selects the call that took `deletedId`'s place in the list (or the one
* before it, if `deletedId` was last), else clears the selection. */
function selectAfterDelete(deletedId: CallId) {
const index = calls.findIndex((c) => c.id === deletedId)
const remaining = calls.filter((c) => c.id !== deletedId)
if (remaining.length === 0) {
clearSelection()
return
}
const next = remaining[Math.min(Math.max(index, 0), remaining.length - 1)]
select(next.id)
}
/** Uploads the shown call's transcript (logging in first if needed). A
* call already uploaded has no button any more: the CRM never gets a
* duplicate. */
@@ -351,14 +404,19 @@
{:else if call.status === 'failed'}
<button class="btn primary" disabled={busy} onclick={retry}>Erneut versuchen</button>
<button class="btn danger" disabled={busy} onclick={discard}>Verwerfen</button>
{:else if call.status === 'done' && !call.uploaded_at}
<button
class="btn primary"
disabled={!call.transcribed_at || isUploading}
title={call.transcribed_at ? 'Transkript ins CRM hochladen' : 'Noch kein Transkript'}
onclick={upload}
>
{isUploading ? 'wird hochgeladen…' : 'Transkript hochladen'}
{:else if call.status === 'done'}
{#if !call.uploaded_at}
<button
class="btn primary"
disabled={!call.transcribed_at || isUploading}
title={call.transcribed_at ? 'Transkript ins CRM hochladen' : 'Noch kein Transkript'}
onclick={upload}
>
{isUploading ? 'wird hochgeladen…' : 'Transkript hochladen'}
</button>
{/if}
<button class="btn danger" disabled={deleteBusy || isUploading} onclick={askDelete}>
Löschen
</button>
{/if}
</span>
@@ -397,6 +455,40 @@
/>
{/if}
</div>
{#if deleteDialogOpen}
<div
class="dialog-backdrop"
onclick={cancelDelete}
onkeydown={(e) => e.key === 'Escape' && cancelDelete()}
role="presentation"
>
<div
class="dialog"
role="alertdialog"
aria-modal="true"
aria-labelledby="delete-dialog-title"
tabindex="-1"
onclick={(e) => e.stopPropagation()}
onkeydown={(e) => e.stopPropagation()}
>
<p class="dialog-title" id="delete-dialog-title">Gespräch löschen?</p>
<p>Audio und Transkript werden unwiderruflich von diesem PC gelöscht.</p>
{#if call.uploaded_at}
<p>Die Kopie im CRM bleibt erhalten.</p>
{/if}
{#if deleteError}
<p class="error">{deleteError}</p>
{/if}
<div class="dialog-actions">
<button class="btn danger" disabled={deleteBusy} onclick={confirmDelete}>
Löschen
</button>
<button class="btn" disabled={deleteBusy} onclick={cancelDelete}>Abbrechen</button>
</div>
</div>
</div>
{/if}
{:else if detailError}
<p class="error pad">{detailError}</p>
{:else if loaded && selectedId === null && calls.length > 0}
@@ -574,4 +666,40 @@
background: var(--rec-soft);
color: var(--rec);
}
.dialog-backdrop {
position: fixed;
inset: 0;
background: rgba(29, 35, 48, 0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
.dialog {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
box-shadow: 0 12px 32px rgba(29, 35, 48, 0.25);
padding: 20px;
width: min(420px, calc(100vw - 32px));
}
.dialog-title {
font-size: 16px;
font-weight: 600;
margin: 0 0 8px;
}
.dialog p {
margin: 0 0 8px;
}
.dialog-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-top: 16px;
}
</style>