1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-29 17:59:36 +02:00

Enhance TransportationCard unlinked state logic and improve date handling; update TransportationModal for conditional rendering and add new background image in JSON.

This commit is contained in:
Sean Morley 2024-12-28 10:56:25 -05:00
parent 5d3ec181a0
commit 697c40fca0
6 changed files with 66 additions and 23 deletions

View file

@ -22,23 +22,49 @@
let unlinked: boolean = false;
// unlinked if collection.start_date and collection.end_date are not within transportation.date and transportation.end_date. check for null in the collection dates first to avoid errors
$: {
if (collection?.start_date && collection.end_date) {
// Parse transportation dates
let transportationStartDate = transportation.date
? new Date(transportation.date.split('T')[0]) // Ensure proper date parsing
: null;
let transportationEndDate = transportation.end_date
? new Date(transportation.end_date.split('T')[0])
: null;
// Parse collection dates
let collectionStartDate = new Date(collection.start_date);
let collectionEndDate = new Date(collection.end_date);
// // Debugging outputs
// console.log(
// 'Transportation Start Date:',
// transportationStartDate,
// 'Transportation End Date:',
// transportationEndDate
// );
// console.log(
// 'Collection Start Date:',
// collectionStartDate,
// 'Collection End Date:',
// collectionEndDate
// );
// Check if the collection range is outside the transportation range
const startOutsideRange =
transportation.date &&
collection.start_date < transportation.date &&
collection.end_date < transportation.date;
transportationStartDate &&
collectionStartDate < transportationStartDate &&
collectionEndDate < transportationStartDate;
const endOutsideRange =
transportation.end_date &&
collection.start_date > transportation.end_date &&
collection.end_date > transportation.end_date;
transportationEndDate &&
collectionStartDate > transportationEndDate &&
collectionEndDate > transportationEndDate;
unlinked = !!(
startOutsideRange ||
endOutsideRange ||
(!transportation.date && !transportation.end_date)
(!transportationStartDate && !transportationEndDate)
);
}
}

View file

@ -429,7 +429,11 @@
<div class="collapse collapse-plus bg-base-200 mb-4">
<input type="checkbox" checked />
<div class="collapse-title text-xl font-medium">
{#if transportation?.type == 'plane'}
{$t('adventures.flight_information')}
{:else}
{$t('adventures.location_information')}
{/if}
</div>
<div class="collapse-content">

View file

@ -19,6 +19,11 @@
"url": "backgrounds/adventurelog_showcase_4.webp",
"author": "Sean Morley",
"location": "Great Sand Dunes National Park, Colorado, USA"
},
{
"url": "backgrounds/adventurelog_showcase_5.webp",
"author": "Sean Morley",
"location": "Hoboken, New Jersey, USA"
}
]
}

View file

@ -72,16 +72,32 @@
// Compute `dates` array reactively
$: {
dates = [];
if (adventures) {
dates = adventures.flatMap((adventure) =>
dates = dates.concat(
adventures.flatMap((adventure) =>
adventure.visits.map((visit) => ({
id: adventure.id,
start: visit.start_date, // Convert to ISO format if needed
end: visit.end_date || visit.start_date,
start: visit.start_date || '', // Ensure it's a string
end: visit.end_date || visit.start_date || '', // Ensure it's a string
title: adventure.name + (adventure.category?.icon ? ' ' + adventure.category.icon : '')
}))
)
);
}
if (transportations) {
dates = dates.concat(
transportations.map((transportation) => ({
id: transportation.id,
start: transportation.date || '', // Ensure it's a string
end: transportation.end_date || transportation.date || '', // Ensure it's a string
title: transportation.name + (transportation.type ? ` (${transportation.type})` : '')
}))
);
}
// Update `options.events` when `dates` changes
options = { ...options, events: dates };
}

View file

@ -110,14 +110,6 @@
id="name"
on:change={() => (property = 'name')}
/>
<input
class="join-item btn"
type="radio"
name="filter"
aria-label={$t('transportation.type')}
id="type"
on:change={() => (property = 'type')}
/>
<input
class="join-item btn"
type="radio"

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB