mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 07:19:36 +02:00
Add custom location handling in AdventureModal component
This commit is contained in:
parent
98e545be6f
commit
efd19da10b
1 changed files with 22 additions and 10 deletions
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
let noPlaces: boolean = false;
|
let noPlaces: boolean = false;
|
||||||
|
|
||||||
|
let is_custom_location: boolean = false;
|
||||||
|
|
||||||
let reverseGeocodePlace: ReverseGeocode | null = null;
|
let reverseGeocodePlace: ReverseGeocode | null = null;
|
||||||
|
|
||||||
let adventure: Adventure = {
|
let adventure: Adventure = {
|
||||||
|
@ -90,6 +92,11 @@
|
||||||
reverseGeocode();
|
reverseGeocode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
is_custom_location =
|
||||||
|
adventure.location !== reverseGeocodePlace?.display_name || !reverseGeocodePlace;
|
||||||
|
}
|
||||||
|
|
||||||
if (adventure.longitude && adventure.latitude) {
|
if (adventure.longitude && adventure.latitude) {
|
||||||
markers = [];
|
markers = [];
|
||||||
markers = [
|
markers = [
|
||||||
|
@ -113,15 +120,15 @@
|
||||||
markers = [];
|
markers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$: {
|
// $: {
|
||||||
if (
|
// if (
|
||||||
reverseGeocodePlace?.display_name &&
|
// reverseGeocodePlace?.display_name &&
|
||||||
(old_display_name != reverseGeocodePlace.display_name || !adventure.location)
|
// (old_display_name != reverseGeocodePlace.display_name || !adventure.location)
|
||||||
) {
|
// ) {
|
||||||
adventure.location = reverseGeocodePlace.display_name;
|
// adventure.location = reverseGeocodePlace.display_name;
|
||||||
old_display_name = reverseGeocodePlace.display_name;
|
// old_display_name = reverseGeocodePlace.display_name;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
let imageSearch: string = adventure.name || '';
|
let imageSearch: string = adventure.name || '';
|
||||||
|
|
||||||
|
@ -302,6 +309,11 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reverseGeocodePlace = data;
|
reverseGeocodePlace = data;
|
||||||
|
|
||||||
|
if (reverseGeocodePlace && reverseGeocodePlace.display_name && !is_custom_location) {
|
||||||
|
old_display_name = reverseGeocodePlace.display_name;
|
||||||
|
adventure.location = reverseGeocodePlace.display_name;
|
||||||
|
}
|
||||||
console.log(data);
|
console.log(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +592,7 @@
|
||||||
bind:value={adventure.location}
|
bind:value={adventure.location}
|
||||||
class="input input-bordered w-full"
|
class="input input-bordered w-full"
|
||||||
/>
|
/>
|
||||||
{#if reverseGeocodePlace && reverseGeocodePlace.display_name && reverseGeocodePlace.display_name != adventure.location}
|
{#if is_custom_location}
|
||||||
<button
|
<button
|
||||||
class="btn btn-primary ml-2"
|
class="btn btn-primary ml-2"
|
||||||
type="button"
|
type="button"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue