2019-07-27 22:07:08 +02:00
|
|
|
<template lang='pug'>
|
2020-07-25 21:41:22 +02:00
|
|
|
v-container
|
2020-08-05 17:30:41 +02:00
|
|
|
v-card-title {{$t('common.places')}}
|
|
|
|
v-card-subtitle(v-html="$t('admin.place_description')")
|
2019-09-13 10:15:23 +02:00
|
|
|
|
2021-12-02 11:14:53 +01:00
|
|
|
v-dialog(v-model='dialog' width='600' :fullscreen='$vuetify.breakpoint.xsOnly')
|
2020-10-09 00:42:03 +02:00
|
|
|
v-card(color='secondary')
|
2020-10-07 10:06:49 +02:00
|
|
|
v-card-title {{$t('admin.edit_place')}}
|
|
|
|
v-card-text
|
2020-10-09 00:42:03 +02:00
|
|
|
v-form(v-model='valid' ref='form' lazy-validation)
|
2020-10-07 10:06:49 +02:00
|
|
|
v-text-field(
|
2020-10-09 00:42:03 +02:00
|
|
|
:rules="[$validators.required('common.name')]"
|
2020-10-07 10:06:49 +02:00
|
|
|
:label="$t('common.name')"
|
|
|
|
v-model='place.name'
|
|
|
|
:placeholder='$t("common.name")')
|
2019-09-11 19:12:24 +02:00
|
|
|
|
2020-10-07 10:06:49 +02:00
|
|
|
v-text-field(
|
2020-10-09 00:42:03 +02:00
|
|
|
:rules="[$validators.required('common.address')]"
|
2020-10-07 10:06:49 +02:00
|
|
|
:label="$t('common.address')"
|
|
|
|
v-model='place.address'
|
|
|
|
:placeholder='$t("common.address")')
|
2020-07-28 12:24:39 +02:00
|
|
|
|
2020-10-07 10:06:49 +02:00
|
|
|
v-card-actions
|
|
|
|
v-spacer
|
|
|
|
v-btn(@click='dialog=false' color='warning') {{$t('common.cancel')}}
|
2020-10-09 00:42:03 +02:00
|
|
|
v-btn(@click='savePlace' color='primary' :loading='loading'
|
|
|
|
:disable='!valid || loading') {{$t('common.save')}}
|
2020-07-25 21:41:22 +02:00
|
|
|
|
2020-08-05 17:30:41 +02:00
|
|
|
v-card-text
|
|
|
|
v-data-table(
|
|
|
|
:headers='headers'
|
|
|
|
:items='places')
|
2020-10-07 10:06:49 +02:00
|
|
|
template(v-slot:item.actions='{item}')
|
|
|
|
v-btn(@click='editPlace(item)' color='primary' icon)
|
2022-02-08 14:45:19 +01:00
|
|
|
v-icon(v-text='mdiPencil')
|
2019-07-27 22:07:08 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2020-10-07 11:29:40 +02:00
|
|
|
import { mapState, mapActions } from 'vuex'
|
2022-02-08 14:45:19 +01:00
|
|
|
import { mdiPencil } from '@mdi/js'
|
|
|
|
|
2019-07-27 22:07:08 +02:00
|
|
|
export default {
|
2019-09-11 19:12:24 +02:00
|
|
|
data () {
|
|
|
|
return {
|
2022-02-08 14:45:19 +01:00
|
|
|
mdiPencil,
|
2020-10-07 11:29:40 +02:00
|
|
|
loading: false,
|
2020-10-07 10:06:49 +02:00
|
|
|
dialog: false,
|
2020-10-09 00:42:03 +02:00
|
|
|
valid: false,
|
2020-07-28 12:24:39 +02:00
|
|
|
place: { name: '', address: '', id: null },
|
|
|
|
headers: [
|
2020-10-07 10:06:49 +02:00
|
|
|
{ value: 'name', text: 'Name' },
|
|
|
|
{ value: 'address', text: 'Address' },
|
|
|
|
{ value: 'actions', text: 'Actions', align: 'right' }
|
2020-07-28 12:24:39 +02:00
|
|
|
]
|
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: {
|
2020-10-07 11:29:40 +02:00
|
|
|
...mapActions(['updateMeta']),
|
2020-10-07 10:06:49 +02:00
|
|
|
editPlace (item) {
|
2019-09-11 19:12:24 +02:00
|
|
|
this.place.name = item.name
|
|
|
|
this.place.address = item.address
|
|
|
|
this.place.id = item.id
|
2020-10-07 10:06:49 +02:00
|
|
|
this.dialog = true
|
2019-09-11 19:12:24 +02:00
|
|
|
},
|
2019-07-27 22:07:08 +02:00
|
|
|
async savePlace () {
|
2020-10-09 00:42:03 +02:00
|
|
|
if (!this.$refs.form.validate()) return
|
2020-10-07 11:29:40 +02:00
|
|
|
this.loading = true
|
2020-07-25 21:41:22 +02:00
|
|
|
await this.$axios.$put('/place', this.place)
|
2020-10-07 11:29:40 +02:00
|
|
|
this.updateMeta()
|
|
|
|
this.loading = false
|
2020-10-07 10:06:49 +02:00
|
|
|
this.dialog = false
|
2019-09-11 19:12:24 +02:00
|
|
|
}
|
2019-07-27 22:07:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|