From dcdefec6de005a41f00196cfdad50bfb84570e75 Mon Sep 17 00:00:00 2001 From: sedum Date: Fri, 2 Sep 2022 08:32:13 +0200 Subject: [PATCH 01/10] add geolocalization --- components/WhereInput.vue | 62 +++++++++++++++++-- components/admin/Places.vue | 14 +++++ components/admin/Settings.vue | 8 +++ locales/en.json | 4 ++ pages/add/_edit.vue | 3 +- server/api/controller/event.js | 28 +++++---- server/api/controller/place.js | 17 ++++- server/api/controller/settings.js | 1 + server/api/index.js | 10 +-- server/api/models/place.js | 3 +- .../20220706090946-place-details.js | 25 ++++++++ store/index.js | 1 + 12 files changed, 150 insertions(+), 26 deletions(-) create mode 100644 server/migrations/20220706090946-place-details.js diff --git a/components/WhereInput.vue b/components/WhereInput.vue index 900d5f6f..aea64c3a 100644 --- a/components/WhereInput.vue +++ b/components/WhereInput.vue @@ -30,11 +30,30 @@ v-row :label="$t('common.address')" @change="changeAddress" :value="value.address") + v-combobox.mr-4(ref='detailsView' v-if='settings.allow_geolocalization' + :prepend-icon='mdiMapSearch' + :disabled='disableDetails' + @input.native='searchCoordinates' + :label="$t('common.coordinates')" + :value='value.detailsView' + persistent-hint hide-no-data clearable no-filter + :loading='loading' + @change='selectDetails' + @focus='searchCoordinates' + :items="detailsList" + :hint="$t('event.coordinates_description')") + template(v-slot:item="{ item, attrs, on }") + v-list-item(v-bind='attrs' v-on='on') + v-list-item-content(two-line v-if='item') + v-list-item-title(v-text='item.display_name') + v-list-item-subtitle(v-text='`${item.lat}`+`,`+`${item.lon}`') + v-text-field(ref='details' v-show='false' v-if='settings.allow_geolocalization') diff --git a/components/admin/Places.vue b/components/admin/Places.vue index 4e9b0d14..a68ca498 100644 --- a/components/admin/Places.vue +++ b/components/admin/Places.vue @@ -25,6 +25,13 @@ v-container v-model='place.address' :placeholder='$t("common.address")') + v-textarea(v-if="settings.allow_geolocalization" + row-height="15" + :disabled="true" + :label="$t('common.details')" + v-model='place.details' + :placeholder='$t("common.details")') + v-card-actions v-spacer v-btn(@click='dialog=false' color='warning') {{$t('common.cancel')}} @@ -47,6 +54,7 @@ v-container + + diff --git a/components/WhereInput.vue b/components/WhereInput.vue index 088e39fe..75d41da2 100644 --- a/components/WhereInput.vue +++ b/components/WhereInput.vue @@ -47,7 +47,7 @@ v-row v-list-item-content(two-line v-if='item') v-list-item-title(v-text='item.display_name') v-list-item-subtitle(v-text='`${item.lat}`+`,`+`${item.lon}`') - v-text-field(ref='details' v-show='false' v-if='settings.allow_geolocation') + v-text-field(ref='details' v-if='settings.allow_geolocation') From 6a7205ed3462a26c2025d79d4ead2ac86dce57db Mon Sep 17 00:00:00 2001 From: sedum Date: Fri, 28 Oct 2022 04:36:39 +0200 Subject: [PATCH 07/10] allowgeoloc: trim placename before submit as issue 189 reported --- pages/add/_edit.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/add/_edit.vue b/pages/add/_edit.vue index c18a7ad1..1e9377d3 100644 --- a/pages/add/_edit.vue +++ b/pages/add/_edit.vue @@ -212,7 +212,7 @@ export default { if (this.event.place.id) { formData.append('place_id', this.event.place.id) } - formData.append('place_name', this.event.place.name) + formData.append('place_name', this.event.place.name.trim()) formData.append('place_address', this.event.place.address) formData.append('place_latitude', this.event.place.latitude) formData.append('place_longitude', this.event.place.longitude) From ca6a0ea58f699e97898fe1fa8c8daa0692e78e4b Mon Sep 17 00:00:00 2001 From: sedum Date: Fri, 28 Oct 2022 08:27:47 +0200 Subject: [PATCH 08/10] center map in dialog delaying popup, add validation of coordinates in /add, fix loading feedback in searchCoordinates field --- components/Map.vue | 157 ++++++++++++++++++++------------------ components/WhereInput.vue | 30 ++++---- pages/event/_slug.vue | 2 +- 3 files changed, 96 insertions(+), 93 deletions(-) diff --git a/components/Map.vue b/components/Map.vue index 19ed9fe0..9846c9cc 100644 --- a/components/Map.vue +++ b/components/Map.vue @@ -19,8 +19,8 @@ client-only(placeholder='Loading...' ) .text-h6 v-icon(v-text='mdiMapMarker' ) nuxt-link.ml-2.p-name.text-decoration-none(v-text="event.place.name" :to='`/place/${event.place.name}`') - v-text.mx-2(v-text="`${event.place.address}`") - v-text.my-4(v-text="$t('common.getting_there')") + p.mx-2(v-text="`${event.place.address}`") + p.my-4(v-text="$t('common.getting_there')") v-row v-btn.ml-2(icon large :href="routeBy('foot')") v-icon(v-text='mdiWalk' color='white') @@ -32,87 +32,94 @@ client-only(placeholder='Loading...' ) diff --git a/components/WhereInput.vue b/components/WhereInput.vue index fcde2108..fa9ec92d 100644 --- a/components/WhereInput.vue +++ b/components/WhereInput.vue @@ -173,27 +173,24 @@ export default { this.$emit('input', { ...this.place }) }, searchCoordinates: debounce(async function(ev) { - this.loading = true const pre_searchCoordinates = ev.target.value.trim().toLowerCase() - // allow pasting coordinates lat/lon + // allow pasting coordinates lat/lon and lat,lon const searchCoordinates = pre_searchCoordinates.replace('/', ',') - // console.log(pre_searchCoordinates) - var regex_coords_comma = "-?[1-9][0-9]*(\\.[0-9]+)?,\\s*-?[1-9][0-9]*(\\.[0-9]+)?"; var regex_coords_slash = "-?[1-9][0-9]*(\\.[0-9]+)?/\\s*-?[1-9][0-9]*(\\.[0-9]+)?"; const setCoords = (v) => { - this.place.latitude = v[0].trim() - this.place.longitude = v[1].trim() - - if (this.place.latitude < -90 || this.place.latitude > 90) { - // non existent + const lat = v[0].trim() + const lon = v[1].trim() + // check coordinates are valid + if ((lat < 90 && lat > -90) + && (lon < 180 && lon > -180)) { + this.place.latitude = lat + this.place.longitude = lon + } else { + this.$root.$message("Non existent coordinates", { color: 'error' }) + return } - if (this.place.latitude < -180 || this.place.latitude > 180) { - // non existent - } - - this.loading = false; } if (pre_searchCoordinates.match(regex_coords_comma)) { @@ -208,10 +205,9 @@ export default { } if (searchCoordinates.length) { + this.loading = true this.detailsList = await this.$axios.$get(`placeNominatim/${searchCoordinates}`) - } - if (this.detailsList) { - this.loading = false; + this.loading = false } }, 300), } diff --git a/pages/event/_slug.vue b/pages/event/_slug.vue index b60bd31d..3cc1f86a 100644 --- a/pages/event/_slug.vue +++ b/pages/event/_slug.vue @@ -32,7 +32,7 @@ v-container#event.pa-0.pa-sm-2 v-icon(v-text='mdiMapMarker') nuxt-link.vcard.ml-2.p-name.text-decoration-none(itemprop="name" :to='`/place/${event.place.name}`') {{event.place && event.place.name}} .text-subtitle-1.p-street-address(itemprop='address') {{event.place && event.place.address}} - v-btn.mt-2(v-if='event.place.latitude && event.place.longitude' small v-text="$t('common.show_map')" :aria-label="$t('common.show_map')" @click="mapModal = true") + v-btn.mt-2(v-if='settings.allow_geolocation && event.place.latitude && event.place.longitude' small v-text="$t('common.show_map')" :aria-label="$t('common.show_map')" @click="mapModal = true") v-dialog(v-model='mapModal' :fullscreen='$vuetify.breakpoint.xsOnly' destroy-on-close) v-card Map(:event='event') From 7fdc6ca07f9957126ae2ac183c522722384d99c7 Mon Sep 17 00:00:00 2001 From: sedum Date: Fri, 11 Nov 2022 06:01:50 +0100 Subject: [PATCH 09/10] allowgeoloc: add translations, fix padding in whereinput, center text in show-map dialog --- components/Map.vue | 2 +- components/WhereInput.vue | 8 +- locales/ca.json | 9 +- locales/de.json | 9 +- locales/en.json | 4 +- locales/es.json | 9 +- locales/fr.json | 9 +- locales/gl.json | 9 +- locales/it.json | 9 +- locales/nb.json | 9 +- package.json | 6 +- tests/app.test.js | 6 ++ yarn.lock | 186 +++++++++++++++++++++++++++++++++++--- 13 files changed, 245 insertions(+), 30 deletions(-) diff --git a/components/Map.vue b/components/Map.vue index 9846c9cc..0bad64d9 100644 --- a/components/Map.vue +++ b/components/Map.vue @@ -15,7 +15,7 @@ client-only(placeholder='Loading...' ) :lat-lng="item.coordinates") LPopup(:content="item.address") - v-row.my-4.d-flex.flex-column.align-center + v-row.my-4.d-flex.flex-column.align-center.text-center .text-h6 v-icon(v-text='mdiMapMarker' ) nuxt-link.ml-2.p-name.text-decoration-none(v-text="event.place.name" :to='`/place/${event.place.name}`') diff --git a/components/WhereInput.vue b/components/WhereInput.vue index fa9ec92d..ff617924 100644 --- a/components/WhereInput.vue +++ b/components/WhereInput.vue @@ -1,5 +1,5 @@ -