Compare commits
2 Commits
02b9cdbc68
...
cleanup-ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e953ca7870 | ||
|
|
c1789f902e |
@@ -33,7 +33,12 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
const u = ($page.url.searchParams.get('url') ?? '').trim();
|
const u = ($page.url.searchParams.get('url') ?? '').trim();
|
||||||
targetUrl = u;
|
targetUrl = u;
|
||||||
if (u) void load(u);
|
if (u) {
|
||||||
|
void load(u);
|
||||||
|
} else {
|
||||||
|
loading = false;
|
||||||
|
errored = 'Kein ?url=-Parameter. Suche zuerst ein Rezept und klicke auf einen Treffer.';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
|
|||||||
@@ -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