2024-07-08 11:44:39 -04:00
|
|
|
<script lang="ts">
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
2024-10-30 15:11:00 -04:00
|
|
|
import type {
|
|
|
|
Adventure,
|
2025-01-19 22:22:03 -05:00
|
|
|
Attachment,
|
2024-11-22 17:03:02 -05:00
|
|
|
Category,
|
2024-10-30 15:11:00 -04:00
|
|
|
Collection,
|
|
|
|
OpenStreetMapPlace,
|
|
|
|
Point,
|
|
|
|
ReverseGeocode
|
|
|
|
} from '$lib/types';
|
2024-07-08 11:44:39 -04:00
|
|
|
import { onMount } from 'svelte';
|
|
|
|
import { addToast } from '$lib/toasts';
|
2024-08-17 15:18:43 -04:00
|
|
|
import { deserialize } from '$app/forms';
|
2024-10-28 19:59:44 -04:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-08-17 11:12:15 -04:00
|
|
|
export let longitude: number | null = null;
|
|
|
|
export let latitude: number | null = null;
|
2024-10-01 09:32:02 -04:00
|
|
|
export let collection: Collection | null = null;
|
2024-08-20 12:39:15 -04:00
|
|
|
|
2024-11-22 17:03:02 -05:00
|
|
|
import { DefaultMarker, MapEvents, MapLibre } from 'svelte-maplibre';
|
2024-08-23 18:24:41 -04:00
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
let query: string = '';
|
|
|
|
let places: OpenStreetMapPlace[] = [];
|
2025-01-02 23:25:58 -05:00
|
|
|
let images: { id: string; image: string; is_primary: boolean }[] = [];
|
2024-09-17 10:34:31 -04:00
|
|
|
let warningMessage: string = '';
|
2024-10-04 21:33:02 -04:00
|
|
|
let constrainDates: boolean = false;
|
2024-08-17 11:12:15 -04:00
|
|
|
|
2024-11-22 17:03:02 -05:00
|
|
|
let categories: Category[] = [];
|
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
import ActivityComplete from './ActivityComplete.svelte';
|
|
|
|
import { appVersion } from '$lib/config';
|
2024-11-22 17:03:02 -05:00
|
|
|
import CategoryDropdown from './CategoryDropdown.svelte';
|
2024-11-23 13:42:41 -05:00
|
|
|
import { findFirstValue } from '$lib';
|
2024-12-17 18:58:38 -05:00
|
|
|
import MarkdownEditor from './MarkdownEditor.svelte';
|
2025-01-02 17:56:47 -05:00
|
|
|
import ImmichSelect from './ImmichSelect.svelte';
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2025-01-02 23:25:58 -05:00
|
|
|
import Star from '~icons/mdi/star';
|
|
|
|
import Crown from '~icons/mdi/crown';
|
2025-01-19 22:22:03 -05:00
|
|
|
import AttachmentCard from './AttachmentCard.svelte';
|
2025-01-02 23:25:58 -05:00
|
|
|
|
2024-08-17 22:48:57 -04:00
|
|
|
let wikiError: string = '';
|
|
|
|
|
2024-08-17 14:21:55 -04:00
|
|
|
let noPlaces: boolean = false;
|
|
|
|
|
2024-11-08 09:39:03 -05:00
|
|
|
let is_custom_location: boolean = false;
|
|
|
|
|
2024-10-30 15:11:00 -04:00
|
|
|
let reverseGeocodePlace: ReverseGeocode | null = null;
|
|
|
|
|
2024-08-20 12:39:15 -04:00
|
|
|
let adventure: Adventure = {
|
|
|
|
id: '',
|
|
|
|
name: '',
|
2024-09-23 18:46:04 -04:00
|
|
|
visits: [],
|
2024-08-20 12:39:15 -04:00
|
|
|
link: null,
|
|
|
|
description: null,
|
|
|
|
activity_types: [],
|
|
|
|
rating: NaN,
|
|
|
|
is_public: false,
|
|
|
|
latitude: NaN,
|
|
|
|
longitude: NaN,
|
|
|
|
location: null,
|
|
|
|
images: [],
|
|
|
|
user_id: null,
|
2024-11-17 16:34:46 -05:00
|
|
|
collection: collection?.id || null,
|
2024-11-23 13:42:41 -05:00
|
|
|
category: {
|
|
|
|
id: '',
|
|
|
|
name: '',
|
|
|
|
display_name: '',
|
|
|
|
icon: '',
|
|
|
|
user_id: ''
|
2025-01-19 22:22:03 -05:00
|
|
|
},
|
|
|
|
attachments: []
|
2024-08-20 12:39:15 -04:00
|
|
|
};
|
|
|
|
|
2024-08-17 22:40:27 -04:00
|
|
|
export let adventureToEdit: Adventure | null = null;
|
|
|
|
|
2024-08-20 12:39:15 -04:00
|
|
|
adventure = {
|
2024-08-17 22:40:27 -04:00
|
|
|
id: adventureToEdit?.id || '',
|
|
|
|
name: adventureToEdit?.name || '',
|
|
|
|
link: adventureToEdit?.link || null,
|
|
|
|
description: adventureToEdit?.description || null,
|
|
|
|
activity_types: adventureToEdit?.activity_types || [],
|
|
|
|
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_id: adventureToEdit?.user_id || null,
|
2024-10-01 09:32:02 -04:00
|
|
|
collection: adventureToEdit?.collection || collection?.id || null,
|
2024-11-02 21:18:52 -04:00
|
|
|
visits: adventureToEdit?.visits || [],
|
2024-11-17 16:34:46 -05:00
|
|
|
is_visited: adventureToEdit?.is_visited || false,
|
2024-11-23 13:42:41 -05:00
|
|
|
category: adventureToEdit?.category || {
|
|
|
|
id: '',
|
|
|
|
name: '',
|
|
|
|
display_name: '',
|
|
|
|
icon: '',
|
|
|
|
user_id: ''
|
2025-01-19 22:22:03 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
attachments: adventureToEdit?.attachments || []
|
2024-08-17 22:40:27 -04:00
|
|
|
};
|
2024-08-17 11:12:15 -04:00
|
|
|
|
2024-08-23 18:24:41 -04:00
|
|
|
let markers: Point[] = [];
|
|
|
|
|
2024-08-17 15:18:43 -04:00
|
|
|
let url: string = '';
|
|
|
|
let imageError: string = '';
|
2024-08-17 16:28:56 -04:00
|
|
|
let wikiImageError: string = '';
|
2024-08-17 15:18:43 -04:00
|
|
|
|
2024-11-07 19:48:44 -05:00
|
|
|
let old_display_name: string = '';
|
|
|
|
|
2024-08-17 22:40:27 -04:00
|
|
|
images = adventure.images || [];
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2024-11-01 20:08:23 -04:00
|
|
|
if (longitude && latitude) {
|
|
|
|
adventure.latitude = latitude;
|
|
|
|
adventure.longitude = longitude;
|
2024-11-08 17:15:53 -05:00
|
|
|
reverseGeocode(true);
|
2024-11-01 20:08:23 -04:00
|
|
|
}
|
|
|
|
|
2024-11-08 09:39:03 -05:00
|
|
|
$: {
|
2024-11-12 23:12:08 -05:00
|
|
|
is_custom_location = adventure.location != reverseGeocodePlace?.display_name;
|
2024-11-08 09:39:03 -05:00
|
|
|
}
|
|
|
|
|
2024-08-17 22:40:27 -04:00
|
|
|
if (adventure.longitude && adventure.latitude) {
|
2024-08-23 18:24:41 -04:00
|
|
|
markers = [];
|
2024-08-17 17:34:52 -04:00
|
|
|
markers = [
|
|
|
|
{
|
2024-08-17 22:40:27 -04:00
|
|
|
lngLat: { lng: adventure.longitude, lat: adventure.latitude },
|
|
|
|
location: adventure.location || '',
|
|
|
|
name: adventure.name,
|
2024-08-18 09:15:59 -04:00
|
|
|
activity_type: ''
|
2024-08-17 17:34:52 -04:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
$: {
|
2024-08-17 22:40:27 -04:00
|
|
|
if (!adventure.rating) {
|
|
|
|
adventure.rating = NaN;
|
2024-08-17 11:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-19 22:22:03 -05:00
|
|
|
function deleteAttachment(event: CustomEvent<string>) {
|
|
|
|
adventure.attachments = adventure.attachments.filter(
|
|
|
|
(attachment) => attachment.id !== event.detail
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
let attachmentName: string = '';
|
|
|
|
let attachmentToEdit: Attachment | null = null;
|
|
|
|
|
|
|
|
async function editAttachment() {
|
|
|
|
if (attachmentToEdit) {
|
|
|
|
let res = await fetch(`/api/attachments/${attachmentToEdit.id}/`, {
|
|
|
|
method: 'PATCH',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({ name: attachmentToEdit.name })
|
|
|
|
});
|
|
|
|
if (res.ok) {
|
|
|
|
let newAttachment = (await res.json()) as Attachment;
|
|
|
|
adventure.attachments = adventure.attachments.map((attachment) => {
|
|
|
|
if (attachment.id === newAttachment.id) {
|
|
|
|
return newAttachment;
|
|
|
|
}
|
|
|
|
return attachment;
|
|
|
|
});
|
|
|
|
attachmentToEdit = null;
|
|
|
|
addToast('success', $t('adventures.attachment_update_success'));
|
|
|
|
} else {
|
|
|
|
addToast('error', $t('adventures.attachment_update_error'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-22 08:36:02 -05:00
|
|
|
let selectedFile: File | null = null;
|
|
|
|
|
|
|
|
function handleFileChange(event: Event) {
|
|
|
|
const input = event.target as HTMLInputElement;
|
|
|
|
if (input.files && input.files.length) {
|
|
|
|
selectedFile = input.files[0];
|
|
|
|
console.log('Selected file:', selectedFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-19 22:22:03 -05:00
|
|
|
async function uploadAttachment(event: Event) {
|
|
|
|
event.preventDefault();
|
|
|
|
console.log('UPLOAD');
|
2025-01-22 08:36:02 -05:00
|
|
|
console.log(selectedFile);
|
2025-01-19 22:22:03 -05:00
|
|
|
|
2025-01-22 08:36:02 -05:00
|
|
|
if (!selectedFile) {
|
2025-01-19 22:22:03 -05:00
|
|
|
console.error('No files selected');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-01-22 08:36:02 -05:00
|
|
|
const file = selectedFile;
|
2025-01-19 22:22:03 -05:00
|
|
|
console.log(file);
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append('file', file);
|
|
|
|
formData.append('adventure', adventure.id);
|
|
|
|
formData.append('name', attachmentName);
|
|
|
|
|
|
|
|
console.log(formData);
|
|
|
|
|
|
|
|
try {
|
|
|
|
const res = await fetch('/adventures?/attachment', {
|
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
const newData = deserialize(await res.text()) as { data: Attachment };
|
|
|
|
adventure.attachments = [...adventure.attachments, newData.data];
|
|
|
|
addToast('success', $t('adventures.attachment_upload_success'));
|
|
|
|
attachmentName = '';
|
|
|
|
} else {
|
|
|
|
addToast('error', $t('adventures.attachment_upload_error'));
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
addToast('error', $t('adventures.attachment_upload_error'));
|
|
|
|
} finally {
|
|
|
|
// Reset the file input for a new upload
|
|
|
|
if (fileInput) {
|
|
|
|
fileInput.value = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-23 14:24:30 -04:00
|
|
|
function clearMap() {
|
|
|
|
console.log('CLEAR');
|
|
|
|
markers = [];
|
|
|
|
}
|
|
|
|
|
2024-08-17 22:40:27 -04:00
|
|
|
let imageSearch: string = adventure.name || '';
|
2024-08-17 15:18:43 -04:00
|
|
|
|
2024-08-17 13:30:00 -04:00
|
|
|
async function removeImage(id: string) {
|
2024-08-17 13:59:49 -04:00
|
|
|
let res = await fetch(`/api/images/${id}/image_delete`, {
|
|
|
|
method: 'POST'
|
2024-08-17 13:30:00 -04:00
|
|
|
});
|
2024-08-17 13:59:49 -04:00
|
|
|
if (res.status === 204) {
|
2024-08-17 13:30:00 -04:00
|
|
|
images = images.filter((image) => image.id !== id);
|
2024-08-17 22:40:27 -04:00
|
|
|
adventure.images = images;
|
2024-08-17 13:59:49 -04:00
|
|
|
console.log(images);
|
2024-10-28 19:59:44 -04:00
|
|
|
addToast('success', $t('adventures.image_removed_success'));
|
2024-08-17 13:30:00 -04:00
|
|
|
} else {
|
2024-10-28 19:59:44 -04:00
|
|
|
addToast('error', $t('adventures.image_removed_error'));
|
2024-08-17 13:30:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
let isDetails: boolean = true;
|
|
|
|
|
|
|
|
function saveAndClose() {
|
2024-08-17 22:40:27 -04:00
|
|
|
dispatch('save', adventure);
|
2024-08-17 11:12:15 -04:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2025-01-03 12:05:02 -05:00
|
|
|
let willBeMarkedVisited: boolean = false;
|
|
|
|
|
|
|
|
$: {
|
|
|
|
willBeMarkedVisited = false; // Reset before evaluating
|
|
|
|
|
|
|
|
const today = new Date(); // Cache today's date to avoid redundant calculations
|
|
|
|
|
|
|
|
for (const visit of adventure.visits) {
|
|
|
|
const startDate = new Date(visit.start_date);
|
|
|
|
const endDate = visit.end_date ? new Date(visit.end_date) : null;
|
|
|
|
|
|
|
|
// If the visit has both a start date and an end date, check if it started by today
|
|
|
|
if (startDate && endDate && startDate <= today) {
|
|
|
|
willBeMarkedVisited = true;
|
|
|
|
break; // Exit the loop since we've determined the result
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the visit has a start date but no end date, check if it started by today
|
|
|
|
if (startDate && !endDate && startDate <= today) {
|
|
|
|
willBeMarkedVisited = true;
|
|
|
|
break; // Exit the loop since we've determined the result
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('WMBV:', willBeMarkedVisited);
|
|
|
|
}
|
|
|
|
|
2024-11-01 20:08:23 -04:00
|
|
|
let previousCoords: { lat: number; lng: number } | null = null;
|
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
$: if (markers.length > 0) {
|
2024-11-01 20:08:23 -04:00
|
|
|
const newLat = Math.round(markers[0].lngLat.lat * 1e6) / 1e6;
|
|
|
|
const newLng = Math.round(markers[0].lngLat.lng * 1e6) / 1e6;
|
|
|
|
|
|
|
|
if (!previousCoords || previousCoords.lat !== newLat || previousCoords.lng !== newLng) {
|
|
|
|
adventure.latitude = newLat;
|
|
|
|
adventure.longitude = newLng;
|
|
|
|
previousCoords = { lat: newLat, lng: newLng };
|
|
|
|
reverseGeocode();
|
2024-08-17 11:12:15 -04:00
|
|
|
}
|
2024-11-01 20:08:23 -04:00
|
|
|
|
2024-08-17 22:40:27 -04:00
|
|
|
if (!adventure.name) {
|
|
|
|
adventure.name = markers[0].name;
|
2024-08-17 11:12:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-02 23:25:58 -05:00
|
|
|
async function makePrimaryImage(image_id: string) {
|
|
|
|
let res = await fetch(`/api/images/${image_id}/toggle_primary`, {
|
|
|
|
method: 'POST'
|
|
|
|
});
|
|
|
|
if (res.ok) {
|
|
|
|
images = images.map((image) => {
|
|
|
|
if (image.id === image_id) {
|
|
|
|
image.is_primary = true;
|
|
|
|
} else {
|
|
|
|
image.is_primary = false;
|
|
|
|
}
|
|
|
|
return image;
|
|
|
|
});
|
|
|
|
adventure.images = images;
|
|
|
|
} else {
|
|
|
|
console.error('Error in makePrimaryImage:', res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-11 21:25:29 -05:00
|
|
|
async function handleMultipleFiles(event: Event) {
|
|
|
|
const files = (event.target as HTMLInputElement).files;
|
|
|
|
if (files) {
|
|
|
|
for (const file of files) {
|
|
|
|
await uploadImage(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function uploadImage(file: File) {
|
|
|
|
let formData = new FormData();
|
|
|
|
formData.append('image', file);
|
|
|
|
formData.append('adventure', adventure.id);
|
|
|
|
|
|
|
|
let res = await fetch(`/adventures?/image`, {
|
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
|
|
|
});
|
|
|
|
if (res.ok) {
|
|
|
|
let newData = deserialize(await res.text()) as { data: { id: string; image: string } };
|
|
|
|
console.log(newData);
|
|
|
|
let newImage = { id: newData.data.id, image: newData.data.image, is_primary: false };
|
|
|
|
console.log(newImage);
|
|
|
|
images = [...images, newImage];
|
|
|
|
adventure.images = images;
|
|
|
|
addToast('success', $t('adventures.image_upload_success'));
|
|
|
|
} else {
|
|
|
|
addToast('error', $t('adventures.image_upload_error'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-17 15:18:43 -04:00
|
|
|
async function fetchImage() {
|
2025-01-01 16:24:44 -05:00
|
|
|
try {
|
|
|
|
let res = await fetch(url);
|
|
|
|
let data = await res.blob();
|
|
|
|
if (!data) {
|
|
|
|
imageError = $t('adventures.no_image_url');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let file = new File([data], 'image.jpg', { type: 'image/jpeg' });
|
|
|
|
let formData = new FormData();
|
|
|
|
formData.append('image', file);
|
|
|
|
formData.append('adventure', adventure.id);
|
|
|
|
|
2025-01-11 21:25:29 -05:00
|
|
|
await uploadImage(file);
|
|
|
|
url = '';
|
|
|
|
} catch (e) {
|
|
|
|
imageError = $t('adventures.image_fetch_failed');
|
2024-08-17 15:18:43 -04:00
|
|
|
}
|
2025-01-01 16:24:44 -05:00
|
|
|
}
|
|
|
|
|
2024-08-17 15:18:43 -04:00
|
|
|
async function fetchWikiImage() {
|
|
|
|
let res = await fetch(`/api/generate/img/?name=${imageSearch}`);
|
|
|
|
let data = await res.json();
|
2024-08-17 16:28:56 -04:00
|
|
|
if (!res.ok) {
|
2024-10-29 10:29:03 -04:00
|
|
|
wikiImageError = $t('adventures.image_fetch_failed');
|
2024-08-17 16:28:56 -04:00
|
|
|
return;
|
|
|
|
}
|
2024-08-17 15:18:43 -04:00
|
|
|
if (data.source) {
|
|
|
|
let imageUrl = data.source;
|
|
|
|
let res = await fetch(imageUrl);
|
|
|
|
let blob = await res.blob();
|
|
|
|
let file = new File([blob], `${imageSearch}.jpg`, { type: 'image/jpeg' });
|
2025-01-18 12:28:14 -05:00
|
|
|
wikiImageError = '';
|
2024-08-17 15:18:43 -04:00
|
|
|
let formData = new FormData();
|
|
|
|
formData.append('image', file);
|
2024-08-17 22:40:27 -04:00
|
|
|
formData.append('adventure', adventure.id);
|
2024-08-17 15:18:43 -04:00
|
|
|
let res2 = await fetch(`/adventures?/image`, {
|
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
|
|
|
});
|
|
|
|
if (res2.ok) {
|
|
|
|
let newData = deserialize(await res2.text()) as { data: { id: string; image: string } };
|
|
|
|
console.log(newData);
|
2025-01-02 23:25:58 -05:00
|
|
|
let newImage = { id: newData.data.id, image: newData.data.image, is_primary: false };
|
2024-08-17 15:18:43 -04:00
|
|
|
console.log(newImage);
|
|
|
|
images = [...images, newImage];
|
2024-08-17 22:40:27 -04:00
|
|
|
adventure.images = images;
|
2024-10-28 19:59:44 -04:00
|
|
|
addToast('success', $t('adventures.image_upload_success'));
|
2024-08-17 15:18:43 -04:00
|
|
|
} else {
|
2024-10-28 19:59:44 -04:00
|
|
|
addToast('error', $t('adventures.image_upload_error'));
|
|
|
|
wikiImageError = $t('adventures.wiki_image_error');
|
2024-08-17 15:18:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-08-17 11:12:15 -04:00
|
|
|
async function geocode(e: Event | null) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
if (!query) {
|
2024-10-29 10:29:03 -04:00
|
|
|
alert($t('adventures.no_location'));
|
2024-08-17 11:12:15 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
let res = await fetch(`https://nominatim.openstreetmap.org/search?q=${query}&format=jsonv2`, {
|
|
|
|
headers: {
|
|
|
|
'User-Agent': `AdventureLog / ${appVersion} `
|
|
|
|
}
|
|
|
|
});
|
|
|
|
console.log(res);
|
|
|
|
let data = (await res.json()) as OpenStreetMapPlace[];
|
|
|
|
places = data;
|
2024-08-17 14:21:55 -04:00
|
|
|
if (data.length === 0) {
|
|
|
|
noPlaces = true;
|
|
|
|
} else {
|
|
|
|
noPlaces = false;
|
|
|
|
}
|
2024-08-17 11:12:15 -04:00
|
|
|
}
|
|
|
|
|
2024-10-01 09:32:02 -04:00
|
|
|
let new_start_date: string = '';
|
|
|
|
let new_end_date: string = '';
|
|
|
|
let new_notes: string = '';
|
|
|
|
function addNewVisit() {
|
2024-10-07 19:25:49 -04:00
|
|
|
if (new_start_date && !new_end_date) {
|
|
|
|
new_end_date = new_start_date;
|
|
|
|
}
|
2024-10-01 09:32:02 -04:00
|
|
|
if (new_start_date > new_end_date) {
|
2024-10-28 19:59:44 -04:00
|
|
|
addToast('error', $t('adventures.start_before_end_error'));
|
2024-10-01 09:32:02 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (new_end_date && !new_start_date) {
|
2024-10-29 10:29:03 -04:00
|
|
|
addToast('error', $t('adventures.no_start_date'));
|
2024-10-01 09:32:02 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
adventure.visits = [
|
|
|
|
...adventure.visits,
|
|
|
|
{
|
|
|
|
start_date: new_start_date,
|
|
|
|
end_date: new_end_date,
|
|
|
|
notes: new_notes,
|
|
|
|
id: ''
|
|
|
|
}
|
|
|
|
];
|
|
|
|
new_start_date = '';
|
|
|
|
new_end_date = '';
|
|
|
|
new_notes = '';
|
|
|
|
}
|
|
|
|
|
2024-10-30 18:40:49 -04:00
|
|
|
async function markVisited() {
|
|
|
|
console.log(reverseGeocodePlace);
|
|
|
|
if (reverseGeocodePlace) {
|
2025-01-09 19:40:23 -05:00
|
|
|
if (!reverseGeocodePlace.region_visited && reverseGeocodePlace.region_id) {
|
|
|
|
let region_res = await fetch(`/api/visitedregion`, {
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify({ region: reverseGeocodePlace.region_id })
|
|
|
|
});
|
|
|
|
if (region_res.ok) {
|
|
|
|
reverseGeocodePlace.region_visited = true;
|
|
|
|
addToast('success', `Visit to ${reverseGeocodePlace.region} marked`);
|
|
|
|
} else {
|
|
|
|
addToast('error', `Failed to mark visit to ${reverseGeocodePlace.region}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!reverseGeocodePlace.city_visited && reverseGeocodePlace.city_id != null) {
|
|
|
|
let city_res = await fetch(`/api/visitedcity`, {
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify({ city: reverseGeocodePlace.city_id })
|
|
|
|
});
|
|
|
|
if (city_res.ok) {
|
|
|
|
reverseGeocodePlace.city_visited = true;
|
|
|
|
addToast('success', `Visit to ${reverseGeocodePlace.city} marked`);
|
|
|
|
} else {
|
|
|
|
addToast('error', `Failed to mark visit to ${reverseGeocodePlace.city}`);
|
|
|
|
}
|
2024-10-30 18:40:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-08 17:15:53 -05:00
|
|
|
async function reverseGeocode(force_update: boolean = false) {
|
2024-08-17 11:12:15 -04:00
|
|
|
let res = await fetch(
|
2024-10-30 15:11:00 -04:00
|
|
|
`/api/reverse-geocode/reverse_geocode/?lat=${adventure.latitude}&lon=${adventure.longitude}`
|
2024-08-17 11:12:15 -04:00
|
|
|
);
|
2024-10-30 15:11:00 -04:00
|
|
|
let data = await res.json();
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.error);
|
|
|
|
reverseGeocodePlace = null;
|
|
|
|
return;
|
2024-08-17 11:12:15 -04:00
|
|
|
}
|
2024-10-30 15:11:00 -04:00
|
|
|
reverseGeocodePlace = data;
|
2024-11-08 09:39:03 -05:00
|
|
|
|
2024-11-12 23:12:08 -05:00
|
|
|
console.log(reverseGeocodePlace);
|
|
|
|
console.log(is_custom_location);
|
|
|
|
|
2024-11-08 17:15:53 -05:00
|
|
|
if (
|
|
|
|
reverseGeocodePlace &&
|
|
|
|
reverseGeocodePlace.display_name &&
|
|
|
|
(!is_custom_location || force_update)
|
|
|
|
) {
|
2024-11-08 09:39:03 -05:00
|
|
|
old_display_name = reverseGeocodePlace.display_name;
|
|
|
|
adventure.location = reverseGeocodePlace.display_name;
|
|
|
|
}
|
2024-08-17 11:12:15 -04:00
|
|
|
console.log(data);
|
|
|
|
}
|
2024-07-16 15:38:07 -04:00
|
|
|
|
|
|
|
let fileInput: HTMLInputElement;
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
let modal: HTMLDialogElement;
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2025-01-01 16:24:44 -05:00
|
|
|
let immichIntegration: boolean = false;
|
|
|
|
|
2024-07-08 11:44:39 -04:00
|
|
|
onMount(async () => {
|
|
|
|
modal = document.getElementById('my_modal_1') as HTMLDialogElement;
|
2024-08-20 12:39:15 -04:00
|
|
|
modal.showModal();
|
|
|
|
console.log('open');
|
2024-11-22 17:03:02 -05:00
|
|
|
let categoryFetch = await fetch('/api/categories/categories');
|
|
|
|
if (categoryFetch.ok) {
|
|
|
|
categories = await categoryFetch.json();
|
|
|
|
} else {
|
|
|
|
addToast('error', $t('adventures.category_fetch_error'));
|
|
|
|
}
|
2025-01-01 16:24:44 -05:00
|
|
|
// Check for Immich Integration
|
|
|
|
let res = await fetch('/api/integrations');
|
|
|
|
if (!res.ok) {
|
|
|
|
addToast('error', $t('immich.integration_fetch_error'));
|
|
|
|
} else {
|
|
|
|
let data = await res.json();
|
|
|
|
if (data.immich) {
|
|
|
|
immichIntegration = true;
|
|
|
|
}
|
|
|
|
}
|
2024-07-08 11:44:39 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
dispatch('close');
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleKeydown(event: KeyboardEvent) {
|
|
|
|
if (event.key === 'Escape') {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-17 22:48:57 -04:00
|
|
|
async function generateDesc() {
|
|
|
|
let res = await fetch(`/api/generate/desc/?name=${adventure.name}`);
|
|
|
|
let data = await res.json();
|
|
|
|
if (data.extract?.length > 0) {
|
|
|
|
adventure.description = data.extract;
|
2024-08-18 09:15:59 -04:00
|
|
|
wikiError = '';
|
2024-08-17 22:48:57 -04:00
|
|
|
} else {
|
2024-10-29 10:29:03 -04:00
|
|
|
wikiError = $t('adventures.no_description_found');
|
2024-08-17 22:48:57 -04:00
|
|
|
}
|
|
|
|
}
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2024-08-23 18:24:41 -04:00
|
|
|
async function addMarker(e: CustomEvent<any>) {
|
|
|
|
markers = [];
|
|
|
|
markers = [
|
|
|
|
...markers,
|
|
|
|
{
|
|
|
|
lngLat: e.detail.lngLat,
|
|
|
|
name: '',
|
|
|
|
location: '',
|
|
|
|
activity_type: ''
|
|
|
|
}
|
|
|
|
];
|
2024-08-17 11:12:15 -04:00
|
|
|
console.log(markers);
|
|
|
|
}
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
function imageSubmit() {
|
|
|
|
return async ({ result }: any) => {
|
|
|
|
if (result.type === 'success') {
|
|
|
|
if (result.data.id && result.data.image) {
|
2024-08-17 22:40:27 -04:00
|
|
|
adventure.images = [...adventure.images, result.data];
|
2024-08-17 11:12:15 -04:00
|
|
|
images = [...images, result.data];
|
2024-10-29 10:29:03 -04:00
|
|
|
addToast('success', $t('adventures.image_upload_success'));
|
2024-07-08 11:44:39 -04:00
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
fileInput.value = '';
|
2024-08-17 22:40:27 -04:00
|
|
|
console.log(adventure);
|
2024-08-17 11:12:15 -04:00
|
|
|
} else {
|
2024-10-29 10:29:03 -04:00
|
|
|
addToast('error', result.data.error || $t('adventures.image_upload_error'));
|
2024-07-08 11:44:39 -04:00
|
|
|
}
|
|
|
|
}
|
2024-08-17 11:12:15 -04:00
|
|
|
};
|
2024-07-08 11:44:39 -04:00
|
|
|
}
|
2024-07-16 15:38:07 -04:00
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
async function handleSubmit(event: Event) {
|
|
|
|
event.preventDefault();
|
2024-08-17 22:40:27 -04:00
|
|
|
console.log(adventure);
|
|
|
|
if (adventure.id === '') {
|
2024-11-26 15:10:17 -05:00
|
|
|
console.log(categories);
|
2024-11-26 20:06:52 -05:00
|
|
|
if (adventure.category?.display_name == '') {
|
|
|
|
if (categories.some((category) => category.name === 'general')) {
|
|
|
|
adventure.category = categories.find(
|
|
|
|
(category) => category.name === 'general'
|
|
|
|
) as Category;
|
|
|
|
} else {
|
|
|
|
adventure.category = {
|
|
|
|
id: '',
|
|
|
|
name: 'general',
|
|
|
|
display_name: 'General',
|
|
|
|
icon: '🌍',
|
|
|
|
user_id: ''
|
|
|
|
};
|
|
|
|
}
|
2024-11-26 15:10:17 -05:00
|
|
|
}
|
2024-08-17 22:40:27 -04:00
|
|
|
let res = await fetch('/api/adventures', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(adventure)
|
|
|
|
});
|
|
|
|
let data = await res.json();
|
|
|
|
if (data.id) {
|
|
|
|
adventure = data as Adventure;
|
|
|
|
isDetails = false;
|
2024-09-17 10:34:31 -04:00
|
|
|
warningMessage = '';
|
2024-10-29 10:29:03 -04:00
|
|
|
addToast('success', $t('adventures.adventure_created'));
|
2024-08-17 22:40:27 -04:00
|
|
|
} else {
|
2024-11-23 13:42:41 -05:00
|
|
|
warningMessage = findFirstValue(data) as string;
|
|
|
|
console.error(data);
|
2024-10-29 10:29:03 -04:00
|
|
|
addToast('error', $t('adventures.adventure_create_error'));
|
2024-08-17 22:40:27 -04:00
|
|
|
}
|
2024-08-17 11:12:15 -04:00
|
|
|
} else {
|
2024-08-17 22:40:27 -04:00
|
|
|
let res = await fetch(`/api/adventures/${adventure.id}`, {
|
|
|
|
method: 'PATCH',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(adventure)
|
|
|
|
});
|
|
|
|
let data = await res.json();
|
|
|
|
if (data.id) {
|
|
|
|
adventure = data as Adventure;
|
|
|
|
isDetails = false;
|
2024-09-17 10:34:31 -04:00
|
|
|
warningMessage = '';
|
2024-10-29 10:29:03 -04:00
|
|
|
addToast('success', $t('adventures.adventure_updated'));
|
2024-08-17 22:40:27 -04:00
|
|
|
} else {
|
2024-09-17 10:34:31 -04:00
|
|
|
warningMessage = Object.values(data)[0] as string;
|
2024-10-29 10:29:03 -04:00
|
|
|
addToast('error', $t('adventures.adventure_update_error'));
|
2024-08-17 22:40:27 -04:00
|
|
|
}
|
2024-07-16 15:38:07 -04:00
|
|
|
}
|
2025-01-09 19:40:23 -05:00
|
|
|
if (
|
2025-01-12 20:28:27 -05:00
|
|
|
adventure.is_visited &&
|
|
|
|
(!reverseGeocodePlace?.region_visited || !reverseGeocodePlace?.city_visited)
|
2025-01-09 19:40:23 -05:00
|
|
|
) {
|
2025-01-03 12:05:02 -05:00
|
|
|
markVisited();
|
|
|
|
}
|
2025-01-03 16:42:27 -05:00
|
|
|
imageSearch = adventure.name;
|
2024-07-08 11:44:39 -04:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2024-08-17 11:12:15 -04:00
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
2024-07-08 11:44:39 -04:00
|
|
|
<dialog id="my_modal_1" class="modal">
|
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
2024-08-17 11:12:15 -04:00
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
2024-09-30 18:03:10 -04:00
|
|
|
<div class="modal-box w-11/12 max-w-3xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
|
|
|
|
<h3 class="font-bold text-2xl">
|
2024-10-29 10:29:03 -04:00
|
|
|
{adventureToEdit ? $t('adventures.edit_adventure') : $t('adventures.new_adventure')}
|
2024-08-20 12:39:15 -04:00
|
|
|
</h3>
|
2024-08-17 22:40:27 -04:00
|
|
|
{#if adventure.id === '' || isDetails}
|
2024-08-17 11:12:15 -04:00
|
|
|
<div class="modal-action items-center">
|
|
|
|
<form method="post" style="width: 100%;" on:submit={handleSubmit}>
|
|
|
|
<!-- Grid layout for form fields -->
|
2024-08-17 14:13:23 -04:00
|
|
|
<!-- <div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-3"> -->
|
2024-09-30 18:03:10 -04:00
|
|
|
<div class="collapse collapse-plus bg-base-200 mb-4">
|
|
|
|
<input type="checkbox" checked />
|
2024-10-29 10:29:03 -04:00
|
|
|
<div class="collapse-title text-xl font-medium">
|
|
|
|
{$t('adventures.basic_information')}
|
|
|
|
</div>
|
2024-09-30 18:03:10 -04:00
|
|
|
<div class="collapse-content">
|
|
|
|
<div>
|
2024-11-23 13:42:41 -05:00
|
|
|
<label for="name">{$t('adventures.name')}<span class="text-red-500">*</span></label
|
|
|
|
><br />
|
2024-08-17 22:48:57 -04:00
|
|
|
<input
|
2024-09-30 18:03:10 -04:00
|
|
|
type="text"
|
|
|
|
id="name"
|
|
|
|
name="name"
|
|
|
|
bind:value={adventure.name}
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
required
|
2024-08-17 22:48:57 -04:00
|
|
|
/>
|
2024-09-30 18:03:10 -04:00
|
|
|
</div>
|
|
|
|
<div>
|
2024-11-23 13:42:41 -05:00
|
|
|
<label for="link"
|
|
|
|
>{$t('adventures.category')}<span class="text-red-500">*</span></label
|
|
|
|
><br />
|
2024-11-22 17:03:02 -05:00
|
|
|
|
2024-11-23 13:42:41 -05:00
|
|
|
<CategoryDropdown bind:categories bind:selected_category={adventure.category} />
|
2024-09-30 18:03:10 -04:00
|
|
|
</div>
|
|
|
|
<div>
|
2024-10-29 10:29:03 -04:00
|
|
|
<label for="rating">{$t('adventures.rating')}</label><br />
|
2024-08-17 22:48:57 -04:00
|
|
|
<input
|
2024-09-30 18:03:10 -04:00
|
|
|
type="number"
|
|
|
|
min="0"
|
|
|
|
max="5"
|
|
|
|
hidden
|
|
|
|
bind:value={adventure.rating}
|
|
|
|
id="rating"
|
|
|
|
name="rating"
|
|
|
|
class="input input-bordered w-full max-w-xs mt-1"
|
2024-08-17 22:48:57 -04:00
|
|
|
/>
|
2024-09-30 18:03:10 -04:00
|
|
|
<div class="rating -ml-3 mt-1">
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
name="rating-2"
|
|
|
|
class="rating-hidden"
|
|
|
|
checked={Number.isNaN(adventure.rating)}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
name="rating-2"
|
|
|
|
class="mask mask-star-2 bg-orange-400"
|
|
|
|
on:click={() => (adventure.rating = 1)}
|
|
|
|
checked={adventure.rating === 1}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
name="rating-2"
|
|
|
|
class="mask mask-star-2 bg-orange-400"
|
|
|
|
on:click={() => (adventure.rating = 2)}
|
|
|
|
checked={adventure.rating === 2}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
name="rating-2"
|
|
|
|
class="mask mask-star-2 bg-orange-400"
|
|
|
|
on:click={() => (adventure.rating = 3)}
|
|
|
|
checked={adventure.rating === 3}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
name="rating-2"
|
|
|
|
class="mask mask-star-2 bg-orange-400"
|
|
|
|
on:click={() => (adventure.rating = 4)}
|
|
|
|
checked={adventure.rating === 4}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="radio"
|
|
|
|
name="rating-2"
|
|
|
|
class="mask mask-star-2 bg-orange-400"
|
|
|
|
on:click={() => (adventure.rating = 5)}
|
|
|
|
checked={adventure.rating === 5}
|
|
|
|
/>
|
|
|
|
{#if adventure.rating}
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn btn-sm btn-error ml-2"
|
|
|
|
on:click={() => (adventure.rating = NaN)}
|
|
|
|
>
|
2024-10-29 10:29:03 -04:00
|
|
|
{$t('adventures.remove')}
|
2024-09-30 18:03:10 -04:00
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>
|
2024-10-29 10:29:03 -04:00
|
|
|
<label for="link">{$t('adventures.link')}</label><br />
|
2024-09-30 18:03:10 -04:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="link"
|
|
|
|
name="link"
|
|
|
|
bind:value={adventure.link}
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
2024-10-29 10:29:03 -04:00
|
|
|
<label for="description">{$t('adventures.description')}</label><br />
|
2024-12-17 18:58:38 -05:00
|
|
|
<MarkdownEditor bind:text={adventure.description} />
|
2024-09-30 18:03:10 -04:00
|
|
|
<div class="mt-2">
|
2024-10-29 10:29:03 -04:00
|
|
|
<div class="tooltip tooltip-right" data-tip={$t('adventures.wiki_desc')}>
|
2024-12-17 18:58:38 -05:00
|
|
|
<button type="button" class="btn btn-neutral mt-2" on:click={generateDesc}
|
2024-10-29 10:29:03 -04:00
|
|
|
>{$t('adventures.generate_desc')}</button
|
2024-09-30 18:16:08 -04:00
|
|
|
>
|
|
|
|
</div>
|
2024-09-30 18:03:10 -04:00
|
|
|
<p class="text-red-500">{wikiError}</p>
|
|
|
|
</div>
|
2024-08-17 22:48:57 -04:00
|
|
|
</div>
|
2024-10-01 09:32:02 -04:00
|
|
|
{#if !collection?.id}
|
2024-09-09 14:29:50 -04:00
|
|
|
<div>
|
2024-09-30 18:03:10 -04:00
|
|
|
<div class="form-control flex items-start mt-1">
|
|
|
|
<label class="label cursor-pointer flex items-start space-x-2">
|
2024-10-29 10:29:03 -04:00
|
|
|
<span class="label-text">{$t('adventures.public_adventure')}</span>
|
2024-09-09 14:29:50 -04:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
class="toggle toggle-primary"
|
|
|
|
id="is_public"
|
|
|
|
name="is_public"
|
|
|
|
bind:checked={adventure.is_public}
|
|
|
|
/>
|
2024-09-30 18:03:10 -04:00
|
|
|
</label>
|
2024-08-17 22:48:57 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-09 14:29:50 -04:00
|
|
|
{/if}
|
2024-08-17 22:48:57 -04:00
|
|
|
</div>
|
2024-09-30 18:03:10 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="collapse collapse-plus bg-base-200 mb-4">
|
|
|
|
<input type="checkbox" />
|
2024-10-29 10:29:03 -04:00
|
|
|
<div class="collapse-title text-xl font-medium">
|
|
|
|
{$t('adventures.location_information')}
|
|
|
|
</div>
|
2024-09-30 18:03:10 -04:00
|
|
|
<div class="collapse-content">
|
|
|
|
<!-- <div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"> -->
|
|
|
|
<div>
|
2024-10-29 10:29:03 -04:00
|
|
|
<label for="latitude">{$t('adventures.location')}</label><br />
|
2024-11-07 19:48:44 -05:00
|
|
|
<div class="flex items-center">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="location"
|
|
|
|
name="location"
|
|
|
|
bind:value={adventure.location}
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
/>
|
2024-11-08 09:39:03 -05:00
|
|
|
{#if is_custom_location}
|
2024-11-07 19:48:44 -05:00
|
|
|
<button
|
|
|
|
class="btn btn-primary ml-2"
|
|
|
|
type="button"
|
|
|
|
on:click={() => (adventure.location = reverseGeocodePlace?.display_name)}
|
|
|
|
>{$t('adventures.set_to_pin')}</button
|
|
|
|
>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2024-08-17 14:38:24 -04:00
|
|
|
</div>
|
2024-11-07 19:48:44 -05:00
|
|
|
|
2024-09-30 18:03:10 -04:00
|
|
|
<div>
|
|
|
|
<form on:submit={geocode} class="mt-2">
|
|
|
|
<input
|
|
|
|
type="text"
|
2024-10-29 10:29:03 -04:00
|
|
|
placeholder={$t('adventures.search_for_location')}
|
2024-09-30 18:03:10 -04:00
|
|
|
class="input input-bordered w-full max-w-xs mb-2"
|
|
|
|
id="search"
|
|
|
|
name="search"
|
|
|
|
bind:value={query}
|
|
|
|
/>
|
2024-10-29 10:29:03 -04:00
|
|
|
<button class="btn btn-neutral -mt-1" type="submit">{$t('navbar.search')}</button>
|
2024-09-30 18:03:10 -04:00
|
|
|
<button class="btn btn-neutral -mt-1" type="button" on:click={clearMap}
|
2024-10-29 10:29:03 -04:00
|
|
|
>{$t('adventures.clear_map')}</button
|
2024-09-30 18:03:10 -04:00
|
|
|
>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{#if places.length > 0}
|
|
|
|
<div class="mt-4 max-w-full">
|
2024-10-29 10:29:03 -04:00
|
|
|
<h3 class="font-bold text-lg mb-4">{$t('adventures.search_results')}</h3>
|
2024-09-30 18:03:10 -04:00
|
|
|
|
|
|
|
<div class="flex flex-wrap">
|
|
|
|
{#each places as place}
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn btn-neutral mb-2 mr-2 max-w-full break-words whitespace-normal text-left"
|
|
|
|
on:click={() => {
|
|
|
|
markers = [
|
|
|
|
{
|
|
|
|
lngLat: { lng: Number(place.lon), lat: Number(place.lat) },
|
|
|
|
location: place.display_name,
|
|
|
|
name: place.name,
|
|
|
|
activity_type: place.type
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{place.display_name}
|
|
|
|
</button>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{:else if noPlaces}
|
2024-10-29 10:29:03 -04:00
|
|
|
<p class="text-error text-lg">{$t('adventures.no_results')}</p>
|
2024-09-30 18:03:10 -04:00
|
|
|
{/if}
|
|
|
|
<!-- </div> -->
|
|
|
|
<div>
|
|
|
|
<MapLibre
|
2024-10-17 15:14:15 -04:00
|
|
|
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
|
2024-12-19 21:44:31 -05:00
|
|
|
class="relative aspect-[9/16] max-h-[70vh] w-full sm:aspect-video sm:max-h-full rounded-lg"
|
2024-09-30 18:03:10 -04:00
|
|
|
standardControls
|
|
|
|
>
|
|
|
|
<!-- MapEvents gives you access to map events even from other components inside the map,
|
2024-08-17 22:48:57 -04:00
|
|
|
where you might not have access to the top-level `MapLibre` component. In this case
|
|
|
|
it would also work to just use on:click on the MapLibre component itself. -->
|
2024-09-30 18:03:10 -04:00
|
|
|
<MapEvents on:click={addMarker} />
|
2024-08-17 22:48:57 -04:00
|
|
|
|
2024-09-30 18:03:10 -04:00
|
|
|
{#each markers as marker}
|
|
|
|
<DefaultMarker lngLat={marker.lngLat} />
|
|
|
|
{/each}
|
|
|
|
</MapLibre>
|
2024-10-30 15:11:00 -04:00
|
|
|
{#if reverseGeocodePlace}
|
|
|
|
<div class="mt-2">
|
2024-10-31 09:51:04 -04:00
|
|
|
<p>
|
2025-01-09 19:40:23 -05:00
|
|
|
{reverseGeocodePlace.city
|
|
|
|
? reverseGeocodePlace.city + ', '
|
|
|
|
: ''}{reverseGeocodePlace.region},
|
|
|
|
{reverseGeocodePlace.country}
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
{reverseGeocodePlace.region}:
|
|
|
|
{reverseGeocodePlace.region_visited
|
2024-10-31 09:51:04 -04:00
|
|
|
? $t('adventures.visited')
|
|
|
|
: $t('adventures.not_visited')}
|
|
|
|
</p>
|
2025-01-09 19:40:23 -05:00
|
|
|
{#if reverseGeocodePlace.city}
|
|
|
|
<p>
|
|
|
|
{reverseGeocodePlace.city}:
|
|
|
|
{reverseGeocodePlace.city_visited
|
|
|
|
? $t('adventures.visited')
|
|
|
|
: $t('adventures.not_visited')}
|
|
|
|
</p>
|
|
|
|
{/if}
|
2024-10-30 15:11:00 -04:00
|
|
|
</div>
|
2025-01-09 19:40:23 -05:00
|
|
|
{#if !reverseGeocodePlace.region_visited || (!reverseGeocodePlace.city_visited && !willBeMarkedVisited)}
|
2025-01-03 12:05:02 -05:00
|
|
|
<button type="button" class="btn btn-neutral" on:click={markVisited}>
|
|
|
|
{$t('adventures.mark_visited')}
|
|
|
|
</button>
|
|
|
|
{/if}
|
2025-01-13 10:51:33 -05:00
|
|
|
{#if (willBeMarkedVisited && !reverseGeocodePlace.region_visited && reverseGeocodePlace.region_id) || (!reverseGeocodePlace.city_visited && willBeMarkedVisited && reverseGeocodePlace.city_id)}
|
2024-10-30 18:40:49 -04:00
|
|
|
<div role="alert" class="alert alert-info mt-2">
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
fill="none"
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
class="h-6 w-6 shrink-0 stroke-current"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
stroke-linecap="round"
|
|
|
|
stroke-linejoin="round"
|
|
|
|
stroke-width="2"
|
|
|
|
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
|
|
></path>
|
|
|
|
</svg>
|
|
|
|
<span
|
2025-01-09 19:40:23 -05:00
|
|
|
>{reverseGeocodePlace.city
|
|
|
|
? reverseGeocodePlace.city + ', '
|
|
|
|
: ''}{reverseGeocodePlace.region},
|
2025-01-03 12:12:09 -05:00
|
|
|
{reverseGeocodePlace.country}
|
|
|
|
{$t('adventures.will_be_marked')}</span
|
2024-10-30 18:40:49 -04:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2024-10-30 15:11:00 -04:00
|
|
|
{/if}
|
2024-09-30 18:03:10 -04:00
|
|
|
</div>
|
2024-08-17 14:38:24 -04:00
|
|
|
</div>
|
2024-09-30 18:03:10 -04:00
|
|
|
</div>
|
|
|
|
|
2024-10-01 09:32:02 -04:00
|
|
|
<div class="collapse collapse-plus bg-base-200 mb-4 overflow-visible">
|
|
|
|
<input type="checkbox" />
|
|
|
|
<div class="collapse-title text-xl font-medium">
|
2024-11-04 19:25:07 -05:00
|
|
|
{$t('adventures.tags')} ({adventure.activity_types?.length || 0})
|
2024-10-01 09:32:02 -04:00
|
|
|
</div>
|
|
|
|
<div class="collapse-content">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="activity_types"
|
|
|
|
name="activity_types"
|
|
|
|
hidden
|
|
|
|
bind:value={adventure.activity_types}
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
/>
|
|
|
|
<ActivityComplete bind:activities={adventure.activity_types} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="collapse collapse-plus bg-base-200 mb-4">
|
|
|
|
<input type="checkbox" />
|
|
|
|
<div class="collapse-title text-xl font-medium">
|
2024-10-29 10:29:03 -04:00
|
|
|
{$t('adventures.visits')} ({adventure.visits.length})
|
2024-10-01 09:32:02 -04:00
|
|
|
</div>
|
|
|
|
<div class="collapse-content">
|
|
|
|
<label class="label cursor-pointer flex items-start space-x-2">
|
2024-10-04 21:33:02 -04:00
|
|
|
{#if adventure.collection && collection && collection.start_date && collection.end_date}
|
2024-10-29 10:29:03 -04:00
|
|
|
<span class="label-text">{$t('adventures.date_constrain')}</span>
|
2024-10-04 21:33:02 -04:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
class="toggle toggle-primary"
|
|
|
|
id="constrain_dates"
|
|
|
|
name="constrain_dates"
|
|
|
|
on:change={() => (constrainDates = !constrainDates)}
|
|
|
|
/>
|
|
|
|
{/if}
|
2024-10-01 09:32:02 -04:00
|
|
|
</label>
|
|
|
|
<div class="flex gap-2 mb-1">
|
2024-10-04 21:33:02 -04:00
|
|
|
{#if !constrainDates}
|
|
|
|
<input
|
|
|
|
type="date"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
placeholder="Start Date"
|
|
|
|
bind:value={new_start_date}
|
|
|
|
on:keydown={(e) => {
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
addNewVisit();
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="date"
|
|
|
|
class="input input-bordered w-full"
|
2024-10-29 10:29:03 -04:00
|
|
|
placeholder={$t('adventures.end_date')}
|
2024-10-04 21:33:02 -04:00
|
|
|
bind:value={new_end_date}
|
|
|
|
on:keydown={(e) => {
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
addNewVisit();
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{:else}
|
|
|
|
<input
|
|
|
|
type="date"
|
|
|
|
class="input input-bordered w-full"
|
2024-10-29 10:29:03 -04:00
|
|
|
placeholder={$t('adventures.start_date')}
|
2024-10-04 21:33:02 -04:00
|
|
|
min={collection?.start_date}
|
|
|
|
max={collection?.end_date}
|
|
|
|
bind:value={new_start_date}
|
|
|
|
on:keydown={(e) => {
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
addNewVisit();
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
type="date"
|
|
|
|
class="input input-bordered w-full"
|
2024-10-29 10:29:03 -04:00
|
|
|
placeholder={$t('adventures.end_date')}
|
2024-10-04 21:33:02 -04:00
|
|
|
bind:value={new_end_date}
|
|
|
|
min={collection?.start_date}
|
|
|
|
max={collection?.end_date}
|
|
|
|
on:keydown={(e) => {
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
addNewVisit();
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{/if}
|
2024-10-01 09:32:02 -04:00
|
|
|
</div>
|
|
|
|
<div class="flex gap-2 mb-1">
|
|
|
|
<!-- textarea for notes -->
|
|
|
|
<textarea
|
|
|
|
class="textarea textarea-bordered w-full"
|
2024-10-29 10:29:03 -04:00
|
|
|
placeholder={$t('adventures.add_notes')}
|
2024-10-01 09:32:02 -04:00
|
|
|
bind:value={new_notes}
|
|
|
|
on:keydown={(e) => {
|
|
|
|
if (e.key === 'Enter') {
|
|
|
|
e.preventDefault();
|
|
|
|
addNewVisit();
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
></textarea>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex gap-2">
|
2024-10-29 10:29:03 -04:00
|
|
|
<button type="button" class="btn btn-neutral" on:click={addNewVisit}
|
|
|
|
>{$t('adventures.add')}</button
|
|
|
|
>
|
2024-10-01 09:32:02 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{#if adventure.visits.length > 0}
|
2024-10-29 10:29:03 -04:00
|
|
|
<h2 class=" font-bold text-xl mt-2">{$t('adventures.my_visits')}</h2>
|
2024-10-01 09:32:02 -04:00
|
|
|
{#each adventure.visits as visit}
|
2024-10-04 21:33:02 -04:00
|
|
|
<div class="flex flex-col gap-2">
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<p>
|
|
|
|
{new Date(visit.start_date).toLocaleDateString(undefined, {
|
|
|
|
timeZone: 'UTC'
|
|
|
|
})}
|
|
|
|
</p>
|
2024-10-07 19:25:49 -04:00
|
|
|
{#if visit.end_date && visit.end_date !== visit.start_date}
|
2024-10-04 21:56:43 -04:00
|
|
|
<p>
|
|
|
|
{new Date(visit.end_date).toLocaleDateString(undefined, {
|
|
|
|
timeZone: 'UTC'
|
|
|
|
})}
|
|
|
|
</p>
|
|
|
|
{/if}
|
2024-10-04 21:33:02 -04:00
|
|
|
|
|
|
|
<div>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn btn-sm btn-error"
|
|
|
|
on:click={() => {
|
|
|
|
adventure.visits = adventure.visits.filter((v) => v !== visit);
|
|
|
|
}}
|
|
|
|
>
|
2024-10-29 10:29:03 -04:00
|
|
|
{$t('adventures.remove')}
|
2024-10-04 21:33:02 -04:00
|
|
|
</button>
|
|
|
|
</div>
|
2024-10-01 09:32:02 -04:00
|
|
|
</div>
|
2024-10-04 21:33:02 -04:00
|
|
|
<p class="whitespace-pre-wrap -mt-2 mb-2">{visit.notes}</p>
|
2024-10-01 09:32:02 -04:00
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-08-17 14:13:23 -04:00
|
|
|
|
2024-09-30 18:03:10 -04:00
|
|
|
<div>
|
2024-08-17 22:48:57 -04:00
|
|
|
<div class="mt-4">
|
2024-09-17 10:34:31 -04:00
|
|
|
{#if warningMessage != ''}
|
|
|
|
<div role="alert" class="alert alert-warning mb-2">
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
class="h-6 w-6 shrink-0 stroke-current"
|
|
|
|
fill="none"
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
stroke-linecap="round"
|
|
|
|
stroke-linejoin="round"
|
|
|
|
stroke-width="2"
|
|
|
|
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
|
|
/>
|
|
|
|
</svg>
|
2024-10-29 10:29:03 -04:00
|
|
|
<span>{$t('adventures.warning')}: {warningMessage}</span>
|
2024-09-17 10:34:31 -04:00
|
|
|
</div>
|
|
|
|
{/if}
|
2024-10-29 10:29:03 -04:00
|
|
|
<button type="submit" class="btn btn-primary">{$t('adventures.save_next')}</button>
|
|
|
|
<button type="button" class="btn" on:click={close}>{$t('about.close')}</button>
|
2024-08-17 22:48:57 -04:00
|
|
|
</div>
|
2024-08-17 11:12:15 -04:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{:else}
|
2025-01-22 08:36:02 -05:00
|
|
|
<div class="modal-action items-center">
|
|
|
|
<div class="collapse collapse-plus bg-base-200 mb-4">
|
|
|
|
<input type="checkbox" />
|
|
|
|
<div class="collapse-title text-xl font-medium">
|
|
|
|
{$t('adventures.attachments')} ({adventure.attachments?.length || 0})
|
|
|
|
</div>
|
|
|
|
<div class="collapse-content">
|
|
|
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
|
|
{#each adventure.attachments as attachment}
|
|
|
|
<AttachmentCard
|
|
|
|
{attachment}
|
|
|
|
on:delete={deleteAttachment}
|
|
|
|
allowEdit
|
|
|
|
on:edit={(e) => (attachmentToEdit = e.detail)}
|
|
|
|
/>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
<div class="flex gap-2 m-4">
|
|
|
|
<input
|
|
|
|
type="file"
|
|
|
|
id="fileInput"
|
|
|
|
class="file-input file-input-bordered w-full max-w-xs"
|
|
|
|
accept="image/*,video/*,audio/*,application/pdf,.gpx"
|
|
|
|
on:change={handleFileChange}
|
|
|
|
/>
|
2025-01-01 11:00:11 -05:00
|
|
|
|
2025-01-22 08:36:02 -05:00
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
placeholder={$t('adventures.attachment_name')}
|
|
|
|
bind:value={attachmentName}
|
|
|
|
/>
|
|
|
|
<button class="btn btn-neutral" on:click={uploadAttachment}>
|
|
|
|
{$t('adventures.upload')}
|
|
|
|
</button>
|
|
|
|
</div>
|
2025-01-01 11:00:11 -05:00
|
|
|
|
2025-01-22 08:36:02 -05:00
|
|
|
{#if attachmentToEdit}
|
|
|
|
<form
|
|
|
|
on:submit={(e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
editAttachment();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div class="flex gap-2 m-4">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
placeholder={$t('adventures.attachment_name')}
|
|
|
|
bind:value={attachmentToEdit.name}
|
|
|
|
/>
|
|
|
|
<button type="submit" class="btn btn-neutral">{$t('transportation.edit')}</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2024-08-17 15:18:43 -04:00
|
|
|
</div>
|
2025-01-01 11:00:11 -05:00
|
|
|
</div>
|
2025-01-22 08:36:02 -05:00
|
|
|
<div class="collapse collapse-plus bg-base-200 mb-4">
|
|
|
|
<input type="checkbox" checked />
|
|
|
|
<div class="collapse-title text-xl font-medium">
|
|
|
|
{$t('adventures.images')} ({adventure.images?.length || 0})
|
|
|
|
</div>
|
|
|
|
<div class="collapse-content">
|
|
|
|
<label for="image" class="block font-medium mb-2">
|
|
|
|
{$t('adventures.image')}
|
|
|
|
</label>
|
|
|
|
<form class="flex flex-col items-start gap-2">
|
|
|
|
<input
|
|
|
|
type="file"
|
|
|
|
name="image"
|
|
|
|
class="file-input file-input-bordered w-full max-w-sm"
|
|
|
|
bind:this={fileInput}
|
|
|
|
accept="image/*"
|
|
|
|
id="image"
|
|
|
|
multiple
|
|
|
|
on:change={handleMultipleFiles}
|
|
|
|
/>
|
|
|
|
<input type="hidden" name="adventure" value={adventure.id} id="adventure" />
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<div class="mb-4">
|
|
|
|
<label for="url" class="block font-medium mb-2">
|
|
|
|
{$t('adventures.url')}
|
|
|
|
</label>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="url"
|
|
|
|
name="url"
|
|
|
|
bind:value={url}
|
|
|
|
class="input input-bordered flex-1"
|
|
|
|
placeholder="Enter image URL"
|
|
|
|
/>
|
|
|
|
<button class="btn btn-neutral" type="button" on:click={fetchImage}>
|
|
|
|
{$t('adventures.fetch_image')}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-01-01 11:00:11 -05:00
|
|
|
|
2025-01-22 08:36:02 -05:00
|
|
|
<div class="mb-4">
|
|
|
|
<label for="name" class="block font-medium mb-2">
|
|
|
|
{$t('adventures.wikipedia')}
|
|
|
|
</label>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="name"
|
|
|
|
name="name"
|
|
|
|
bind:value={imageSearch}
|
|
|
|
class="input input-bordered flex-1"
|
|
|
|
placeholder="Search Wikipedia for images"
|
|
|
|
/>
|
|
|
|
<button class="btn btn-neutral" type="button" on:click={fetchWikiImage}>
|
|
|
|
{$t('adventures.fetch_image')}
|
2024-08-17 16:28:56 -04:00
|
|
|
</button>
|
2025-01-22 08:36:02 -05:00
|
|
|
</div>
|
|
|
|
{#if wikiImageError}
|
|
|
|
<p class="text-red-500">{$t('adventures.wiki_image_error')}</p>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2025-01-02 23:25:58 -05:00
|
|
|
|
2025-01-22 08:36:02 -05:00
|
|
|
{#if immichIntegration}
|
|
|
|
<ImmichSelect
|
2025-02-03 19:56:25 -05:00
|
|
|
{adventure}
|
2025-01-22 08:36:02 -05:00
|
|
|
on:fetchImage={(e) => {
|
|
|
|
url = e.detail;
|
|
|
|
fetchImage();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<div class="divider"></div>
|
|
|
|
|
|
|
|
{#if images.length > 0}
|
|
|
|
<h1 class="font-semibold text-xl mb-4">{$t('adventures.my_images')}</h1>
|
|
|
|
<div class="flex flex-wrap gap-4">
|
|
|
|
{#each images as image}
|
|
|
|
<div class="relative h-32 w-32">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="absolute top-1 right-1 btn btn-error btn-xs z-10"
|
|
|
|
on:click={() => removeImage(image.id)}
|
|
|
|
>
|
|
|
|
✕
|
|
|
|
</button>
|
|
|
|
{#if !image.is_primary}
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="absolute top-1 left-1 btn btn-success btn-xs z-10"
|
|
|
|
on:click={() => makePrimaryImage(image.id)}
|
|
|
|
>
|
|
|
|
<Star class="h-4 w-4" />
|
|
|
|
</button>
|
|
|
|
{:else}
|
|
|
|
<!-- crown icon -->
|
|
|
|
|
|
|
|
<div class="absolute top-1 left-1 bg-warning text-white rounded-full p-1 z-10">
|
|
|
|
<Crown class="h-4 w-4" />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
<img
|
|
|
|
src={image.image}
|
|
|
|
alt={image.id}
|
|
|
|
class="w-full h-full object-cover rounded-md shadow-md"
|
|
|
|
/>
|
2025-01-02 23:25:58 -05:00
|
|
|
</div>
|
2025-01-22 08:36:02 -05:00
|
|
|
{/each}
|
2024-08-17 16:28:56 -04:00
|
|
|
</div>
|
2025-01-22 08:36:02 -05:00
|
|
|
{:else}
|
|
|
|
<h1 class="font-semibold text-xl text-gray-500">{$t('adventures.no_images')}</h1>
|
|
|
|
{/if}
|
2024-08-15 21:29:36 -04:00
|
|
|
</div>
|
2025-01-22 08:36:02 -05:00
|
|
|
</div>
|
|
|
|
<div class="mt-4">
|
2025-01-01 11:00:11 -05:00
|
|
|
<button type="button" class="btn btn-primary w-full max-w-sm" on:click={saveAndClose}>
|
|
|
|
{$t('about.close')}
|
|
|
|
</button>
|
2024-08-17 11:12:15 -04:00
|
|
|
</div>
|
|
|
|
{/if}
|
2025-01-01 11:00:11 -05:00
|
|
|
|
2024-08-18 09:15:59 -04:00
|
|
|
{#if adventure.is_public && adventure.id}
|
|
|
|
<div class="bg-neutral p-4 mt-2 rounded-md shadow-sm">
|
2024-10-29 10:29:03 -04:00
|
|
|
<p class=" font-semibold">{$t('adventures.share_adventure')}</p>
|
2024-08-18 09:15:59 -04:00
|
|
|
<div class="flex items-center justify-between">
|
|
|
|
<p class="text-card-foreground font-mono">
|
|
|
|
{window.location.origin}/adventures/{adventure.id}
|
|
|
|
</p>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
on:click={() => {
|
|
|
|
navigator.clipboard.writeText(`${window.location.origin}/adventures/${adventure.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"
|
|
|
|
>
|
2024-10-29 10:29:03 -04:00
|
|
|
{$t('adventures.copy_link')}
|
2024-08-18 09:15:59 -04:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2024-07-08 11:44:39 -04:00
|
|
|
</div>
|
|
|
|
</dialog>
|