From 3f30819d25dac9de7d6bf5057c80c34460bb21f5 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Tue, 21 Jan 2025 19:40:56 -0500 Subject: [PATCH] feat: add GPX file support in AdventureModal and improve map marker handling --- .../src/lib/components/AdventureModal.svelte | 2 +- .../src/routes/adventures/[id]/+page.svelte | 84 ++++++++++--------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/frontend/src/lib/components/AdventureModal.svelte b/frontend/src/lib/components/AdventureModal.svelte index e734744..cb5a920 100644 --- a/frontend/src/lib/components/AdventureModal.svelte +++ b/frontend/src/lib/components/AdventureModal.svelte @@ -990,7 +990,7 @@ it would also work to just use on:click on the MapLibre component itself. --> type="file" id="fileInput" class="file-input file-input-bordered w-full max-w-xs" - accept="image/*,video/*,audio/*,application/pdf" + accept="image/*,video/*,audio/*,application/pdf,.gpx" bind:this={fileInput} /> diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index 8d3ea0c..fb0528f 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -99,7 +99,7 @@ } else { notFound = true; } - getGpxFiles(); + await getGpxFiles(); }); function saveEdit(event: CustomEvent) { @@ -379,23 +379,25 @@ {/if} - {#if adventure.longitude && adventure.latitude} -
-
-

{$t('adventures.latitude')}

-

{adventure.latitude}° N

+ {#if (adventure.longitude && adventure.latitude) || geojson} + {#if adventure.longitude && adventure.latitude} +
+
+

{$t('adventures.latitude')}

+

{adventure.latitude}° N

+
+
+

{$t('adventures.longitude')}

+

{adventure.longitude}° W

+
-
-

{$t('adventures.longitude')}

-

{adventure.longitude}° W

-
-
+ {/if} {#if geojson} @@ -415,34 +417,36 @@ it would also work to just use on:click on the MapLibre component itself. --> - - -
{adventure.name}
-

- {adventure.category?.display_name + ' ' + adventure.category?.icon} -

- {#if adventure.visits.length > 0} -

- {#each adventure.visits as visit} - {visit.start_date - ? new Date(visit.start_date).toLocaleDateString(undefined, { - timeZone: 'UTC' - }) - : ''} - {visit.end_date && - visit.end_date !== '' && - visit.end_date !== visit.start_date - ? ' - ' + - new Date(visit.end_date).toLocaleDateString(undefined, { - timeZone: 'UTC' - }) - : ''} -
- {/each} + {#if adventure.longitude && adventure.latitude} + + +

{adventure.name}
+

+ {adventure.category?.display_name + ' ' + adventure.category?.icon}

- {/if} -
-
+ {#if adventure.visits.length > 0} +

+ {#each adventure.visits as visit} + {visit.start_date + ? new Date(visit.start_date).toLocaleDateString(undefined, { + timeZone: 'UTC' + }) + : ''} + {visit.end_date && + visit.end_date !== '' && + visit.end_date !== visit.start_date + ? ' - ' + + new Date(visit.end_date).toLocaleDateString(undefined, { + timeZone: 'UTC' + }) + : ''} +
+ {/each} +

+ {/if} + + + {/if}
{/if}