diff --git a/frontend/src/lib/components/CollectionAllView.svelte b/frontend/src/lib/components/CollectionAllView.svelte index 7f6697d..0ca295e 100644 --- a/frontend/src/lib/components/CollectionAllView.svelte +++ b/frontend/src/lib/components/CollectionAllView.svelte @@ -24,7 +24,7 @@ import Filter from '~icons/mdi/filter-variant'; // Component imports - import AdventureCard from './LocationCard.svelte'; + import LocationCard from './LocationCard.svelte'; import TransportationCard from './TransportationCard.svelte'; import LodgingCard from './LodgingCard.svelte'; import NoteCard from './NoteCard.svelte'; @@ -432,7 +432,7 @@
{#each filteredAdventures as adventure} -
{#each filteredAdventures as adventure} - + {/each}
{/if} diff --git a/frontend/src/lib/components/LocationModal.svelte b/frontend/src/lib/components/LocationModal.svelte index c8271a3..2f38bac 100644 --- a/frontend/src/lib/components/LocationModal.svelte +++ b/frontend/src/lib/components/LocationModal.svelte @@ -23,7 +23,6 @@ let images: { id: string; image: string; is_primary: boolean; immich_id: string | null }[] = []; let warningMessage: string = ''; - let constrainDates: boolean = false; let categories: Category[] = []; @@ -97,7 +96,7 @@ let wikiError: string = ''; - let adventure: Location = { + let location: Location = { id: '', name: '', visits: [], @@ -121,24 +120,24 @@ attachments: [] }; - export let adventureToEdit: Location | null = null; + export let locationToEdit: Location | null = null; - adventure = { - id: adventureToEdit?.id || '', - name: adventureToEdit?.name || '', - link: adventureToEdit?.link || null, - description: adventureToEdit?.description || null, - tags: adventureToEdit?.tags || [], - rating: adventureToEdit?.rating || NaN, - is_public: adventureToEdit?.is_public || false, - latitude: adventureToEdit?.latitude || NaN, - longitude: adventureToEdit?.longitude || NaN, - location: adventureToEdit?.location || null, - images: adventureToEdit?.images || [], - user: adventureToEdit?.user || null, - visits: adventureToEdit?.visits || [], - is_visited: adventureToEdit?.is_visited || false, - category: adventureToEdit?.category || { + location = { + id: locationToEdit?.id || '', + name: locationToEdit?.name || '', + link: locationToEdit?.link || null, + description: locationToEdit?.description || null, + tags: locationToEdit?.tags || [], + rating: locationToEdit?.rating || NaN, + is_public: locationToEdit?.is_public || false, + latitude: locationToEdit?.latitude || NaN, + longitude: locationToEdit?.longitude || NaN, + location: locationToEdit?.location || null, + images: locationToEdit?.images || [], + user: locationToEdit?.user || null, + visits: locationToEdit?.visits || [], + is_visited: locationToEdit?.is_visited || false, + category: locationToEdit?.category || { id: '', name: '', display_name: '', @@ -146,7 +145,7 @@ user: '' }, - attachments: adventureToEdit?.attachments || [] + attachments: locationToEdit?.attachments || [] }; onMount(async () => { @@ -183,15 +182,15 @@ let isLoading: boolean = false; - images = adventure.images || []; + images = location.images || []; $: { - if (!adventure.rating) { - adventure.rating = NaN; + if (!location.rating) { + location.rating = NaN; } } function deleteAttachment(event: CustomEvent) { - adventure.attachments = adventure.attachments.filter( + location.attachments = location.attachments.filter( (attachment) => attachment.id !== event.detail ); } @@ -210,7 +209,7 @@ }); if (res.ok) { let newAttachment = (await res.json()) as Attachment; - adventure.attachments = adventure.attachments.map((attachment) => { + location.attachments = location.attachments.map((attachment) => { if (attachment.id === newAttachment.id) { return newAttachment; } @@ -245,7 +244,7 @@ const formData = new FormData(); formData.append('file', file); - formData.append('location', adventure.id); + formData.append('location', location.id); formData.append('name', attachmentName); try { @@ -256,7 +255,7 @@ if (res.ok) { 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')); attachmentName = ''; } else { @@ -273,7 +272,7 @@ } } - let imageSearch: string = adventure.name || ''; + let imageSearch: string = location.name || ''; async function removeImage(id: string) { let res = await fetch(`/api/images/${id}/image_delete`, { @@ -281,7 +280,7 @@ }); if (res.status === 204) { images = images.filter((image) => image.id !== id); - adventure.images = images; + location.images = images; addToast('success', $t('adventures.image_removed_success')); } else { addToast('error', $t('adventures.image_removed_error')); @@ -291,7 +290,7 @@ let isDetails: boolean = true; function saveAndClose() { - dispatch('save', adventure); + dispatch('save', location); close(); } @@ -308,7 +307,7 @@ } return image; }); - adventure.images = images; + location.images = images; } else { console.error('Error in makePrimaryImage:', res); } @@ -326,7 +325,7 @@ async function uploadImage(file: File) { let formData = new FormData(); formData.append('image', file); - formData.append('location', adventure.id); + formData.append('location', location.id); let res = await fetch(`/locations?/image`, { method: 'POST', @@ -341,7 +340,7 @@ immich_id: null }; images = [...images, newImage]; - adventure.images = images; + location.images = images; addToast('success', $t('adventures.image_upload_success')); } else { addToast('error', $t('adventures.image_upload_error')); @@ -359,7 +358,7 @@ let file = new File([data], 'image.jpg', { type: 'image/jpeg' }); let formData = new FormData(); formData.append('image', file); - formData.append('adventure', adventure.id); + formData.append('adventure', location.id); await uploadImage(file); url = ''; @@ -383,7 +382,7 @@ wikiImageError = ''; let formData = new FormData(); formData.append('image', file); - formData.append('location', adventure.id); + formData.append('location', location.id); let res2 = await fetch(`/locations?/image`, { method: 'POST', body: formData @@ -397,7 +396,7 @@ immich_id: null }; images = [...images, newImage]; - adventure.images = images; + location.images = images; addToast('success', $t('adventures.image_upload_success')); } else { addToast('error', $t('adventures.image_upload_error')); @@ -417,10 +416,10 @@ } 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(); if (data.extract?.length > 0) { - adventure.description = data.extract; + location.description = data.extract; wikiError = ''; } else { wikiError = $t('adventures.no_description_found'); @@ -433,20 +432,20 @@ isLoading = true; // if category icon is empty, set it to the default icon - if (adventure.category?.icon == '' || adventure.category?.icon == null) { - if (adventure.category) { - adventure.category.icon = '🌍'; + if (location.category?.icon == '' || location.category?.icon == null) { + if (location.category) { + location.category.icon = '🌍'; } } - if (adventure.id === '') { - if (adventure.category?.display_name == '') { + if (location.id === '') { + if (location.category?.display_name == '') { if (categories.some((category) => category.name === 'general')) { - adventure.category = categories.find( + location.category = categories.find( (category) => category.name === 'general' ) as Category; } else { - adventure.category = { + location.category = { id: '', name: 'general', display_name: 'General', @@ -458,7 +457,7 @@ // add this collection to the adventure if (collection && collection.id) { - adventure.collections = [collection.id]; + location.collections = [collection.id]; } let res = await fetch('/api/locations', { @@ -466,11 +465,11 @@ headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(adventure) + body: JSON.stringify(location) }); let data = await res.json(); if (data.id) { - adventure = data as Location; + location = data as Location; isDetails = false; warningMessage = ''; addToast('success', $t('adventures.location_created')); @@ -480,16 +479,16 @@ addToast('error', $t('adventures.location_create_error')); } } else { - let res = await fetch(`/api/locations/${adventure.id}`, { + let res = await fetch(`/api/locations/${location.id}`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(adventure) + body: JSON.stringify(location) }); let data = await res.json(); if (data.id) { - adventure = data as Location; + location = data as Location; isDetails = false; warningMessage = ''; addToast('success', $t('adventures.location_updated')); @@ -498,7 +497,7 @@ addToast('error', $t('adventures.location_update_error')); } } - imageSearch = adventure.name; + imageSearch = location.name; isLoading = false; } @@ -509,9 +508,9 @@

- +
- {#if !adventureToEdit || (adventureToEdit.collections && adventureToEdit.collections.length === 0)} + {#if !locationToEdit || (locationToEdit.collections && locationToEdit.collections.length === 0)}
@@ -649,12 +648,12 @@
- +
- {$t('adventures.tags')} ({adventure.tags?.length || 0}) + {$t('adventures.tags')} ({location.tags?.length || 0})
- +
- +
@@ -711,11 +710,11 @@
- {$t('adventures.attachments')} ({adventure.attachments?.length || 0}) + {$t('adventures.attachments')} ({location.attachments?.length || 0})
- {#each adventure.attachments as attachment} + {#each location.attachments as attachment}
- {$t('adventures.images')} ({adventure.images?.length || 0}) + {$t('adventures.images')} ({location.images?.length || 0})