2020-10-25 00:31:38 +02:00
|
|
|
<template lang="pug">
|
|
|
|
v-row
|
|
|
|
v-combobox.col-md-6(ref='place'
|
|
|
|
:rules="[$validators.required('common.where')]"
|
|
|
|
:label="$t('common.where')"
|
|
|
|
:hint="$t('event.where_description')"
|
|
|
|
:hide-no-data="!place._name"
|
|
|
|
:search-input.sync="place._name"
|
2020-11-04 10:55:30 +01:00
|
|
|
prepend-icon='mdi-map-marker'
|
2020-10-25 00:31:38 +02:00
|
|
|
persistent-hint
|
2020-10-28 01:30:37 +01:00
|
|
|
:value="value.name"
|
2020-10-25 00:31:38 +02:00
|
|
|
:items="places"
|
|
|
|
item-text='name'
|
|
|
|
@change='selectPlace')
|
|
|
|
template(v-slot:no-data)
|
2020-11-04 10:55:30 +01:00
|
|
|
v-list-item(@click='createPlace')
|
|
|
|
v-list-item-content Create {{place._name}}
|
2020-10-25 00:31:38 +02:00
|
|
|
|
|
|
|
v-text-field.col-md-6(ref='address'
|
2020-11-04 10:55:30 +01:00
|
|
|
prepend-icon='mdi-map'
|
2020-10-25 00:31:38 +02:00
|
|
|
:disabled='disableAddress'
|
|
|
|
:rules="[$validators.required('common.address')]"
|
|
|
|
:label="$t('common.address')"
|
|
|
|
@change="changeAddress"
|
2020-10-27 11:56:47 +01:00
|
|
|
:value="value.address")
|
2020-10-25 00:31:38 +02:00
|
|
|
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'WhereInput',
|
2020-10-27 11:56:47 +01:00
|
|
|
props: {
|
|
|
|
value: { type: Object, default: () => {} }
|
|
|
|
},
|
2020-10-25 00:31:38 +02:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
place: { _name: '' },
|
|
|
|
disableAddress: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(['places'])
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
selectPlace (p) {
|
2020-11-04 10:55:30 +01:00
|
|
|
if (typeof p === 'object') {
|
|
|
|
if (p === null) { return }
|
2020-10-25 00:31:38 +02:00
|
|
|
this.place.name = p.name
|
2020-11-04 10:55:30 +01:00
|
|
|
this.place.address = p.address
|
2020-10-25 00:31:38 +02:00
|
|
|
this.disableAddress = true
|
2020-11-04 10:55:30 +01:00
|
|
|
} else { // this is a new place
|
|
|
|
this.place.name = p
|
2020-10-25 00:31:38 +02:00
|
|
|
this.disableAddress = false
|
|
|
|
this.$refs.place.blur()
|
|
|
|
this.$refs.address.focus()
|
|
|
|
}
|
2020-11-04 10:55:30 +01:00
|
|
|
this.$emit('input', { ...this.place })
|
2020-10-25 00:31:38 +02:00
|
|
|
},
|
|
|
|
changeAddress (v) {
|
|
|
|
this.place.address = v
|
2020-11-04 10:55:30 +01:00
|
|
|
this.$emit('input', { ...this.place })
|
|
|
|
},
|
|
|
|
createPlace (v) {
|
|
|
|
this.$refs.place.blur()
|
|
|
|
this.$refs.address.focus()
|
2020-10-25 00:31:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|