feat(comments): Trash-Button zum Loeschen eigener Kommentare
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m19s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m19s
Der DELETE-Endpunkt fuer Kommentare existierte schon, hatte aber keine UI-Exposition — Nutzer konnten ihre eigenen Kommentare nur via API-Call loeschen. Das war beim UAT 2026-04-19 aufgefallen. Jetzt: pro Kommentar wird nur fuer den Autor (comment.profile_id === profileStore.active.id) ein kleiner Trash2-Button in der Ecke angezeigt. Mit confirmAction-Dialog, weil das Loeschen nicht undo-bar ist. Nutzt asyncFetch fuer den DELETE-Call — konsistent mit dem Rest des Page-Scripts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -194,6 +194,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteComment(id: number) {
|
||||||
|
const ok = await confirmAction({
|
||||||
|
title: 'Kommentar löschen?',
|
||||||
|
message: 'Der Eintrag verschwindet ohne Umweg.',
|
||||||
|
confirmLabel: 'Löschen',
|
||||||
|
destructive: true
|
||||||
|
});
|
||||||
|
if (!ok) return;
|
||||||
|
if (!requireOnline('Das Löschen')) return;
|
||||||
|
const res = await asyncFetch(
|
||||||
|
`/api/recipes/${data.recipe.id}/comments`,
|
||||||
|
{
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: { 'content-type': 'application/json' },
|
||||||
|
body: JSON.stringify({ comment_id: id })
|
||||||
|
},
|
||||||
|
'Löschen fehlgeschlagen'
|
||||||
|
);
|
||||||
|
if (!res) return;
|
||||||
|
comments = comments.filter((c) => c.id !== id);
|
||||||
|
}
|
||||||
|
|
||||||
async function deleteRecipe() {
|
async function deleteRecipe() {
|
||||||
const ok = await confirmAction({
|
const ok = await confirmAction({
|
||||||
title: 'Rezept löschen?',
|
title: 'Rezept löschen?',
|
||||||
@@ -466,6 +488,16 @@
|
|||||||
<div class="author">{c.author}</div>
|
<div class="author">{c.author}</div>
|
||||||
<div class="text">{c.text}</div>
|
<div class="text">{c.text}</div>
|
||||||
<div class="date">{new Date(c.created_at).toLocaleString('de-DE')}</div>
|
<div class="date">{new Date(c.created_at).toLocaleString('de-DE')}</div>
|
||||||
|
{#if profileStore.active?.id === c.profile_id}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="comment-del"
|
||||||
|
aria-label="Kommentar löschen"
|
||||||
|
onclick={() => void deleteComment(c.id)}
|
||||||
|
>
|
||||||
|
<Trash2 size="14" />
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -673,6 +705,26 @@
|
|||||||
border: 1px solid #e4eae7;
|
border: 1px solid #e4eae7;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 0.75rem 0.9rem;
|
padding: 0.75rem 0.9rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.comment-del {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.5rem;
|
||||||
|
right: 0.5rem;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: #888;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.comment-del:hover {
|
||||||
|
background: #f3f5f3;
|
||||||
|
color: #b42626;
|
||||||
}
|
}
|
||||||
.comments .author {
|
.comments .author {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
Reference in New Issue
Block a user