mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-29 17:59:36 +02:00
Edit adventure from detail view
This commit is contained in:
parent
2a072f22cb
commit
25c6d3fce3
1 changed files with 22 additions and 0 deletions
|
@ -27,6 +27,10 @@
|
||||||
let adventure: Adventure;
|
let adventure: Adventure;
|
||||||
|
|
||||||
let notFound: boolean = false;
|
let notFound: boolean = false;
|
||||||
|
let isEditModalOpen: boolean = false;
|
||||||
|
|
||||||
|
import ClipboardList from '~icons/mdi/clipboard-list';
|
||||||
|
import EditAdventure from '$lib/components/EditAdventure.svelte';
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (data.props.adventure) {
|
if (data.props.adventure) {
|
||||||
|
@ -35,6 +39,11 @@
|
||||||
notFound = true;
|
notFound = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function saveEdit(event: CustomEvent<Adventure>) {
|
||||||
|
adventure = event.detail;
|
||||||
|
isEditModalOpen = false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if notFound}
|
{#if notFound}
|
||||||
|
@ -59,6 +68,14 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if isEditModalOpen}
|
||||||
|
<EditAdventure
|
||||||
|
adventureToEdit={adventure}
|
||||||
|
on:close={() => (isEditModalOpen = false)}
|
||||||
|
on:saveEdit={saveEdit}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if !adventure && !notFound}
|
{#if !adventure && !notFound}
|
||||||
<div class="flex justify-center items-center w-full mt-16">
|
<div class="flex justify-center items-center w-full mt-16">
|
||||||
<span class="loading loading-spinner w-24 h-24"></span>
|
<span class="loading loading-spinner w-24 h-24"></span>
|
||||||
|
@ -66,6 +83,11 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if adventure}
|
{#if adventure}
|
||||||
|
<div class="fixed bottom-4 right-4 z-[999]">
|
||||||
|
<button class="btn m-1 size-16 btn-primary" on:click={() => (isEditModalOpen = true)}
|
||||||
|
><ClipboardList class="w-8 h-8" /></button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
<div class="flex flex-col min-h-dvh">
|
<div class="flex flex-col min-h-dvh">
|
||||||
<main class="flex-1">
|
<main class="flex-1">
|
||||||
<div class="max-w-5xl mx-auto p-4 md:p-6 lg:p-8">
|
<div class="max-w-5xl mx-auto p-4 md:p-6 lg:p-8">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue