From f354cd1ffeb9078abccd5dbd355acd377892afa4 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Fri, 4 Oct 2024 21:33:02 -0400 Subject: [PATCH] Refactor release workflow to use "released" event type --- .github/workflows/backend-release.yml | 2 +- .github/workflows/frontend-release.yml | 2 +- .../src/lib/components/AdventureLink.svelte | 4 +- .../src/lib/components/AdventureModal.svelte | 143 +++++++++++------- .../src/routes/adventures/[id]/+page.svelte | 31 +++- 5 files changed, 125 insertions(+), 57 deletions(-) diff --git a/.github/workflows/backend-release.yml b/.github/workflows/backend-release.yml index e12143c..696f8b5 100644 --- a/.github/workflows/backend-release.yml +++ b/.github/workflows/backend-release.yml @@ -2,7 +2,7 @@ name: Upload the tagged release backend image to GHCR and Docker Hub on: release: - types: [published] + types: [released] env: IMAGE_NAME: "adventurelog-backend" diff --git a/.github/workflows/frontend-release.yml b/.github/workflows/frontend-release.yml index a73af32..bb7fc6b 100644 --- a/.github/workflows/frontend-release.yml +++ b/.github/workflows/frontend-release.yml @@ -2,7 +2,7 @@ name: Upload tagged release frontend image to GHCR and Docker Hub on: release: - types: [published] + types: [released] env: IMAGE_NAME: "adventurelog-frontend" diff --git a/frontend/src/lib/components/AdventureLink.svelte b/frontend/src/lib/components/AdventureLink.svelte index b1bb85f..cb4551b 100644 --- a/frontend/src/lib/components/AdventureLink.svelte +++ b/frontend/src/lib/components/AdventureLink.svelte @@ -19,14 +19,14 @@ if (modal) { modal.showModal(); } - let res = await fetch(`/api/adventures/all/?include_collections=false`, { + let res = await fetch(`/api/adventures/?include_collections=false`, { method: 'GET' }); const newAdventures = await res.json(); if (res.ok && adventures) { - adventures = newAdventures; + adventures = newAdventures.results; } isLoading = false; }); diff --git a/frontend/src/lib/components/AdventureModal.svelte b/frontend/src/lib/components/AdventureModal.svelte index 3970ede..d8889d7 100644 --- a/frontend/src/lib/components/AdventureModal.svelte +++ b/frontend/src/lib/components/AdventureModal.svelte @@ -16,6 +16,7 @@ let places: OpenStreetMapPlace[] = []; let images: { id: string; image: string }[] = []; let warningMessage: string = ''; + let constrainDates: boolean = false; import ActivityComplete from './ActivityComplete.svelte'; import { appVersion } from '$lib/config'; @@ -638,40 +639,73 @@ it would also work to just use on:click on the MapLibre component itself. -->
- { - if (e.key === 'Enter') { - e.preventDefault(); - addNewVisit(); - } - }} - /> - { - if (e.key === 'Enter') { - e.preventDefault(); - addNewVisit(); - } - }} - /> + {#if !constrainDates} + { + if (e.key === 'Enter') { + e.preventDefault(); + addNewVisit(); + } + }} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + addNewVisit(); + } + }} + /> + {:else} + { + if (e.key === 'Enter') { + e.preventDefault(); + addNewVisit(); + } + }} + /> + { + if (e.key === 'Enter') { + e.preventDefault(); + addNewVisit(); + } + }} + /> + {/if}
@@ -695,27 +729,32 @@ it would also work to just use on:click on the MapLibre component itself. --> {#if adventure.visits.length > 0}

My Visits

{#each adventure.visits as visit} -
-

- {new Date(visit.start_date).toLocaleDateString(undefined, { - timeZone: 'UTC' - })} -

-

- {new Date(visit.end_date).toLocaleDateString(undefined, { timeZone: 'UTC' })} -

-

{visit.notes}

-
- +
+
+

+ {new Date(visit.start_date).toLocaleDateString(undefined, { + timeZone: 'UTC' + })} +

+

+ {new Date(visit.end_date).toLocaleDateString(undefined, { + timeZone: 'UTC' + })} +

+ +
+ +
+

{visit.notes}

{/each} {/if} diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index 085809f..8f8b6fe 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -40,6 +40,7 @@ import EditAdventure from '$lib/components/AdventureModal.svelte'; import AdventureModal from '$lib/components/AdventureModal.svelte'; import ImageDisplayModal from '$lib/components/ImageDisplayModal.svelte'; + import { typeToString } from '$lib'; onMount(() => { if (data.props.adventure) { @@ -310,7 +311,7 @@

Adventure Type

- {adventure.type[0].toLocaleUpperCase() + adventure.type.slice(1)} + {typeToString(adventure.type)}

{#if data.props.collection} @@ -322,6 +323,34 @@ >
{/if} + {#if adventure.visits.length > 0} +
+

Visits

+

+ {adventure.visits.length} + {adventure.visits.length > 1 ? 'visits' : 'visit' + ':'} +

+ + {#each adventure.visits as visit} +
+

+ {visit.start_date + ? new Date(visit.start_date).toLocaleDateString(undefined, { + timeZone: 'UTC' + }) + : ''} + {visit.end_date && visit.end_date !== '' + ? ' - ' + + new Date(visit.end_date).toLocaleDateString(undefined, { + timeZone: 'UTC' + }) + : ''} +

+

{visit.notes}

+
+ {/each} +
+ {/if}
{#if adventure.longitude && adventure.latitude}