Skip to content

Commit 001fdf8

Browse files
committed
Improving code style
1 parent 05e12f4 commit 001fdf8

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

packages/web-forms/src/components/controls/Input/InputGeopoint.vue

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import Button from 'primevue/button';
44
import PrimeProgressSpinner from 'primevue/progressspinner';
55
import { inject, computed, ref } from 'vue';
66
7-
interface Coordinates {
8-
latitude: string;
9-
longitude: string;
10-
altitude: string;
11-
accuracy: string;
12-
}
13-
147
interface InputGeopointProps {
158
readonly node: GeopointInputNode;
169
}
1710
1811
const props = defineProps<InputGeopointProps>();
1912
const coords = ref<GeolocationCoordinates | null>(null);
2013
14+
interface Coordinates {
15+
latitude: string;
16+
longitude: string;
17+
altitude: string;
18+
accuracy: string;
19+
}
20+
2121
const 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
*/
3333
const ACCURACY_THRESHOLD_DEFAULT = 5;
3434
const 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
*/
4141
const UNACCEPTABLE_ACCURACY_THRESHOLD_DEFAULT = 100;
4242
const unacceptableAccuracyThreshold = computed<number>(() => {
@@ -84,15 +84,15 @@ const qualityLabel = computed<string>(() => {
8484
});
8585
8686
const disabled = computed(() => props.node.currentState.readonly === true);
87-
const watchID = ref<number | null>(null);
8887
const geoLocationError = ref<boolean>(false);
88+
const watchID = ref<number | null>(null);
8989
const isLocating = computed(() => {
9090
return watchID.value !== null;
9191
});
9292
9393
const 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
148148
const 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

Comments
 (0)