2019-07-27 22:07:08 +02:00
|
|
|
<template lang='pug'>
|
|
|
|
div
|
|
|
|
p(v-html="$t('admin.place_description')")
|
2019-07-27 23:49:23 +02:00
|
|
|
el-form.mb-2(inline label-width='120px')
|
2019-07-27 22:07:08 +02:00
|
|
|
el-form-item(:label="$t('common.name')")
|
|
|
|
el-input.mr-1(:placeholder='$t("common.name")' v-model='place.name')
|
|
|
|
el-form-item(:label="$t('common.address')")
|
|
|
|
el-input.mr-1(:placeholder='$t("common.address")' v-model='place.address')
|
|
|
|
el-button(variant='primary' @click='savePlace') {{$t('common.save')}}
|
2019-07-27 23:49:23 +02:00
|
|
|
el-table(:data='paginatedPlaces' small)
|
2019-07-27 22:07:08 +02:00
|
|
|
el-table-column(:label="$t('common.name')")
|
|
|
|
template(slot-scope='data') {{data.row.name}}
|
|
|
|
el-table-column(:label="$t('common.address')")
|
|
|
|
template(slot-scope='data') {{data.row.address}}
|
2019-07-27 23:49:23 +02:00
|
|
|
el-table-column(:label="$t('common.actions')")
|
|
|
|
template(slot-scope='data')
|
|
|
|
el-button(size='mini'
|
|
|
|
type='success'
|
2019-09-11 19:12:24 +02:00
|
|
|
@click='place = data.row') {{$t('common.edit')}}
|
|
|
|
|
2019-09-06 11:55:38 +02:00
|
|
|
client-only
|
2019-07-27 22:07:08 +02:00
|
|
|
el-pagination(:page-size='perPage' :currentPage.sync='placePage' :total='places.length')
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
export default {
|
2019-09-11 19:12:24 +02:00
|
|
|
data () {
|
|
|
|
return {
|
2019-07-27 22:07:08 +02:00
|
|
|
perPage: 10,
|
|
|
|
placePage: 0,
|
2019-09-11 19:12:24 +02:00
|
|
|
place: { name: '', address: '', id: null }
|
2019-07-27 22:07:08 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(['places']),
|
|
|
|
paginatedPlaces () {
|
2019-09-11 19:12:24 +02:00
|
|
|
return this.places.slice((this.placePage - 1) * this.perPage,
|
2019-07-27 22:07:08 +02:00
|
|
|
this.placePage * this.perPage)
|
2019-09-11 19:12:24 +02:00
|
|
|
}
|
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 () {
|
|
|
|
const place = await this.$axios.$put('/place', this.place)
|
2019-09-11 19:12:24 +02:00
|
|
|
}
|
2019-07-27 22:07:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|