1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-04 04:35:19 +02:00

refactor: Rename AdventureCard and AdventureModal to LocationCard and LocationModal for consistency

This commit is contained in:
Sean Morley 2025-06-25 11:44:48 -04:00
parent 3ea1ca0b40
commit f48960f72b
10 changed files with 126 additions and 127 deletions

View file

@ -24,7 +24,7 @@
import Filter from '~icons/mdi/filter-variant'; import Filter from '~icons/mdi/filter-variant';
// Component imports // Component imports
import AdventureCard from './LocationCard.svelte'; import LocationCard from './LocationCard.svelte';
import TransportationCard from './TransportationCard.svelte'; import TransportationCard from './TransportationCard.svelte';
import LodgingCard from './LodgingCard.svelte'; import LodgingCard from './LodgingCard.svelte';
import NoteCard from './NoteCard.svelte'; import NoteCard from './NoteCard.svelte';
@ -432,7 +432,7 @@
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mx-4"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mx-4">
{#each filteredAdventures as adventure} {#each filteredAdventures as adventure}
<AdventureCard <LocationCard
{user} {user}
on:edit={handleEditAdventure} on:edit={handleEditAdventure}
on:delete={handleDeleteAdventure} on:delete={handleDeleteAdventure}

View file

@ -4,7 +4,7 @@
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
import { t } from 'svelte-i18n'; import { t } from 'svelte-i18n';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import AdventureCard from './LocationCard.svelte'; import LocationCard from './LocationCard.svelte';
let modal: HTMLDialogElement; let modal: HTMLDialogElement;
// Icons - following the worldtravel pattern // Icons - following the worldtravel pattern
@ -274,7 +274,7 @@
<!-- Adventures Grid --> <!-- Adventures Grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-6 p-4"> <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-6 p-4">
{#each filteredAdventures as adventure} {#each filteredAdventures as adventure}
<AdventureCard {user} type="link" {adventure} on:link={add} /> <LocationCard {user} type="link" {adventure} on:link={add} />
{/each} {/each}
</div> </div>
{/if} {/if}

View file

@ -23,7 +23,6 @@
let images: { id: string; image: string; is_primary: boolean; immich_id: string | null }[] = []; let images: { id: string; image: string; is_primary: boolean; immich_id: string | null }[] = [];
let warningMessage: string = ''; let warningMessage: string = '';
let constrainDates: boolean = false;
let categories: Category[] = []; let categories: Category[] = [];
@ -97,7 +96,7 @@
let wikiError: string = ''; let wikiError: string = '';
let adventure: Location = { let location: Location = {
id: '', id: '',
name: '', name: '',
visits: [], visits: [],
@ -121,24 +120,24 @@
attachments: [] attachments: []
}; };
export let adventureToEdit: Location | null = null; export let locationToEdit: Location | null = null;
adventure = { location = {
id: adventureToEdit?.id || '', id: locationToEdit?.id || '',
name: adventureToEdit?.name || '', name: locationToEdit?.name || '',
link: adventureToEdit?.link || null, link: locationToEdit?.link || null,
description: adventureToEdit?.description || null, description: locationToEdit?.description || null,
tags: adventureToEdit?.tags || [], tags: locationToEdit?.tags || [],
rating: adventureToEdit?.rating || NaN, rating: locationToEdit?.rating || NaN,
is_public: adventureToEdit?.is_public || false, is_public: locationToEdit?.is_public || false,
latitude: adventureToEdit?.latitude || NaN, latitude: locationToEdit?.latitude || NaN,
longitude: adventureToEdit?.longitude || NaN, longitude: locationToEdit?.longitude || NaN,
location: adventureToEdit?.location || null, location: locationToEdit?.location || null,
images: adventureToEdit?.images || [], images: locationToEdit?.images || [],
user: adventureToEdit?.user || null, user: locationToEdit?.user || null,
visits: adventureToEdit?.visits || [], visits: locationToEdit?.visits || [],
is_visited: adventureToEdit?.is_visited || false, is_visited: locationToEdit?.is_visited || false,
category: adventureToEdit?.category || { category: locationToEdit?.category || {
id: '', id: '',
name: '', name: '',
display_name: '', display_name: '',
@ -146,7 +145,7 @@
user: '' user: ''
}, },
attachments: adventureToEdit?.attachments || [] attachments: locationToEdit?.attachments || []
}; };
onMount(async () => { onMount(async () => {
@ -183,15 +182,15 @@
let isLoading: boolean = false; let isLoading: boolean = false;
images = adventure.images || []; images = location.images || [];
$: { $: {
if (!adventure.rating) { if (!location.rating) {
adventure.rating = NaN; location.rating = NaN;
} }
} }
function deleteAttachment(event: CustomEvent<string>) { function deleteAttachment(event: CustomEvent<string>) {
adventure.attachments = adventure.attachments.filter( location.attachments = location.attachments.filter(
(attachment) => attachment.id !== event.detail (attachment) => attachment.id !== event.detail
); );
} }
@ -210,7 +209,7 @@
}); });
if (res.ok) { if (res.ok) {
let newAttachment = (await res.json()) as Attachment; let newAttachment = (await res.json()) as Attachment;
adventure.attachments = adventure.attachments.map((attachment) => { location.attachments = location.attachments.map((attachment) => {
if (attachment.id === newAttachment.id) { if (attachment.id === newAttachment.id) {
return newAttachment; return newAttachment;
} }
@ -245,7 +244,7 @@
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
formData.append('location', adventure.id); formData.append('location', location.id);
formData.append('name', attachmentName); formData.append('name', attachmentName);
try { try {
@ -256,7 +255,7 @@
if (res.ok) { if (res.ok) {
const newData = deserialize(await res.text()) as { data: Attachment }; const newData = deserialize(await res.text()) as { data: Attachment };
adventure.attachments = [...adventure.attachments, newData.data]; location.attachments = [...location.attachments, newData.data];
addToast('success', $t('adventures.attachment_upload_success')); addToast('success', $t('adventures.attachment_upload_success'));
attachmentName = ''; attachmentName = '';
} else { } else {
@ -273,7 +272,7 @@
} }
} }
let imageSearch: string = adventure.name || ''; let imageSearch: string = location.name || '';
async function removeImage(id: string) { async function removeImage(id: string) {
let res = await fetch(`/api/images/${id}/image_delete`, { let res = await fetch(`/api/images/${id}/image_delete`, {
@ -281,7 +280,7 @@
}); });
if (res.status === 204) { if (res.status === 204) {
images = images.filter((image) => image.id !== id); images = images.filter((image) => image.id !== id);
adventure.images = images; location.images = images;
addToast('success', $t('adventures.image_removed_success')); addToast('success', $t('adventures.image_removed_success'));
} else { } else {
addToast('error', $t('adventures.image_removed_error')); addToast('error', $t('adventures.image_removed_error'));
@ -291,7 +290,7 @@
let isDetails: boolean = true; let isDetails: boolean = true;
function saveAndClose() { function saveAndClose() {
dispatch('save', adventure); dispatch('save', location);
close(); close();
} }
@ -308,7 +307,7 @@
} }
return image; return image;
}); });
adventure.images = images; location.images = images;
} else { } else {
console.error('Error in makePrimaryImage:', res); console.error('Error in makePrimaryImage:', res);
} }
@ -326,7 +325,7 @@
async function uploadImage(file: File) { async function uploadImage(file: File) {
let formData = new FormData(); let formData = new FormData();
formData.append('image', file); formData.append('image', file);
formData.append('location', adventure.id); formData.append('location', location.id);
let res = await fetch(`/locations?/image`, { let res = await fetch(`/locations?/image`, {
method: 'POST', method: 'POST',
@ -341,7 +340,7 @@
immich_id: null immich_id: null
}; };
images = [...images, newImage]; images = [...images, newImage];
adventure.images = images; location.images = images;
addToast('success', $t('adventures.image_upload_success')); addToast('success', $t('adventures.image_upload_success'));
} else { } else {
addToast('error', $t('adventures.image_upload_error')); addToast('error', $t('adventures.image_upload_error'));
@ -359,7 +358,7 @@
let file = new File([data], 'image.jpg', { type: 'image/jpeg' }); let file = new File([data], 'image.jpg', { type: 'image/jpeg' });
let formData = new FormData(); let formData = new FormData();
formData.append('image', file); formData.append('image', file);
formData.append('adventure', adventure.id); formData.append('adventure', location.id);
await uploadImage(file); await uploadImage(file);
url = ''; url = '';
@ -383,7 +382,7 @@
wikiImageError = ''; wikiImageError = '';
let formData = new FormData(); let formData = new FormData();
formData.append('image', file); formData.append('image', file);
formData.append('location', adventure.id); formData.append('location', location.id);
let res2 = await fetch(`/locations?/image`, { let res2 = await fetch(`/locations?/image`, {
method: 'POST', method: 'POST',
body: formData body: formData
@ -397,7 +396,7 @@
immich_id: null immich_id: null
}; };
images = [...images, newImage]; images = [...images, newImage];
adventure.images = images; location.images = images;
addToast('success', $t('adventures.image_upload_success')); addToast('success', $t('adventures.image_upload_success'));
} else { } else {
addToast('error', $t('adventures.image_upload_error')); addToast('error', $t('adventures.image_upload_error'));
@ -417,10 +416,10 @@
} }
async function generateDesc() { async function generateDesc() {
let res = await fetch(`/api/generate/desc/?name=${adventure.name}`); let res = await fetch(`/api/generate/desc/?name=${location.name}`);
let data = await res.json(); let data = await res.json();
if (data.extract?.length > 0) { if (data.extract?.length > 0) {
adventure.description = data.extract; location.description = data.extract;
wikiError = ''; wikiError = '';
} else { } else {
wikiError = $t('adventures.no_description_found'); wikiError = $t('adventures.no_description_found');
@ -433,20 +432,20 @@
isLoading = true; isLoading = true;
// if category icon is empty, set it to the default icon // if category icon is empty, set it to the default icon
if (adventure.category?.icon == '' || adventure.category?.icon == null) { if (location.category?.icon == '' || location.category?.icon == null) {
if (adventure.category) { if (location.category) {
adventure.category.icon = '🌍'; location.category.icon = '🌍';
} }
} }
if (adventure.id === '') { if (location.id === '') {
if (adventure.category?.display_name == '') { if (location.category?.display_name == '') {
if (categories.some((category) => category.name === 'general')) { if (categories.some((category) => category.name === 'general')) {
adventure.category = categories.find( location.category = categories.find(
(category) => category.name === 'general' (category) => category.name === 'general'
) as Category; ) as Category;
} else { } else {
adventure.category = { location.category = {
id: '', id: '',
name: 'general', name: 'general',
display_name: 'General', display_name: 'General',
@ -458,7 +457,7 @@
// add this collection to the adventure // add this collection to the adventure
if (collection && collection.id) { if (collection && collection.id) {
adventure.collections = [collection.id]; location.collections = [collection.id];
} }
let res = await fetch('/api/locations', { let res = await fetch('/api/locations', {
@ -466,11 +465,11 @@
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(adventure) body: JSON.stringify(location)
}); });
let data = await res.json(); let data = await res.json();
if (data.id) { if (data.id) {
adventure = data as Location; location = data as Location;
isDetails = false; isDetails = false;
warningMessage = ''; warningMessage = '';
addToast('success', $t('adventures.location_created')); addToast('success', $t('adventures.location_created'));
@ -480,16 +479,16 @@
addToast('error', $t('adventures.location_create_error')); addToast('error', $t('adventures.location_create_error'));
} }
} else { } else {
let res = await fetch(`/api/locations/${adventure.id}`, { let res = await fetch(`/api/locations/${location.id}`, {
method: 'PATCH', method: 'PATCH',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(adventure) body: JSON.stringify(location)
}); });
let data = await res.json(); let data = await res.json();
if (data.id) { if (data.id) {
adventure = data as Location; location = data as Location;
isDetails = false; isDetails = false;
warningMessage = ''; warningMessage = '';
addToast('success', $t('adventures.location_updated')); addToast('success', $t('adventures.location_updated'));
@ -498,7 +497,7 @@
addToast('error', $t('adventures.location_update_error')); addToast('error', $t('adventures.location_update_error'));
} }
} }
imageSearch = adventure.name; imageSearch = location.name;
isLoading = false; isLoading = false;
} }
</script> </script>
@ -509,9 +508,9 @@
<!-- svelte-ignore a11y-no-noninteractive-element-interactions --> <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<div class="modal-box w-11/12 max-w-3xl" role="dialog" on:keydown={handleKeydown} tabindex="0"> <div class="modal-box w-11/12 max-w-3xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
<h3 class="font-bold text-2xl"> <h3 class="font-bold text-2xl">
{adventureToEdit ? $t('adventures.edit_location') : $t('adventures.new_location')} {locationToEdit ? $t('adventures.edit_location') : $t('adventures.new_location')}
</h3> </h3>
{#if adventure.id === '' || isDetails} {#if location.id === '' || isDetails}
<div class="modal-action items-center"> <div class="modal-action items-center">
<form method="post" style="width: 100%;" on:submit={handleSubmit}> <form method="post" style="width: 100%;" on:submit={handleSubmit}>
<!-- Grid layout for form fields --> <!-- Grid layout for form fields -->
@ -529,7 +528,7 @@
type="text" type="text"
id="name" id="name"
name="name" name="name"
bind:value={adventure.name} bind:value={location.name}
class="input input-bordered w-full" class="input input-bordered w-full"
required required
/> />
@ -539,7 +538,7 @@
>{$t('adventures.category')}<span class="text-red-500">*</span></label >{$t('adventures.category')}<span class="text-red-500">*</span></label
><br /> ><br />
<CategoryDropdown bind:categories bind:selected_category={adventure.category} /> <CategoryDropdown bind:categories bind:selected_category={location.category} />
</div> </div>
<div> <div>
<label for="rating">{$t('adventures.rating')}</label><br /> <label for="rating">{$t('adventures.rating')}</label><br />
@ -548,7 +547,7 @@
min="0" min="0"
max="5" max="5"
hidden hidden
bind:value={adventure.rating} bind:value={location.rating}
id="rating" id="rating"
name="rating" name="rating"
class="input input-bordered w-full max-w-xs mt-1" class="input input-bordered w-full max-w-xs mt-1"
@ -558,48 +557,48 @@
type="radio" type="radio"
name="rating-2" name="rating-2"
class="rating-hidden" class="rating-hidden"
checked={Number.isNaN(adventure.rating)} checked={Number.isNaN(location.rating)}
/> />
<input <input
type="radio" type="radio"
name="rating-2" name="rating-2"
class="mask mask-star-2 bg-orange-400" class="mask mask-star-2 bg-orange-400"
on:click={() => (adventure.rating = 1)} on:click={() => (location.rating = 1)}
checked={adventure.rating === 1} checked={location.rating === 1}
/> />
<input <input
type="radio" type="radio"
name="rating-2" name="rating-2"
class="mask mask-star-2 bg-orange-400" class="mask mask-star-2 bg-orange-400"
on:click={() => (adventure.rating = 2)} on:click={() => (location.rating = 2)}
checked={adventure.rating === 2} checked={location.rating === 2}
/> />
<input <input
type="radio" type="radio"
name="rating-2" name="rating-2"
class="mask mask-star-2 bg-orange-400" class="mask mask-star-2 bg-orange-400"
on:click={() => (adventure.rating = 3)} on:click={() => (location.rating = 3)}
checked={adventure.rating === 3} checked={location.rating === 3}
/> />
<input <input
type="radio" type="radio"
name="rating-2" name="rating-2"
class="mask mask-star-2 bg-orange-400" class="mask mask-star-2 bg-orange-400"
on:click={() => (adventure.rating = 4)} on:click={() => (location.rating = 4)}
checked={adventure.rating === 4} checked={location.rating === 4}
/> />
<input <input
type="radio" type="radio"
name="rating-2" name="rating-2"
class="mask mask-star-2 bg-orange-400" class="mask mask-star-2 bg-orange-400"
on:click={() => (adventure.rating = 5)} on:click={() => (location.rating = 5)}
checked={adventure.rating === 5} checked={location.rating === 5}
/> />
{#if adventure.rating} {#if location.rating}
<button <button
type="button" type="button"
class="btn btn-sm btn-error ml-2" class="btn btn-sm btn-error ml-2"
on:click={() => (adventure.rating = NaN)} on:click={() => (location.rating = NaN)}
> >
{$t('adventures.remove')} {$t('adventures.remove')}
</button> </button>
@ -613,14 +612,14 @@
type="text" type="text"
id="link" id="link"
name="link" name="link"
bind:value={adventure.link} bind:value={location.link}
class="input input-bordered w-full" class="input input-bordered w-full"
/> />
</div> </div>
</div> </div>
<div> <div>
<label for="description">{$t('adventures.description')}</label><br /> <label for="description">{$t('adventures.description')}</label><br />
<MarkdownEditor bind:text={adventure.description} /> <MarkdownEditor bind:text={location.description} />
<div class="mt-2"> <div class="mt-2">
<div class="tooltip tooltip-right" data-tip={$t('adventures.wiki_location_desc')}> <div class="tooltip tooltip-right" data-tip={$t('adventures.wiki_location_desc')}>
<button type="button" class="btn btn-neutral mt-2" on:click={generateDesc} <button type="button" class="btn btn-neutral mt-2" on:click={generateDesc}
@ -630,7 +629,7 @@
<p class="text-red-500">{wikiError}</p> <p class="text-red-500">{wikiError}</p>
</div> </div>
</div> </div>
{#if !adventureToEdit || (adventureToEdit.collections && adventureToEdit.collections.length === 0)} {#if !locationToEdit || (locationToEdit.collections && locationToEdit.collections.length === 0)}
<div> <div>
<div class="form-control flex items-start mt-1"> <div class="form-control flex items-start mt-1">
<label class="label cursor-pointer flex items-start space-x-2"> <label class="label cursor-pointer flex items-start space-x-2">
@ -640,7 +639,7 @@
class="toggle toggle-primary" class="toggle toggle-primary"
id="is_public" id="is_public"
name="is_public" name="is_public"
bind:checked={adventure.is_public} bind:checked={location.is_public}
/> />
</label> </label>
</div> </div>
@ -649,12 +648,12 @@
</div> </div>
</div> </div>
<LocationDropdown bind:item={adventure} bind:triggerMarkVisted {initialLatLng} /> <LocationDropdown bind:item={location} bind:triggerMarkVisted {initialLatLng} />
<div class="collapse collapse-plus bg-base-200 mb-4 overflow-visible"> <div class="collapse collapse-plus bg-base-200 mb-4 overflow-visible">
<input type="checkbox" /> <input type="checkbox" />
<div class="collapse-title text-xl font-medium"> <div class="collapse-title text-xl font-medium">
{$t('adventures.tags')} ({adventure.tags?.length || 0}) {$t('adventures.tags')} ({location.tags?.length || 0})
</div> </div>
<div class="collapse-content"> <div class="collapse-content">
<input <input
@ -662,14 +661,14 @@
id="tags" id="tags"
name="tags" name="tags"
hidden hidden
bind:value={adventure.tags} bind:value={location.tags}
class="input input-bordered w-full" class="input input-bordered w-full"
/> />
<ActivityComplete bind:activities={adventure.tags} /> <ActivityComplete bind:activities={location.tags} />
</div> </div>
</div> </div>
<DateRangeCollapse type="adventure" {collection} bind:visits={adventure.visits} /> <DateRangeCollapse type="adventure" {collection} bind:visits={location.visits} />
<div> <div>
<div class="mt-4"> <div class="mt-4">
@ -711,11 +710,11 @@
<div class="collapse collapse-plus bg-base-200 mb-4"> <div class="collapse collapse-plus bg-base-200 mb-4">
<input type="checkbox" /> <input type="checkbox" />
<div class="collapse-title text-xl font-medium"> <div class="collapse-title text-xl font-medium">
{$t('adventures.attachments')} ({adventure.attachments?.length || 0}) {$t('adventures.attachments')} ({location.attachments?.length || 0})
</div> </div>
<div class="collapse-content"> <div class="collapse-content">
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3"> <div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{#each adventure.attachments as attachment} {#each location.attachments as attachment}
<AttachmentCard <AttachmentCard
{attachment} {attachment}
on:delete={deleteAttachment} on:delete={deleteAttachment}
@ -785,7 +784,7 @@
<div class="collapse collapse-plus bg-base-200 mb-4"> <div class="collapse collapse-plus bg-base-200 mb-4">
<input type="checkbox" checked /> <input type="checkbox" checked />
<div class="collapse-title text-xl font-medium"> <div class="collapse-title text-xl font-medium">
{$t('adventures.images')} ({adventure.images?.length || 0}) {$t('adventures.images')} ({location.images?.length || 0})
</div> </div>
<div class="collapse-content"> <div class="collapse-content">
<label for="image" class="block font-medium mb-2"> <label for="image" class="block font-medium mb-2">
@ -802,7 +801,7 @@
multiple multiple
on:change={handleMultipleFiles} on:change={handleMultipleFiles}
/> />
<input type="hidden" name="adventure" value={adventure.id} id="adventure" /> <input type="hidden" name="adventure" value={location.id} id="adventure" />
</form> </form>
<div class="mb-4"> <div class="mb-4">
@ -848,7 +847,7 @@
{#if immichIntegration} {#if immichIntegration}
<ImmichSelect <ImmichSelect
{adventure} adventure={location}
on:fetchImage={(e) => { on:fetchImage={(e) => {
url = e.detail; url = e.detail;
fetchImage(); fetchImage();
@ -862,7 +861,7 @@
immich_id: e.detail.immich_id immich_id: e.detail.immich_id
}; };
images = [...images, newImage]; images = [...images, newImage];
adventure.images = images; location.images = images;
addToast('success', $t('adventures.image_upload_success')); addToast('success', $t('adventures.image_upload_success'));
}} }}
/> />
@ -917,17 +916,17 @@
</div> </div>
{/if} {/if}
{#if adventure.is_public && adventure.id} {#if location.is_public && location.id}
<div class="bg-neutral p-4 mt-2 rounded-md shadow-sm text-neutral-content"> <div class="bg-neutral p-4 mt-2 rounded-md shadow-sm text-neutral-content">
<p class=" font-semibold">{$t('adventures.share_location')}</p> <p class=" font-semibold">{$t('adventures.share_location')}</p>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<p class="text-card-foreground font-mono"> <p class="text-card-foreground font-mono">
{window.location.origin}/locations/{adventure.id} {window.location.origin}/locations/{location.id}
</p> </p>
<button <button
type="button" type="button"
on:click={() => { on:click={() => {
navigator.clipboard.writeText(`${window.location.origin}/locations/${adventure.id}`); navigator.clipboard.writeText(`${window.location.origin}/locations/${location.id}`);
}} }}
class="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2" class="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2"
> >

View file

@ -276,7 +276,7 @@ export type ImmichAlbum = {
export type Attachment = { export type Attachment = {
id: string; id: string;
file: string; file: string;
adventure: string; location: string;
extension: string; extension: string;
user: string; user: string;
name: string; name: string;

View file

@ -15,7 +15,7 @@
import DayGrid from '@event-calendar/day-grid'; import DayGrid from '@event-calendar/day-grid';
import Plus from '~icons/mdi/plus'; import Plus from '~icons/mdi/plus';
import AdventureCard from '$lib/components/LocationCard.svelte'; import LocationCard from '$lib/components/LocationCard.svelte';
import AdventureLink from '$lib/components/LocationLink.svelte'; import AdventureLink from '$lib/components/LocationLink.svelte';
import { MapLibre, Marker, Popup, LineLayer, GeoJSON } from 'svelte-maplibre'; import { MapLibre, Marker, Popup, LineLayer, GeoJSON } from 'svelte-maplibre';
import TransportationCard from '$lib/components/TransportationCard.svelte'; import TransportationCard from '$lib/components/TransportationCard.svelte';
@ -39,7 +39,7 @@
import ChecklistCard from '$lib/components/ChecklistCard.svelte'; import ChecklistCard from '$lib/components/ChecklistCard.svelte';
import ChecklistModal from '$lib/components/ChecklistModal.svelte'; import ChecklistModal from '$lib/components/ChecklistModal.svelte';
import AdventureModal from '$lib/components/LocationModal.svelte'; import LocationModal from '$lib/components/LocationModal.svelte';
import TransportationModal from '$lib/components/TransportationModal.svelte'; import TransportationModal from '$lib/components/TransportationModal.svelte';
import CardCarousel from '$lib/components/CardCarousel.svelte'; import CardCarousel from '$lib/components/CardCarousel.svelte';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
@ -517,14 +517,14 @@
}, },
attachments: [] attachments: []
}; };
isAdventureModalOpen = true; isLocationModalOpen = true;
} }
let adventureToEdit: Location | null = null; let adventureToEdit: Location | null = null;
let transportationToEdit: Transportation | null = null; let transportationToEdit: Transportation | null = null;
let isShowingLodgingModal: boolean = false; let isShowingLodgingModal: boolean = false;
let lodgingToEdit: Lodging | null = null; let lodgingToEdit: Lodging | null = null;
let isAdventureModalOpen: boolean = false; let isLocationModalOpen: boolean = false;
let isNoteModalOpen: boolean = false; let isNoteModalOpen: boolean = false;
let noteToEdit: Note | null; let noteToEdit: Note | null;
let checklistToEdit: Checklist | null; let checklistToEdit: Checklist | null;
@ -533,7 +533,7 @@
function editAdventure(event: CustomEvent<Location>) { function editAdventure(event: CustomEvent<Location>) {
adventureToEdit = event.detail; adventureToEdit = event.detail;
isAdventureModalOpen = true; isLocationModalOpen = true;
} }
function editTransportation(event: CustomEvent<Transportation>) { function editTransportation(event: CustomEvent<Transportation>) {
@ -557,7 +557,7 @@
} else { } else {
adventures = [event.detail, ...adventures]; adventures = [event.detail, ...adventures];
} }
isAdventureModalOpen = false; isLocationModalOpen = false;
} }
let isPopupOpen = false; let isPopupOpen = false;
@ -688,10 +688,10 @@
/> />
{/if} {/if}
{#if isAdventureModalOpen} {#if isLocationModalOpen}
<AdventureModal <LocationModal
{adventureToEdit} locationToEdit={adventureToEdit}
on:close={() => (isAdventureModalOpen = false)} on:close={() => (isLocationModalOpen = false)}
on:save={saveOrCreateAdventure} on:save={saveOrCreateAdventure}
{collection} {collection}
/> />
@ -775,7 +775,7 @@
<button <button
class="btn btn-primary" class="btn btn-primary"
on:click={() => { on:click={() => {
isAdventureModalOpen = true; isLocationModalOpen = true;
adventureToEdit = null; adventureToEdit = null;
}} }}
> >
@ -1069,7 +1069,7 @@
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{#if dayAdventures.length > 0} {#if dayAdventures.length > 0}
{#each dayAdventures as adventure} {#each dayAdventures as adventure}
<AdventureCard <LocationCard
user={data.user} user={data.user}
on:edit={editAdventure} on:edit={editAdventure}
on:delete={deleteAdventure} on:delete={deleteAdventure}
@ -1224,7 +1224,7 @@
</div> </div>
</div> </div>
{#if orderedItem.type === 'adventure' && orderedItem.item && 'images' in orderedItem.item} {#if orderedItem.type === 'adventure' && orderedItem.item && 'images' in orderedItem.item}
<AdventureCard <LocationCard
user={data.user} user={data.user}
on:edit={editAdventure} on:edit={editAdventure}
on:delete={deleteAdventure} on:delete={deleteAdventure}

View file

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import AdventureCard from '$lib/components/LocationCard.svelte'; import LocationCard from '$lib/components/LocationCard.svelte';
import type { PageData } from './$types'; import type { PageData } from './$types';
import { t } from 'svelte-i18n'; import { t } from 'svelte-i18n';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
@ -178,7 +178,7 @@
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6">
{#each recentAdventures as adventure} {#each recentAdventures as adventure}
<div class="adventure-card"> <div class="adventure-card">
<AdventureCard {adventure} user={data.user} readOnly /> <LocationCard {adventure} user={data.user} readOnly />
</div> </div>
{/each} {/each}
</div> </div>

View file

@ -2,8 +2,8 @@
import { enhance, deserialize } from '$app/forms'; import { enhance, deserialize } from '$app/forms';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { page } from '$app/stores'; import { page } from '$app/stores';
import AdventureCard from '$lib/components/LocationCard.svelte'; import LocationCard from '$lib/components/LocationCard.svelte';
import AdventureModal from '$lib/components/LocationModal.svelte'; import LocationModal from '$lib/components/LocationModal.svelte';
import CategoryFilterDropdown from '$lib/components/CategoryFilterDropdown.svelte'; import CategoryFilterDropdown from '$lib/components/CategoryFilterDropdown.svelte';
import CategoryModal from '$lib/components/CategoryModal.svelte'; import CategoryModal from '$lib/components/CategoryModal.svelte';
import NotFound from '$lib/components/NotFound.svelte'; import NotFound from '$lib/components/NotFound.svelte';
@ -42,7 +42,7 @@
let is_category_modal_open: boolean = false; let is_category_modal_open: boolean = false;
let typeString: string = ''; let typeString: string = '';
let adventureToEdit: Location | null = null; let adventureToEdit: Location | null = null;
let isAdventureModalOpen: boolean = false; let isLocationModalOpen: boolean = false;
let sidebarOpen = false; let sidebarOpen = false;
// Reactive statements // Reactive statements
@ -141,12 +141,12 @@
} else { } else {
adventures = [event.detail, ...adventures]; adventures = [event.detail, ...adventures];
} }
isAdventureModalOpen = false; isLocationModalOpen = false;
} }
function editAdventure(event: CustomEvent<Location>) { function editAdventure(event: CustomEvent<Location>) {
adventureToEdit = event.detail; adventureToEdit = event.detail;
isAdventureModalOpen = true; isLocationModalOpen = true;
} }
function toggleSidebar() { function toggleSidebar() {
@ -167,10 +167,10 @@
<meta name="description" content="View your completed and planned adventures." /> <meta name="description" content="View your completed and planned adventures." />
</svelte:head> </svelte:head>
{#if isAdventureModalOpen} {#if isLocationModalOpen}
<AdventureModal <LocationModal
{adventureToEdit} locationToEdit={adventureToEdit}
on:close={() => (isAdventureModalOpen = false)} on:close={() => (isLocationModalOpen = false)}
on:save={saveOrCreate} on:save={saveOrCreate}
/> />
{/if} {/if}
@ -250,7 +250,7 @@
class="btn btn-primary btn-wide mt-6 gap-2" class="btn btn-primary btn-wide mt-6 gap-2"
on:click={() => { on:click={() => {
adventureToEdit = null; adventureToEdit = null;
isAdventureModalOpen = true; isLocationModalOpen = true;
}} }}
> >
<Plus class="w-5 h-5" /> <Plus class="w-5 h-5" />
@ -263,7 +263,7 @@
class="grid grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 gap-6" class="grid grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 gap-6"
> >
{#each adventures as adventure} {#each adventures as adventure}
<AdventureCard <LocationCard
user={data.user} user={data.user}
{adventure} {adventure}
on:delete={deleteAdventure} on:delete={deleteAdventure}
@ -503,7 +503,7 @@
<button <button
class="btn btn-primary gap-2 w-full" class="btn btn-primary gap-2 w-full"
on:click={() => { on:click={() => {
isAdventureModalOpen = true; isLocationModalOpen = true;
adventureToEdit = null; adventureToEdit = null;
}} }}
> >

View file

@ -16,7 +16,7 @@
import LightbulbOn from '~icons/mdi/lightbulb-on'; import LightbulbOn from '~icons/mdi/lightbulb-on';
import WeatherSunset from '~icons/mdi/weather-sunset'; import WeatherSunset from '~icons/mdi/weather-sunset';
import ClipboardList from '~icons/mdi/clipboard-list'; import ClipboardList from '~icons/mdi/clipboard-list';
import AdventureModal from '$lib/components/LocationModal.svelte'; import LocationModal from '$lib/components/LocationModal.svelte';
import ImageDisplayModal from '$lib/components/ImageDisplayModal.svelte'; import ImageDisplayModal from '$lib/components/ImageDisplayModal.svelte';
import AttachmentCard from '$lib/components/AttachmentCard.svelte'; import AttachmentCard from '$lib/components/AttachmentCard.svelte';
import { getBasemapUrl, isAllDay } from '$lib'; import { getBasemapUrl, isAllDay } from '$lib';
@ -132,8 +132,8 @@
{/if} {/if}
{#if isEditModalOpen} {#if isEditModalOpen}
<AdventureModal <LocationModal
adventureToEdit={adventure} locationToEdit={adventure}
on:close={() => (isEditModalOpen = false)} on:close={() => (isEditModalOpen = false)}
on:save={saveEdit} on:save={saveEdit}
/> />

View file

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import AdventureModal from '$lib/components/LocationModal.svelte'; import LocationModal from '$lib/components/LocationModal.svelte';
import { DefaultMarker, MapEvents, MapLibre, Popup, Marker } from 'svelte-maplibre'; import { DefaultMarker, MapEvents, MapLibre, Popup, Marker } from 'svelte-maplibre';
import { t } from 'svelte-i18n'; import { t } from 'svelte-i18n';
import type { Location, VisitedRegion } from '$lib/types.js'; import type { Location, VisitedRegion } from '$lib/types.js';
@ -457,7 +457,7 @@
</div> </div>
{#if createModalOpen} {#if createModalOpen}
<AdventureModal <LocationModal
on:close={() => (createModalOpen = false)} on:close={() => (createModalOpen = false)}
on:save={createNewAdventure} on:save={createNewAdventure}
{initialLatLng} {initialLatLng}

View file

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
export let data; export let data;
import AdventureCard from '$lib/components/LocationCard.svelte'; import LocationCard from '$lib/components/LocationCard.svelte';
import CollectionCard from '$lib/components/CollectionCard.svelte'; import CollectionCard from '$lib/components/CollectionCard.svelte';
import type { Location, Collection, User } from '$lib/types.js'; import type { Location, Collection, User } from '$lib/types.js';
import { t } from 'svelte-i18n'; import { t } from 'svelte-i18n';
@ -359,7 +359,7 @@
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6">
{#each adventures as adventure} {#each adventures as adventure}
<div class="adventure-card"> <div class="adventure-card">
<AdventureCard {adventure} user={null} /> <LocationCard {adventure} user={null} />
</div> </div>
{/each} {/each}
</div> </div>