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

Merge pull request #145 from seanmorley15/development

Development
This commit is contained in:
Sean Morley 2024-07-27 09:30:37 -04:00 committed by GitHub
commit 9221e4bf45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 69 additions and 47 deletions

View file

@ -18,6 +18,7 @@
let image: File; let image: File;
import MapMarker from '~icons/mdi/map-marker'; import MapMarker from '~icons/mdi/map-marker';
import Map from '~icons/mdi/map';
import Calendar from '~icons/mdi/calendar'; import Calendar from '~icons/mdi/calendar';
import Notebook from '~icons/mdi/notebook'; import Notebook from '~icons/mdi/notebook';
import ClipboardList from '~icons/mdi/clipboard-list'; import ClipboardList from '~icons/mdi/clipboard-list';
@ -110,18 +111,15 @@
isImageFetcherOpen = false; isImageFetcherOpen = false;
} }
function setLongLat(event: CustomEvent<[number, number]>) { function setLongLat(event: CustomEvent<Adventure>) {
console.log(event.detail); console.log(event.detail);
adventureToEdit.latitude = event.detail[1];
adventureToEdit.longitude = event.detail[0];
isPointModalOpen = false; isPointModalOpen = false;
} }
</script> </script>
{#if isPointModalOpen} {#if isPointModalOpen}
<PointSelectionModal <PointSelectionModal
longitude={adventureToEdit.longitude} bind:adventure={adventureToEdit}
latitude={adventureToEdit.latitude}
on:close={() => (isPointModalOpen = false)} on:close={() => (isPointModalOpen = false)}
on:submit={setLongLat} on:submit={setLongLat}
query={adventureToEdit.name} query={adventureToEdit.name}
@ -184,6 +182,19 @@
bind:value={adventureToEdit.location} bind:value={adventureToEdit.location}
class="input input-bordered w-full max-w-xs mt-1" class="input input-bordered w-full max-w-xs mt-1"
/> />
<div class="mb-2 mt-2">
<button
type="button"
class="btn btn-secondary"
on:click={() => (isPointModalOpen = true)}
>
<Map class="inline-block w-6 h-6" />{adventureToEdit.latitude &&
adventureToEdit.longitude
? 'Change'
: 'Select'}
Location</button
>
</div>
</div> </div>
<div class="mb-2"> <div class="mb-2">
<label for="date">Date <Calendar class="inline-block mb-1 w-6 h-6" /></label><br /> <label for="date">Date <Calendar class="inline-block mb-1 w-6 h-6" /></label><br />
@ -283,16 +294,6 @@
bind:value={adventureToEdit.longitude} bind:value={adventureToEdit.longitude}
class="input input-bordered w-full max-w-xs mt-1" class="input input-bordered w-full max-w-xs mt-1"
/> />
<div class="mb-2">
<button
type="button"
class="btn btn-secondary"
on:click={() => (isPointModalOpen = true)}
>
{adventureToEdit.latitude && adventureToEdit.longitude ? 'Change' : 'Select'}
Location</button
>
</div>
{#if adventureToEdit.collection === null} {#if adventureToEdit.collection === null}
<div class="mb-2"> <div class="mb-2">
<label for="is_public">Public <Earth class="inline-block -mt-1 mb-1 w-6 h-6" /></label <label for="is_public">Public <Earth class="inline-block -mt-1 mb-1 w-6 h-6" /></label

View file

@ -12,8 +12,15 @@
export let longitude: number | null = null; export let longitude: number | null = null;
export let latitude: number | null = null; export let latitude: number | null = null;
import Wikipedia from '~icons/mdi/wikipedia'; import MapMarker from '~icons/mdi/map-marker';
import Calendar from '~icons/mdi/calendar';
import Notebook from '~icons/mdi/notebook';
import ClipboardList from '~icons/mdi/clipboard-list'; import ClipboardList from '~icons/mdi/clipboard-list';
import Star from '~icons/mdi/star';
import Attachment from '~icons/mdi/attachment';
import Map from '~icons/mdi/map';
import Earth from '~icons/mdi/earth';
import Wikipedia from '~icons/mdi/wikipedia';
import ActivityComplete from './ActivityComplete.svelte'; import ActivityComplete from './ActivityComplete.svelte';
import { appVersion } from '$lib/config'; import { appVersion } from '$lib/config';
@ -152,10 +159,8 @@
isImageFetcherOpen = false; isImageFetcherOpen = false;
} }
function setLongLat(event: CustomEvent<[number, number]>) { function setLongLat(event: CustomEvent<Adventure>) {
console.log(event.detail); console.log(event.detail);
newAdventure.latitude = event.detail[1];
newAdventure.longitude = event.detail[0];
isPointModalOpen = false; isPointModalOpen = false;
} }
</script> </script>
@ -165,8 +170,7 @@
query={newAdventure.name} query={newAdventure.name}
on:close={() => (isPointModalOpen = false)} on:close={() => (isPointModalOpen = false)}
on:submit={setLongLat} on:submit={setLongLat}
latitude={newAdventure.latitude || null} bind:adventure={newAdventure}
longitude={newAdventure.longitude || null}
/> />
{/if} {/if}
@ -238,9 +242,7 @@
/> />
</div> </div>
<div class="mb-2"> <div class="mb-2">
<label for="location" <label for="location">Location<MapMarker class="inline-block -mt-1 mb-1 w-6 h-6" /></label
>Location<iconify-icon icon="mdi:map-marker" class="text-lg ml-0.5 -mb-0.5"
></iconify-icon></label
><br /> ><br />
<input <input
type="text" type="text"
@ -249,6 +251,16 @@
bind:value={newAdventure.location} bind:value={newAdventure.location}
class="input input-bordered w-full max-w-xs mt-1" class="input input-bordered w-full max-w-xs mt-1"
/> />
<div class="mb-2 mt-2">
<button
type="button"
class="btn btn-secondary"
on:click={() => (isPointModalOpen = true)}
><Map class="inline-block w-6 h-6" />{newAdventure.latitude && newAdventure.longitude
? 'Change'
: 'Select'} Location</button
>
</div>
</div> </div>
<div class="mb-2"> <div class="mb-2">
<label for="date" <label for="date"
@ -359,14 +371,7 @@
bind:value={newAdventure.longitude} bind:value={newAdventure.longitude}
class="input input-bordered w-full max-w-xs mt-1" class="input input-bordered w-full max-w-xs mt-1"
/> />
<div class="mb-2">
<button
type="button"
class="btn btn-secondary"
on:click={() => (isPointModalOpen = true)}
>{newAdventure.latitude && newAdventure.longitude ? 'Change' : 'Select'} Location</button
>
</div>
<button type="submit" class="btn btn-primary mr-4 mt-4">Create</button> <button type="submit" class="btn btn-primary mr-4 mt-4">Create</button>
<button type="button" class="btn mt-4" on:click={close}>Close</button> <button type="button" class="btn mt-4" on:click={close}>Close</button>
</div> </div>

