mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-27 08:49:36 +02:00
feat: refactor AttachmentCard component to handle delete action locally and simplify adventure page logic
This commit is contained in:
parent
25edec460b
commit
30c58ca118
2 changed files with 4 additions and 10 deletions
|
@ -90,10 +90,10 @@
|
||||||
>
|
>
|
||||||
{$t('transportation.edit')}
|
{$t('transportation.edit')}
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
|
||||||
<button class="btn btn-sm btn-danger btn-outline" type="button" on:click={deleteAttachment}>
|
<button class="btn btn-sm btn-danger btn-outline" type="button" on:click={deleteAttachment}>
|
||||||
{$t('adventures.delete')}
|
{$t('adventures.delete')}
|
||||||
</button>
|
</button>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,12 +12,6 @@
|
||||||
return marked(markdown);
|
return marked(markdown);
|
||||||
};
|
};
|
||||||
|
|
||||||
function deleteAttachment(event: CustomEvent<string>) {
|
|
||||||
adventure.attachments = adventure.attachments.filter(
|
|
||||||
(attachment) => attachment.id !== event.detail
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
|
@ -395,7 +389,7 @@
|
||||||
{#if adventure.attachments && adventure.attachments.length > 0}
|
{#if adventure.attachments && adventure.attachments.length > 0}
|
||||||
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||||
{#each adventure.attachments as attachment}
|
{#each adventure.attachments as attachment}
|
||||||
<AttachmentCard {attachment} on:delete={deleteAttachment} />
|
<AttachmentCard {attachment} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue