@@ -4,20 +4,20 @@ import Button from 'primevue/button';
44import PrimeProgressSpinner from ' primevue/progressspinner' ;
55import { inject , computed , ref } from ' vue' ;
66
7- interface Coordinates {
8- latitude: string ;
9- longitude: string ;
10- altitude: string ;
11- accuracy: string ;
12- }
13-
147interface InputGeopointProps {
158 readonly node: GeopointInputNode ;
169}
1710
1811const props = defineProps <InputGeopointProps >();
1912const coords = ref <GeolocationCoordinates | null >(null );
2013
14+ interface Coordinates {
15+ latitude: string ;
16+ longitude: string ;
17+ altitude: string ;
18+ accuracy: string ;
19+ }
20+
2121const value = computed ((): Coordinates | null => {
2222 if (! props .node .currentState .value ?.length ) {
2323 return null ;
@@ -28,15 +28,15 @@ const value = computed((): Coordinates | null => {
2828});
2929
3030/**
31- * Target in meters that can usually be reached by modern devices given enough time.
31+ * Default accuracy in meters that can usually be reached by modern devices given enough time.
3232 */
3333const ACCURACY_THRESHOLD_DEFAULT = 5 ;
3434const accuracyThreshold = computed <number >(() => {
3535 return props .node .nodeOptions .accuracyThreshold ?? ACCURACY_THRESHOLD_DEFAULT ;
3636});
3737
3838/**
39- * Target in meters, which is about the length of a city block.
39+ * Default unacceptable accuracy in meters, which is about the length of a city block.
4040 */
4141const UNACCEPTABLE_ACCURACY_THRESHOLD_DEFAULT = 100 ;
4242const unacceptableAccuracyThreshold = computed <number >(() => {
@@ -84,15 +84,15 @@ const qualityLabel = computed<string>(() => {
8484});
8585
8686const disabled = computed (() => props .node .currentState .readonly === true );
87- const watchID = ref <number | null >(null );
8887const geoLocationError = ref <boolean >(false );
88+ const watchID = ref <number | null >(null );
8989const isLocating = computed (() => {
9090 return watchID .value !== null ;
9191});
9292
9393const controlElement = ref <HTMLElement | null >(null );
9494// Autosave geopoint when control leaves the viewport as the user scrolls.
95- const observer = new IntersectionObserver (
95+ const controlElementObserver = new IntersectionObserver (
9696 ([entry ]) => {
9797 if (! entry .isIntersecting ) {
9898 save ();
@@ -130,8 +130,8 @@ const start = () => {
130130 { enableHighAccuracy: true }
131131 );
132132
133- if (observer && controlElement .value ) {
134- observer .observe (controlElement .value );
133+ if (controlElementObserver && controlElement .value ) {
134+ controlElementObserver .observe (controlElement .value );
135135 }
136136};
137137
@@ -142,7 +142,7 @@ const stop = () => {
142142
143143 navigator .geolocation .clearWatch (watchID .value );
144144 watchID .value = null ;
145- observer ?.disconnect ();
145+ controlElementObserver ?.disconnect ();
146146};
147147
148148const save = () => {
@@ -165,7 +165,7 @@ const formatNumber = (num: number) => {
165165 </script >
166166
167167<template >
168- <div class = " geolocation-control " ref = " controlElement " >
168+ <div ref = " controlElement " class = " geolocation-control " >
169169 <Button
170170 v-if =" value === null && !isLocating"
171171 rounded
@@ -234,7 +234,7 @@ const formatNumber = (num: number) => {
234234 </div >
235235 </div >
236236
237- <div class = " geolocation-buttons " v-if =" !disabled" >
237+ <div v-if =" !disabled" class = " geolocation-buttons " >
238238 <!-- TODO: translations -->
239239 <Button v-if =" isLocating" text rounded label =" Cancel" @click =" stop()" />
240240
0 commit comments