gancio/components/admin/Places.vue

48 lines
1.1 KiB
Vue
Raw Normal View History

2019-07-27 22:07:08 +02:00
<template lang='pug'>
2020-07-25 21:41:22 +02:00
v-container
v-subheader(v-html="$t('admin.place_description')")
v-form.mb-2
//- el-form-item(:label="$t('common.name')")
//- el-input.mr-1(:placeholder='$t("common.name")' v-model='place.name')
v-text-field(
:label="$t('common.name')"
v-model='place.name'
:placeholder='$t("common.name")')
2019-09-13 10:15:23 +02:00
2020-07-25 21:41:22 +02:00
v-text-field(
:label="$t('common.address')"
v-model='place.address'
:placeholder='$t("common.address")')
2019-09-11 19:12:24 +02:00
2020-07-25 21:41:22 +02:00
v-btn(@click='savePlace') {{$t('common.save')}}
v-data-table(
:items='places')
2019-07-27 22:07:08 +02:00
</template>
<script>
import { mapState } from 'vuex'
2019-07-27 22:07:08 +02:00
export default {
2019-09-11 19:12:24 +02:00
data () {
return {
place: { name: '', address: '', id: null }
2019-07-27 22:07:08 +02:00
}
},
2020-07-25 21:41:22 +02:00
computed: mapState(['places']),
2019-07-27 22:07:08 +02:00
methods: {
2019-09-11 19:12:24 +02:00
placeSelected (items) {
if (items.length === 0) {
this.place.name = this.place.address = ''
return
}
const item = items[0]
this.place.name = item.name
this.place.address = item.address
this.place.id = item.id
},
2019-07-27 22:07:08 +02:00
async savePlace () {
2020-07-25 21:41:22 +02:00
await this.$axios.$put('/place', this.place)
2019-09-11 19:12:24 +02:00
}
2019-07-27 22:07:08 +02:00
}
}
</script>