View file

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
// @ts-nocheck // @ts-nocheck
import type { OpenStreetMapPlace, Point } from '$lib/types'; import type { Adventure, OpenStreetMapPlace, Point } from '$lib/types';
import { createEventDispatcher } from 'svelte'; import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
import { onMount } from 'svelte'; import { onMount } from 'svelte';
@ -12,17 +12,15 @@
let markers: Point[] = []; let markers: Point[] = [];
export let query: string | null = null; export let query: string | null = null;
export let adventure: Adventure;
if (query) { if (query) {
geocode(); geocode();
} }
export let longitude: number | null = null;
export let latitude: number | null = null;
function addMarker(e: CustomEvent<MouseEvent>) { function addMarker(e: CustomEvent<MouseEvent>) {
markers = []; markers = [];
markers = [...markers, { lngLat: e.detail.lngLat, name: 'Marker 1' }]; markers = [...markers, { lngLat: e.detail.lngLat, name: '' }];
console.log(markers); console.log(markers);
} }
@ -31,8 +29,14 @@
if (modal) { if (modal) {
modal.showModal(); modal.showModal();
} }
if (longitude && latitude) { if (adventure.longitude && adventure.latitude) {
markers = [{ lngLat: { lng: longitude, lat: latitude }, name: 'Marker 1' }]; markers = [
{
lngLat: { lng: adventure.longitude, lat: adventure.latitude },
name: adventure.name,
location: adventure.location
}
];
} }
}); });
@ -71,9 +75,19 @@
alert('Please select a point on the map'); alert('Please select a point on the map');
return; return;
} }
let coordArray: [number, number] = [markers[0].lngLat.lng, markers[0].lngLat.lat];
console.log(coordArray); console.log(markers[0]);
dispatch('submit', coordArray); adventure.longitude = markers[0].lngLat.lng;
adventure.latitude = markers[0].lngLat.lat;
if (!adventure.location) {
adventure.location = markers[0].location;
}
if (!adventure.name) {
adventure.name = markers[0].name;
}
adventure.activity_types = [...adventure.activity_types, markers[0].activity_type];
dispatch('submit', adventure);
close();
} }
</script> </script>
@ -120,7 +134,9 @@
markers = [ markers = [
{ {
lngLat: { lng: Number(place.lon), lat: Number(place.lat) }, lngLat: { lng: Number(place.lon), lat: Number(place.lat) },
name: place.display_name location: place.display_name,
name: place.name,
activity_type: place.type
} }
]; ];
}} }}

View file

@ -127,8 +127,8 @@
<circle cx="12" cy="12" r="10" stroke="red" stroke-width="2" fill="red" /> <circle cx="12" cy="12" r="10" stroke="red" stroke-width="2" fill="red" />
</svg> </svg>
<Popup openOn="click" offset={[0, -10]}> <Popup openOn="click" offset={[0, -10]}>
<div class="text-lg font-bold">{name}</div> <div class="text-lg text-black font-bold">{name}</div>
<p class="font-semibold text-md">Visited</p> <p class="font-semibold text-black text-md">Visited</p>
</Popup> </Popup>
</Marker> </Marker>
{/if} {/if}
@ -149,8 +149,8 @@
<circle cx="12" cy="12" r="10" stroke="blue" stroke-width="2" fill="blue" /> <circle cx="12" cy="12" r="10" stroke="blue" stroke-width="2" fill="blue" />
</svg> </svg>
<Popup openOn="click" offset={[0, -10]}> <Popup openOn="click" offset={[0, -10]}>
<div class="text-lg font-bold">{name}</div> <div class="text-lg text-black font-bold">{name}</div>
<p class="font-semibold text-md">Planned</p> <p class="font-semibold text-black text-md">Planned</p>
</Popup> </Popup>
</Marker> </Marker>
{/if} {/if}