diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index da80e43..0d903ee 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -41,6 +41,24 @@ } } + let unlinked: boolean = false; + + // Reactive block to update `unlinked` when dependencies change + $: { + if (collection && collection?.start_date && collection.end_date) { + unlinked = adventure.visits.every((visit) => { + // Check if visit dates exist + if (!visit.start_date || !visit.end_date) return true; // Consider "unlinked" for incomplete visit data + + // Check if collection dates are completely outside this visit's range + const isBeforeVisit = collection.end_date && collection.end_date < visit.start_date; + const isAfterVisit = collection.start_date && collection.start_date > visit.end_date; + + return isBeforeVisit || isAfterVisit; + }); + } + } + async function deleteAdventure() { let res = await fetch(`/adventures/${adventure.id}?/delete`, { method: 'POST', @@ -140,6 +158,9 @@ {adventure.is_public ? $t('adventures.public') : $t('adventures.private')} + {#if unlinked} +
{$t('adventures.out_of_range')}
+ {/if} {#if adventure.location && adventure.location !== ''}
diff --git a/frontend/src/lib/components/ChecklistCard.svelte b/frontend/src/lib/components/ChecklistCard.svelte index e4d0ee2..13814dc 100644 --- a/frontend/src/lib/components/ChecklistCard.svelte +++ b/frontend/src/lib/components/ChecklistCard.svelte @@ -16,6 +16,24 @@ let isWarningModalOpen: boolean = false; + let unlinked: boolean = false; + + $: { + if (collection?.start_date && collection.end_date) { + const startOutsideRange = + checklist.date && + collection.start_date < checklist.date && + collection.end_date < checklist.date; + + const endOutsideRange = + checklist.date && + collection.start_date > checklist.date && + collection.end_date > checklist.date; + + unlinked = !!(startOutsideRange || endOutsideRange); + } + } + function editChecklist() { dispatch('edit', checklist); } @@ -61,6 +79,9 @@ {checklist.items.length > 1 ? $t('checklist.items') : $t('checklist.item')}

{/if} + {#if unlinked} +
{$t('adventures.out_of_range')}
+ {/if} {#if checklist.date && checklist.date !== ''}
@@ -71,7 +92,7 @@ - {#if checklist.user_id == user?.uuid || (collection && user && collection.shared_with.includes(user.uuid))} + {#if checklist.user_id == user?.uuid || (collection && user && collection.shared_with && collection.shared_with.includes(user.uuid))} -
- {#if items.length > 0} -
-

{$t('checklist.items')}

- {/if} - - {#each items as item, i} -
- - - + +
{$t('adventures.note')}
+ {#if unlinked} +
{$t('adventures.out_of_range')}
+ {/if} {#if note.links && note.links.length > 0}

{note.links.length} @@ -74,7 +90,7 @@ - {#if note.user_id == user?.uuid || (collection && user && collection.shared_with.includes(user.uuid))} + {#if note.user_id == user?.uuid || (collection && user && collection.shared_with && collection.shared_with.includes(user.uuid))} -

- {#if newNote.links.length > 0} - - {/if} + {$t('adventures.date_constrain')} + (constrainDates = !constrainDates)} + /> + {/if} + +
+ + +
+
+ {#if !isReadOnly} + + {:else if note} +

+
+ {@html renderMarkdown(note.content || '')} +
+ {/if} +
+ + + {#if !isReadOnly} +
+ + { + if (e.key === 'Enter') { + e.preventDefault(); + addLink(); + } + }} + /> + +
+ {/if} + + + {#if newNote.links.length > 0} + + {/if} + + + + {#if warning} - + {#if unlinked} +
{$t('adventures.out_of_range')}
+ {/if}
@@ -100,7 +122,7 @@
- {#if transportation.user_id == user?.uuid || (collection && user && collection.shared_with.includes(user.uuid))} + {#if transportation.user_id == user?.uuid || (collection && user && collection.shared_with && collection.shared_with.includes(user.uuid))}
{/if} {#if collection} - {#if data.user && data.user.uuid && (data.user.uuid == collection.user_id || collection.shared_with.includes(data.user.uuid)) && !collection.is_archived} + {#if data.user && data.user.uuid && (data.user.uuid == collection.user_id || (collection.shared_with && collection.shared_with.includes(data.user.uuid))) && !collection.is_archived}