reinit whereinputadvanced in /add , and init only/also online mechanism, various fixes: admin edit place; bug in nominatim display_name when place in certain nominatim_class, init refactor geocoding related code in services/geocoding/provider; init MapEdit component

This commit is contained in:
sedum
2023-02-17 00:23:35 +01:00
parent 6aceaba7f7
commit 79ebec9116
21 changed files with 1558 additions and 255 deletions

70
components/MapEdit.vue Normal file
View File

@@ -0,0 +1,70 @@
<template lang="pug">
client-only(placeholder='Loading...' )
LMap(ref="map"
id="leaflet-map"
:zoom="zoom"
:options="{attributionControl: false}"
:center="center")
LControlAttribution(position='bottomright' prefix="")
LTileLayer(
:url="url"
:attribution="attribution")
LMarker(
:lat-lng="marker.coordinates")
</template>
<script>
import "leaflet/dist/leaflet.css"
import { LMap, LTileLayer, LMarker, LPopup, LControlAttribution } from 'vue2-leaflet'
import { mapActions, mapState } from 'vuex'
import { Icon } from 'leaflet'
import { mdiWalk, mdiBike, mdiCar, mdiMapMarker } from '@mdi/js'
export default {
components: {
LMap,
LTileLayer,
LMarker,
LPopup,
LControlAttribution
},
data ({ $store }) {
return {
mdiWalk, mdiBike, mdiCar, mdiMapMarker,
url: $store.state.settings.tilelayer_provider || 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: $store.state.settings.tilelayer_provider_attribution || "<a target=\"_blank\" href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors",
zoom: 14,
center: [this.place.latitude, this.place.longitude],
marker: {
address: this.place.address,
coordinates: {lat: this.place.latitude, lon: this.place.longitude }
}
}
},
props: {
place: { type: Object, default: () => ({}) }
},
mounted() {
delete Icon.Default.prototype._getIconUrl;
Icon.Default.mergeOptions({
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
iconUrl: require('leaflet/dist/images/marker-icon.png'),
shadowUrl: require('leaflet/dist/images/marker-shadow.png'),
});
setTimeout(() => {
this.$refs.map.mapObject.invalidateSize();
}, 200);
}
}
</script>
<style>
#leaflet-map {
height: 8rem;
border-radius: .3rem;
border: 1px solid #fff;
z-index: 1;
}
</style>

View File

