fixes in enable/disable geo fields in /add

This commit is contained in:
sedum 2023-02-22 16:37:58 +01:00
parent cff608c06f
commit d05d48104a
4 changed files with 13 additions and 12 deletions

View file

@ -64,7 +64,7 @@ export default {
<style> <style>
#leaflet-map { #leaflet-map {
height: 8rem; height: 10rem;
border-radius: .3rem; border-radius: .3rem;
border: 1px solid #fff; border: 1px solid #fff;
z-index: 1; z-index: 1;

View file

@ -37,6 +37,7 @@ v-card
@change='selectAddress' @change='selectAddress'
@focus='searchAddress' @focus='searchAddress'
:items="addressList" :items="addressList"
:disabled='disableGeocoded'
:hint="$t('event.address_description_osm')") :hint="$t('event.address_description_osm')")
template(v-slot:message="{message, key}") template(v-slot:message="{message, key}")
span(v-html='message' :key="key") span(v-html='message' :key="key")
@ -51,16 +52,16 @@ v-card
v-col.py-0(cols=12 sm=6) v-col.py-0(cols=12 sm=6)
v-text-field(v-model="place.latitude" v-text-field(v-model="place.latitude"
:prepend-icon='mdiLatitude' :prepend-icon='mdiLatitude'
:disabled="!settings.allow_geolocation || place.name === 'online'" :disabled='disableGeocoded'
:label="$t('common.latitude')" :label="$t('common.latitude')"
:rules="$validators.latitude") :rules="$validators.latitude")
v-col.py-0(cols=12 sm=6) v-col.py-0(cols=12 sm=6)
v-text-field(v-model="place.longitude" v-text-field(v-model="place.longitude"
:prepend-icon='mdiLongitude' :prepend-icon='mdiLongitude'
:disabled="!settings.allow_geolocation || place.name === 'online'" :disabled='disableGeocoded'
:label="$t('common.longitude')" :label="$t('common.longitude')"
:rules="$validators.longitude") :rules="$validators.longitude")
p.mt-4(v-html="$t('event.address_geocoded_disclaimer')") p.mt-4(v-if='place.isNew' v-html="$t('event.address_geocoded_disclaimer')")
MapEdit.mt-4(:place='place' :key='mapEdit' v-if="(settings.allow_geolocation && place.name !== 'online' && place.latitude && place.longitude)" ) MapEdit.mt-4(:place='place' :key='mapEdit' v-if="(settings.allow_geolocation && place.name !== 'online' && place.latitude && place.longitude)" )
@ -93,7 +94,8 @@ export default {
mdiMap, mdiLatitude, mdiLongitude, mdiCog, mdiLink, mdiCloseCircle, mdiMap, mdiLatitude, mdiLongitude, mdiCog, mdiLink, mdiCloseCircle,
mdiMapMarker, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant, mdiMapMarker, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant,
showOnline: $store.state.settings.allow_event_also_online, showOnline: $store.state.settings.allow_event_also_online,
showGeocoded: $store.state.settings.allow_geolocation && this.place.isNew && this.place.name !== 'online', showGeocoded: $store.state.settings.allow_geolocation && this.place.name !== 'online',
disableGeocoded: this.place.name === 'online' || !this.place.isNew,
event_only_online: this.place.name === 'online', event_only_online: this.place.name === 'online',
mapEdit: 1, mapEdit: 1,
addressList: [], addressList: [],
@ -104,7 +106,6 @@ export default {
'mdiMapMarker': mdiMapMarker, 'mdiMapMarker': mdiMapMarker,
'mdiCityVariant': mdiCityVariant 'mdiCityVariant': mdiCityVariant
}, },
geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim',
currentGeocodingProvider: geolocation.getGeocodingProvider($store.state.settings.geocoding_provider_type), currentGeocodingProvider: geolocation.getGeocodingProvider($store.state.settings.geocoding_provider_type),
prevAddress: '' prevAddress: ''
} }
@ -138,7 +139,7 @@ export default {
const searchCoordinates = pre_searchCoordinates.replace('/', ',') const searchCoordinates = pre_searchCoordinates.replace('/', ',')
if (searchCoordinates.length) { if (searchCoordinates.length) {
this.loading = true this.loading = true
const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`) const ret = await this.$axios.$get(`placeOSM/${this.currentGeocodingProvider.commonName}/${searchCoordinates}`)
this.addressList = this.currentGeocodingProvider.mapQueryResults(ret) this.addressList = this.currentGeocodingProvider.mapQueryResults(ret)
this.loading = false this.loading = false
} }

View file

@ -43,9 +43,9 @@ v-container
template(v-slot:item="{ item, attrs, on, selected }") template(v-slot:item="{ item, attrs, on, selected }")
v-list-item(v-bind='attrs' v-on='on') v-list-item(v-bind='attrs' v-on='on')
v-icon.pr-4(v-text='loadCoordinatesResultIcon(item)') v-icon.pr-4(v-text='loadCoordinatesResultIcon(item)')
v-list-item-content(two-line v-if='item' :input-value="selected" ) v-list-item-content(two-line v-if='item')
v-list-item-title(v-text='item.name') v-list-item-title(v-text='item.name')
v-list-item-subtitle(v-text='`${item.address}`') v-list-item-subtitle(v-text='`${item.address}`') {{ selected }}
v-row.mt-4(v-if="(settings.allow_geolocation && place.name !== 'online')") v-row.mt-4(v-if="(settings.allow_geolocation && place.name !== 'online')")
v-col.py-0(cols=12 md=6) v-col.py-0(cols=12 md=6)
@ -174,7 +174,7 @@ export default {
} else { } else {
this.place.address = currentAddress this.place.address = currentAddress
} }
this.place.selected = true
this.prevAddress = this.place.geocodedAddress this.prevAddress = this.place.geocodedAddress
this.$emit('input', { ...this.place }) this.$emit('input', { ...this.place })
}, },

View file

@ -39,8 +39,8 @@ const eventController = {
place = await Place.create({ place = await Place.create({
name: place_name, name: place_name,
address: place_address, address: place_address,
latitude: body.place_latitude, latitude: Number(body.place_latitude) || null,
longitude: body.place_longitude longitude: Number(body.place_longitude) || null
}) })
} }
return place return place