1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-28 01:09:37 +02:00

collections is public fix

This commit is contained in:
Sean Morley 2024-07-15 18:51:05 -04:00
parent 7e5e4edd4d
commit d91b8c7128
5 changed files with 83 additions and 14 deletions

View file

@ -35,6 +35,7 @@
}
function add(event: CustomEvent<Adventure>) {
adventures = adventures.filter((a) => a.id !== event.detail.id);
dispatch('add', event.detail);
}
@ -48,12 +49,17 @@
<dialog id="my_modal_1" class="modal">
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<div class="modal-box" role="dialog" on:keydown={handleKeydown} tabindex="0">
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
<h1 class="text-center font-bold text-4xl mb-6">My Adventures</h1>
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each adventures as adventure}
<AdventureCard type="link" {adventure} on:link={add} />
{/each}
{#if adventures.length === 0}
<p class="text-center text-lg">
No adventures found that can be linked to this collection.
</p>
{/if}
</div>
<button class="btn btn-primary" on:click={close}>Close</button>
</div>

View file

@ -246,17 +246,19 @@
Location</button
>
</div>
<div class="mb-2">
<label for="is_public">Public <Earth class="inline-block -mt-1 mb-1 w-6 h-6" /></label><br
/>
<input
type="checkbox"
class="toggle toggle-primary"
id="is_public"
name="is_public"
bind:checked={adventureToEdit.is_public}
/>
</div>
{#if adventureToEdit.collection === null}
<div class="mb-2">
<label for="is_public">Public <Earth class="inline-block -mt-1 mb-1 w-6 h-6" /></label
><br />
<input
type="checkbox"
class="toggle toggle-primary"
id="is_public"
name="is_public"
bind:checked={adventureToEdit.is_public}
/>
</div>
{/if}
{#if adventureToEdit.is_public}
<div class="bg-neutral p-4 rounded-md shadow-sm">

View file

@ -21,7 +21,7 @@ export type Adventure = {
link?: string | null;
image?: string | null;
date?: string | null; // Assuming date is a string in 'YYYY-MM-DD' format
trip_id?: number | null;
collection?: number | null;
latitude: number | null;
longitude: number | null;
is_public: boolean;

View file

@ -8,6 +8,7 @@
import Plus from '~icons/mdi/plus';
import AdventureCard from '$lib/components/AdventureCard.svelte';
import AdventureLink from '$lib/components/AdventureLink.svelte';
import EditAdventure from '$lib/components/EditAdventure.svelte';
export let data: PageData;
@ -53,6 +54,24 @@
}
}
}
let adventureToEdit: Adventure;
let isEditModalOpen: boolean = false;
function editAdventure(event: CustomEvent<Adventure>) {
adventureToEdit = event.detail;
isEditModalOpen = true;
}
function saveEdit(event: CustomEvent<Adventure>) {
adventures = adventures.map((adventure) => {
if (adventure.id === event.detail.id) {
return event.detail;
}
return adventure;
});
isEditModalOpen = false;
}
</script>
{#if isShowingCreateModal}
@ -64,6 +83,14 @@
/>
{/if}
{#if isEditModalOpen}
<EditAdventure
{adventureToEdit}
on:close={() => (isEditModalOpen = false)}
on:saveEdit={saveEdit}
/>
{/if}
{#if notFound}
<div
class="flex min-h-[100dvh] flex-col items-center justify-center bg-background px-4 py-12 sm:px-6 lg:px-8 -mt-20"
@ -127,7 +154,12 @@
<h1 class="text-center font-semibold text-2xl mt-4 mb-2">Linked Adventures</h1>
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each adventures as adventure}
<AdventureCard on:delete={deleteAdventure} type={adventure.type} {adventure} />
<AdventureCard
on:edit={editAdventure}
on:delete={deleteAdventure}
type={adventure.type}
{adventure}
/>
{/each}
</div>