@@ -24,7 +24,22 @@ v-row.mb-4
v-col(cols=12 md=6)
v-text-field(v-if="!settings.allow_geolocation"
v-row.mx-0.my-0.align-center.justify-center
v-combobox.mr-4(v-model="virtualLocations" v-if="settings.allow_event_only_online && value.name === 'online'"
:prepend-icon='mdiLink'
:hint="`Online locations, for instance a url to a videconference room`"
:label="$t('event.online_event_urls')"
clearable chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
:delimiters="[',', ';', '; ']"
:items="virtualLocations"
@change='selectLocations')
template(v-slot:selection="{ item, on, attrs, selected, parent }")
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
:input-value="selected" label small) {{ item }}
template(v-slot:append)
v-icon(v-text='mdiCog' :disabled='!value.name' @click="whereInputAdvancedDialog = true")
v-text-field.mr-4(v-if="!settings.allow_geolocation && value.name !== 'online'"
ref='address'
:prepend-icon='mdiMap'
:disabled='disableAddress'
@@ -34,57 +49,66 @@ v-row.mb-4
persistent-hint
@change="changeAddress"
:value="value.address")
v-combobox(ref='address' v-else
:prepend-icon='mdiMapSearch'
:disabled='disableAddress'
@input.native='searchAddress'
:label="$t('common.address')"
:rules="[ v => disableAddress ? true : $validators.required('common.address')(v)]"
:value='value.address'
item-text='address'
persistent-hint hide-no-data clearable no-filter
:loading='loading'
@change='selectAddress'
@focus='searchAddress'
:items="addressList"
:hint="$t('event.address_description_osm')")
template(v-slot:message="{message, key}")
span(v-html='message' :key="key")
template(v-slot:item="{ item, attrs, on }")
v-list-item(v-bind='attrs' v-on='on')
v-icon.pr-4(v-text='loadCoordinatesResultIcon(item)')
v-list-item-content(two-line v-if='item')
v-list-item-title(v-text='item.name')
v-list-item-subtitle(v-text='`${item.address}`')
//- v-col(cols=12 md=3 v-if='settings.allow_geolocation')
//- v-text-field(ref='latitude' :value='value.latitude'
//- :prepend-icon='mdiLatitude'
//- :disabled='disableDetails'
//- :label="$t('common.latitude')" )
//- v-col(cols=12 md=3 v-if='settings.allow_geolocation')
//- v-text-field(ref='longitude' :value='value.longitude'
//- :prepend-icon='mdiLongitude'
//- :disabled='disableDetails'
//- :label="$t('common.longitude')")
template(v-slot:append v-if="settings.allow_event_also_online && place.name !== 'online'")
v-icon(v-text='mdiCog' :disabled='!value.name' @click="whereInputAdvancedDialog = true")
v-combobox(ref='address' v-if="settings.allow_geolocation && value.name !== 'online' || (!settings.allow_event_only_online && value.name === 'online')"
:prepend-icon='mdiMapSearch'
:disabled='disableAddress'
@input.native='searchAddress'
:label="$t('common.address')"
:rules="[ v => disableAddress ? true : $validators.required('common.address')(v)]"
:value='value.address'
item-text='address'
persistent-hint hide-no-data clearable no-filter
:loading='loading'
@change='selectAddress'
@focus='searchAddress'
:items="addressList"
:hint="$t('event.address_description_osm')")
template(v-slot:message="{message, key}")
span(v-html='message' :key="key")
template(v-slot:item="{ item, attrs, on }")
v-list-item(v-bind='attrs' v-on='on')
v-icon.pr-4(v-text='loadCoordinatesResultIcon(item)')
v-list-item-content(two-line v-if='item')
v-list-item-title(v-text='item.name')
v-list-item-subtitle(v-text='`${item.address}`')
template(v-slot:append v-if="settings.allow_event_also_online || settings.allow_geolocation")
v-icon(v-text='mdiCog' :disabled='!value.name || (!value.isNew && !settings.allow_event_also_online) ' @click="whereInputAdvancedDialog = true")
v-dialog(v-model='whereInputAdvancedDialog' :key="whereAdvancedId" destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly' dense)
WhereInputAdvanced(ref='whereAdvanced' :place.sync='value' :event='event' @close='whereInputAdvancedDialog = false && this.$refs.address.blur()'
:virtualLocations.sync="virtualLocations"
:online_event_only_value.sync='online_event_only'
@update:onlineEvent="changeOnlineEvent"
@update:virtualLocations="selectLocations"
)
</template>
<script>
import { mdiMap, mdiMapMarker, mdiPlus, mdiMapSearch, mdiLatitude, mdiLongitude, mdiRoadVariant, mdiHome, mdiCityVariant } from '@mdi/js'
import { mdiMap, mdiMapMarker, mdiPlus, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant, mdiCog, mdiLink, mdiCloseCircle } from '@mdi/js'
import { mapState } from 'vuex'
import debounce from 'lodash/debounce'
import get from 'lodash/get'
import WhereInputAdvanced from './WhereInputAdvanced.vue'
import nominatim from '../server/services/geocoding/nominatim'
import photon from '../server/services/geocoding/photon'
export default {
name: 'WhereInput',
props: {
value: { type: Object, default: () => ({}) }
value: { type: Object, default: () => ({}) },
event: { type: Object, default: () => null },
},
components: { WhereInputAdvanced },
data ( {$store} ) {
return {
mdiMap, mdiMapMarker, mdiPlus, mdiMapSearch, mdiLatitude, mdiLongitude, mdiRoadVariant, mdiHome, mdiCityVariant,
mdiMap, mdiMapMarker, mdiPlus, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant, mdiCog, mdiLink, mdiCloseCircle,
places: [],
place: { },
placeName: '',
places: [],
disableAddress: true,
addressList: [],
loading: false,
@@ -101,7 +125,13 @@ export default {
'N': mdiMapMarker,
'R': mdiCityVariant,
},
geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim'
geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim',
nominatimProvider: nominatim,
photonProvider: photon,
whereInputAdvancedDialog: false,
virtualLocations: this.event.locations || [],
online_event_only: (this.value.name === 'online') ? true : false,
whereAdvancedId: 1
}
},
computed: {
@@ -134,8 +164,15 @@ export default {
search: debounce(async function(ev) {
const search = ev ? ev.target.value.trim().toLowerCase() : ''
this.places = await this.$axios.$get(`place?search=${search}`)
if (!search && this.places.length) { return this.places }
const matches = this.places.find(p => search === p.name.toLocaleLowerCase())
// Filter out the place with name 'online' if not allowed
if (this.places.length && !this.settings.allow_event_only_online) {
this.places = this.places.filter(p => p.name !== 'online')
}
if (!search && this.places.length) {
return this.places
}
const matches = this.places.filter(p => p.name !== 'online').find(p => search === p.name.toLocaleLowerCase())
if (!matches && search) {
this.places.unshift({ create: true, name: ev.target.value.trim() })
}
@@ -154,6 +191,11 @@ export default {
}
},
selectPlace (p) {
// force online events under place: online address: online
this.online_event_only = false
this.place.isNew = false
this.whereAdvancedId++
if (!p) { return }
if (typeof p === 'object' && !p.create) {
if (p.id === this.value.id) return
@@ -164,8 +206,14 @@ export default {
this.place.longitude = p.longitude
}
this.place.id = p.id
if (this.settings.allow_event_only_online && this.place.name === 'online') {
this.online_event_only = true
}
this.disableAddress = true
} else { // this is a new place
this.place.isNew = true
this.whereAdvancedId++
this.place.name = (p.name || p).trim()
const tmpPlace = this.place.name.toLocaleLowerCase()
// search for a place with the same name
@@ -183,6 +231,10 @@ export default {
this.place.latitude = p.latitude
this.place.longitude = p.longitude
}
// Prevent to provide link for 'event only online' if not allowed: reset locations
if (!this.settings.allow_event_only_online && this.place.name === 'online') {
this.event.locations = []
}
this.disableAddress = false
this.$refs.place.blur()
this.$refs.address.focus()
@@ -210,91 +262,42 @@ export default {
},
searchAddress: debounce(async function(ev) {
const pre_searchCoordinates = ev.target.value.trim().toLowerCase()
// allow pasting coordinates lat/lon and lat,lon
const searchCoordinates = pre_searchCoordinates.replace('/', ',')
// const regex_coords_comma = "-?[1-9][0-9]*(\\.[0-9]+)?,\\s*-?[1-9][0-9]*(\\.[0-9]+)?";
// const regex_coords_slash = "-?[1-9][0-9]*(\\.[0-9]+)?/\\s*-?[1-9][0-9]*(\\.[0-9]+)?";
// const setCoords = (v) => {
// 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 (pre_searchCoordinates.match(regex_coords_comma)) {
// let v = pre_searchCoordinates.split(",")
// setCoords(v)
// return
// }
// if (pre_searchCoordinates.match(regex_coords_slash)) {
// let v = pre_searchCoordinates.split("/")
// setCoords(v)
// return
// }
if (searchCoordinates.length) {
this.loading = true
const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`)
// this.geocoding_provider.mapQueryResults(ret)
if (this.geocoding_provider_type == "Nominatim") {
if (ret && ret.length) {
this.addressList = ret.map(v => {
const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name'))
const address = v.display_name ? v.display_name.replace(name, '').replace(/^, ?/, '') : ''
return {
class: v.class,
type: v.osm_type,
lat: v.lat,
lon: v.lon,
name,
address
}
})
} else {
this.addressList = []
}
this.addressList = nominatim.mapQueryResults(ret)
} else if (this.geocoding_provider_type == "Photon") {
let photon_properties = ['housenumber', 'street', 'locality', 'district', 'city', 'county', 'state', 'postcode', 'country']
if (ret) {
this.addressList = ret.features.map(v => {
let pre_name = v.properties.name || v.properties.street || ''
let pre_address = ''
photon_properties.forEach((item, i) => {
let last = i == (photon_properties.length - 1)
if (v.properties[item] && !last) {
pre_address += v.properties[item]+', '
} else if (v.properties[item]) {
pre_address += v.properties[item]
}
});
let name = pre_name
let address = pre_address
return {
class: v.properties.osm_key,
type: v.properties.osm_type,
lat: v.geometry.coordinates[1],
lon: v.geometry.coordinates[0],
name,
address
}
})
} else {
this.addressList = []
}
this.addressList = photon.mapQueryResults(ret)
}
this.loading = false
}
}, 1000)
}, 1000),
selectLocations () {
this.event.locations = []
this.virtualLocations && this.virtualLocations.forEach((item, i) => {
if (!item.startsWith('http')) {
this.virtualLocations[i] = `https://${item}`
}
this.event.locations[i] = {'type': 'virtualLocation', 'url': this.virtualLocations[i] }
})
},
changeOnlineEvent(v) {
this.online_event_only = v
// console.log(this.online_event_only)
if (this.online_event_only) { this.place.name = this.place.address = 'online' }
if (!this.online_event_only) { this.place.name = this.place.address = '' }
this.place.latitude = null
this.place.longitude = null
// update virtualLocations
this.event.locations && this.selectLocations()
this.$emit('input', { ...this.place })
},
}
}
</script>

View File

@@ -0,0 +1,104 @@
<template lang="pug">
v-card
v-card-title {{ $t('event.where_advanced_options') }}
v-card-subtitle {{ $t('event.where_advanced_options_description') }}
v-card-text(v-if="settings.allow_event_only_online")
v-switch.mt-0.mb-2(v-model='online_event_only_update'
persistent-hint
:label="$t('event.event_only_online_label')"
:hint="$t('event.online_event_only_help')")
v-combobox.mt-0.mb-0.mr-4.my-5(v-model="virtualLocations_update"
v-if="place.name !== 'online' && settings.allow_event_also_online"
:prepend-icon='mdiLink'
:hint="$t('event.additional_online_locations_help')"
:label="$t('event.additional_online_locations')"
clearable chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
:delimiters="[',', ';', '; ']"
:items="virtualLocations_update")
template(v-slot:selection="{ item, on, attrs, selected, parent }")
v-chip(v-bind="attrs" close :close-icon='mdiCloseCircle' @click:close='parent.selectItem(item)'
:input-value="selected" label small) {{ item }}
v-divider(v-if='showGeocoded && showOnline')
v-card-text.mt-5(v-if='showGeocoded')
v-text-field.mt-0.mb-0(v-model='place.address'
:prepend-icon='mdiMap'
:disabled="!settings.allow_geolocation || place.name === 'online'"
persistent-hint
:hint="$t('event.address_overwrite_help')"
:label="$t('event.address_overwrite')")
v-row.mt-4
v-col.py-0(cols=12 md=6)
v-text-field(v-model="place.latitude"
:prepend-icon='mdiLatitude'
:disabled="!settings.allow_geolocation || place.name === 'online'"
:label="$t('common.latitude')"
:rules="$validators.latitude")
v-col.py-0(cols=12 md=6)
v-text-field(v-model="place.longitude"
:prepend-icon='mdiLongitude'
:disabled="!settings.allow_geolocation || place.name === 'online'"
:label="$t('common.longitude')"
:rules="$validators.longitude")
p.mt-4(v-html="$t('event.address_geocoded_disclaimer')")
MapEdit.mt-4(:place='place' v-if="mapEdit && (settings.allow_geolocation && place.name !== 'online' && place.latitude && place.longitude)" )
v-card-actions
v-spacer
v-btn(@click='close' outlined) Close
</template>
<script>
import { mdiMap, mdiLatitude, mdiLongitude, mdiCog, mdiLink, mdiCloseCircle } from '@mdi/js'
import { mapState } from 'vuex'
import debounce from 'lodash/debounce'
import get from 'lodash/get'
export default {
name: 'WhereInputAdvanced',
props: {
place: { type: Object, default: () => ({}) },
event: { type: Object, default: () => null },
online_event_only_value: { type: Boolean, default: false },
virtualLocations: { type: Array, default: [] }
},
components: {
[process.client && 'MapEdit']: () => import('@/components/MapEdit.vue')
},
data ({$store}) {
return {
mdiMap, mdiLatitude, mdiLongitude, mdiCog, mdiLink, mdiCloseCircle,
showOnline: $store.state.settings.allow_event_also_online,
showGeocoded: $store.state.settings.allow_geolocation && this.place.isNew,
online_event_only: this.place.name === 'online',
mapEdit: true
}
},
computed: {
...mapState(['settings']),
online_event_only_update: {
get () { return this.online_event_only_value },
set (value) {
this.$emit('update:onlineEvent', value)
this.close()
}
},
virtualLocations_update: {
get () { return this.virtualLocations },
set (value) {
this.$emit('update:virtualLocations', value)
}
},
},
methods: {
close() {
this.$emit('close')
}
}
}
</script>

View File

@@ -11,32 +11,57 @@ v-container
v-dialog(v-model='dialog' width='600' :fullscreen='$vuetify.breakpoint.xsOnly')
v-card
v-card-title {{ $t('admin.edit_place') }}
v-card-text
v-card-text.mb-4
v-form(v-model='valid' ref='form' lazy-validation)
v-text-field(
:rules="[$validators.required('common.name')]"
:label="$t('common.name')"
v-model='place.name'
:placeholder='$t("common.name")')
v-combobox(ref='address'
v-text-field(
:rules="[ v => $validators.required('common.address')(v)]"
:label="$t('common.address')"
v-model='place.address'
persistent-hint)
v-combobox.mt-0.mb-4(ref='geocodedAddress'
v-if="(settings.allow_geolocation && place.name !== 'online')"
:disabled="!(settings.allow_geolocation && place.name !== 'online')"
:prepend-icon='mdiMapSearch'
@input.native='searchAddress'
:label="$t('common.address')"
:rules="[ v => $validators.required('common.address')(v)]"
:value='place.address'
:label="$t('admin.search_address')"
:value='place.latitude && place.longitude && place.geocodedAddress'
persistent-hint hide-no-data clearable no-filter
:loading='loading'
@change='selectAddress'
@focus='searchAddress'
:items="addressList"
:hint="$t('event.address_description')")
:hint="$t('event.address_description_osm')")
template(v-slot:message="{message, key}")
span(v-html='message' :key="key")
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.name')
v-list-item-subtitle(v-text='`${item.address}`')
v-row.mt-4(v-if="(settings.allow_geolocation && place.name !== 'online')")
v-col.py-0(cols=12 md=6)
v-text-field(v-model="place.latitude"
:value="place.latitude"
:prepend-icon='mdiLatitude'
:disabled="(!settings.allow_geolocation || place.name === 'online')"
:label="$t('common.latitude')"
:rules="$validators.latitude")
v-col.py-0(cols=12 md=6)
v-text-field(v-model="place.longitude"
:prepend-icon='mdiLongitude'
:disabled="!settings.allow_geolocation || place.name === 'online'"
:label="$t('common.longitude')"
:rules="$validators.longitude")
MapEdit.mt-4(:place='place' :key="mapEdit" v-if="settings.allow_geolocation && place.name !== 'online' && place.latitude && place.longitude")
v-card-actions
v-spacer
@@ -62,15 +87,22 @@ v-container
</template>
<script>
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown } from '@mdi/js'
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown,
mdiLatitude, mdiLongitude } from '@mdi/js'
import { mapState } from 'vuex'
import debounce from 'lodash/debounce'
import get from 'lodash/get'
import nominatim from '../../server/services/geocoding/nominatim'
import photon from '../../server/services/geocoding/photon'
// import geolocation from '../../server/helpers/geolocation/index'
export default {
components: {
[process.client && 'MapEdit']: () => import('@/components/MapEdit.vue')
},
data( {$store} ) {
return {
mdiPencil, mdiChevronRight, mdiChevronLeft, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown,
mdiLatitude, mdiLongitude,
loading: false,
dialog: false,
valid: false,
@@ -85,12 +117,17 @@ export default {
{ value: 'map', text: 'Map' },
{ value: 'actions', text: this.$t('common.actions'), align: 'right' }
],
geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim'
geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim',
nominatimProvider: nominatim,
photonProvider: photon
}
},
async fetch() {
this.places = await this.$axios.$get('/places')
},
mounted() {
// this.currentGeocodingProvider = geolocation.getGeocodingProvider(this.settings.geocoding_provider_type)
},
computed: {
...mapState(['settings']),
},
@@ -99,6 +136,8 @@ export default {
this.place.name = item.name
this.place.address = item.address
if (this.settings.allow_geolocation) {
this.place.geocodedAddress = ''
this.mapEdit++
this.place.latitude = item.latitude
this.place.longitude = item.longitude
}
@@ -116,10 +155,12 @@ export default {
selectAddress (v) {
if (!v) { return }
if (typeof v === 'object') {
this.place.latitude = v.lat
this.place.longitude = v.lon
this.place.address = v.address
// }
this.place.latitude = v.lat
this.place.longitude = v.lon
this.place.address = v.address
if (this.settings.allow_geolocation) {
this.place.geocodedAddress = v.address
}
} else {
this.place.address = v
this.place.latitude = this.place.longitude = null
@@ -128,91 +169,19 @@ export default {
},
searchAddress: debounce(async function(ev) {
const pre_searchCoordinates = ev.target.value.trim().toLowerCase()
// allow pasting coordinates lat/lon and lat,lon
const searchCoordinates = pre_searchCoordinates.replace('/', ',')
// const regex_coords_comma = "-?[1-9][0-9]*(\\.[0-9]+)?,\\s*-?[1-9][0-9]*(\\.[0-9]+)?";
// const regex_coords_slash = "-?[1-9][0-9]*(\\.[0-9]+)?/\\s*-?[1-9][0-9]*(\\.[0-9]+)?";
// const setCoords = (v) => {
// 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 (pre_searchCoordinates.match(regex_coords_comma)) {
// let v = pre_searchCoordinates.split(",")
// setCoords(v)
// return
// }
// if (pre_searchCoordinates.match(regex_coords_slash)) {
// let v = pre_searchCoordinates.split("/")
// setCoords(v)
// return
// }
if (searchCoordinates.length) {
this.loading = true
const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`)
if (this.geocoding_provider_type == "Nominatim") {
if (ret && ret.length) {
this.addressList = ret.map(v => {
const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name'))
const address = v.display_name ? v.display_name.replace(name, '').replace(/^, ?/, '') : ''
return {
class: v.class,
type: v.osm_type,
lat: v.lat,
lon: v.lon,
name,
address
}
})
} else {
this.addressList = []
}
this.addressList = nominatim.mapQueryResults(ret)
} else if (this.geocoding_provider_type == "Photon") {
let photon_properties = ['housenumber', 'street', 'district', 'city', 'county', 'state', 'postcode', 'country']
if (ret) {
this.addressList = ret.features.map(v => {
let pre_name = v.properties.name || v.properties.street || ''
let pre_address = ''
photon_properties.forEach((item, i) => {
let last = i == (photon_properties.length - 1)
if (v.properties[item] && !last) {
pre_address += v.properties[item]+', '
} else if (v.properties[item]) {
pre_address += v.properties[item]
}
});
let name = pre_name
let address = pre_address
return {
class: v.properties.osm_key,
type: v.properties.osm_type,
lat: v.geometry.coordinates[1],
lon: v.geometry.coordinates[0],
name,
address
}
})
} else {
this.addressList = []
}
this.addressList = photon.mapQueryResults(ret)
}
this.loading = false
}
}, 300)
}, 1000)
}
}
</script>

View File

@@ -56,6 +56,14 @@ v-container
inset
:label="$t('admin.allow_geolocation')")
v-switch.mt-1(v-model='allow_event_only_online'
inset
:label="$t('admin.allow_event_only_online')")
v-switch.mt-1(v-model='allow_event_also_online'
inset
:label="$t('admin.allow_event_also_online')")
v-dialog(v-model='showSMTP' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly')
SMTP(@close='showSMTP = false')
@@ -126,6 +134,18 @@ export default {
get () { return this.settings.allow_geolocation },
set (value) { this.setSetting({ key: 'allow_geolocation', value }) }
},
allow_event_only_online: {
get () { return this.settings.allow_event_only_online },
set (value) { this.setSetting({ key: 'allow_event_only_online', value })
if (value == true) { this.allow_event_also_online = value }
}
},
allow_event_also_online: {
get () { return this.settings.allow_event_also_online },
set (value) { this.setSetting({ key: 'allow_event_also_online', value })
if (value == false) { this.setSetting({ key: 'allow_event_only_online', value }) }
}
},
filteredTimezones () {
const current_timezone = moment.tz.guess()
tzNames.unshift(current_timezone)