2019-07-27 22:07:08 +02:00
|
|
|
<template lang='pug'>
|
2022-06-11 12:00:29 +02:00
|
|
|
v-container
|
2022-09-07 11:48:19 +02:00
|
|
|
v-card-title {{ $t('common.places') }}
|
2022-06-11 12:00:29 +02:00
|
|
|
v-spacer
|
|
|
|
v-text-field(v-model='search'
|
|
|
|
:append-icon='mdiMagnify' outlined rounded
|
|
|
|
label='Search'
|
|
|
|
single-line hide-details)
|
|
|
|
v-card-subtitle(v-html="$t('admin.place_description')")
|
2019-09-13 10:15:23 +02:00
|
|
|
|
2022-06-11 12:00:29 +02:00
|
|
|
v-dialog(v-model='dialog' width='600' :fullscreen='$vuetify.breakpoint.xsOnly')
|
2022-09-07 11:48:19 +02:00
|
|
|
v-card
|
|
|
|
v-card-title {{ $t('admin.edit_place') }}
|
2022-06-11 12:00:29 +02:00
|
|
|
v-card-text
|
|
|
|
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")')
|
2019-09-11 19:12:24 +02:00
|
|
|
|
2022-06-11 12:00:29 +02:00
|
|
|
v-text-field(
|
|
|
|
:rules="[$validators.required('common.address')]"
|
|
|
|
:label="$t('common.address')"
|
|
|
|
v-model='place.address'
|
|
|
|
:placeholder='$t("common.address")')
|
2020-07-28 12:24:39 +02:00
|
|
|
|
2022-09-19 05:13:57 +02:00
|
|
|
v-text-field(v-if="settings.allow_geolocation"
|
|
|
|
:rules="[$validators.required('common.latitude')]"
|
|
|
|
:label="$t('common.latitude')"
|
|
|
|
v-model='place.latitude'
|
|
|
|
:placeholder='$t("common.latitude")')
|
|
|
|
|
|
|
|
v-text-field(v-if="settings.allow_geolocation"
|
|
|
|
:rules="[$validators.required('common.longitude')]"
|
|
|
|
:label="$t('common.longitude')"
|
|
|
|
v-model='place.longitude'
|
|
|
|
:placeholder='$t("common.longitude")')
|
|
|
|
|
2022-09-02 08:32:13 +02:00
|
|
|
|
2022-06-11 12:00:29 +02:00
|
|
|
v-card-actions
|
2022-09-07 11:48:19 +02:00
|
|
|
v-spacer
|
|
|
|
v-btn(@click='dialog = false' outlined color='warning') {{ $t('common.cancel') }}
|
|
|
|
v-btn(@click='savePlace' color='primary' outlined :loading='loading'
|
|
|
|
:disable='!valid || loading') {{ $t('common.save') }}
|
2020-07-25 21:41:22 +02:00
|
|
|
|
2022-06-11 12:00:29 +02:00
|
|
|
v-card-text
|
|
|
|
v-data-table(
|
|
|
|
:headers='headers'
|
|
|
|
:items='places'
|
2022-09-07 11:48:19 +02:00
|
|
|
:hide-default-footer='places.length < 5'
|
2022-06-11 12:00:29 +02:00
|
|
|
:footer-props='{ prevIcon: mdiChevronLeft, nextIcon: mdiChevronRight }'
|
|
|
|
:search='search')
|
2022-09-07 11:48:19 +02:00
|
|
|
template(v-slot:item.actions='{ item }')
|
2022-06-11 12:00:29 +02:00
|
|
|
v-btn(@click='editPlace(item)' color='primary' icon)
|
|
|
|
v-icon(v-text='mdiPencil')
|
2022-06-18 01:09:25 +02:00
|
|
|
nuxt-link(:to='`/place/${item.name}`')
|
2022-06-11 12:00:29 +02:00
|
|
|
v-icon(v-text='mdiEye')
|
2022-06-01 14:08:13 +02:00
|
|
|
|
2019-07-27 22:07:08 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2022-06-01 14:08:13 +02:00
|
|
|
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiEye } from '@mdi/js'
|
2022-09-02 08:32:13 +02:00
|
|
|
import { mapState } from 'vuex'
|
2022-02-08 14:45:19 +01:00
|
|
|
|
2019-07-27 22:07:08 +02:00
|
|
|
export default {
|
2022-09-07 11:48:19 +02:00
|
|
|
data() {
|
2019-09-11 19:12:24 +02:00
|
|
|
return {
|
2022-06-01 14:08:13 +02:00
|
|
|
mdiPencil, mdiChevronRight, mdiChevronLeft, mdiMagnify, mdiEye,
|
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,
|
2022-06-01 14:08:13 +02:00
|
|
|
places: [],
|
2022-03-07 16:39:02 +01:00
|
|
|
search: '',
|
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
|
|
|
}
|
|
|
|
},
|
2022-09-07 11:48:19 +02:00
|
|
|
async fetch() {
|
2022-06-01 14:08:13 +02:00
|
|
|
this.places = await this.$axios.$get('/place/all')
|
|
|
|
},
|
2022-09-02 08:32:13 +02:00
|
|
|
computed: {
|
|
|
|
...mapState(['settings']),
|
|
|
|
},
|
2019-07-27 22:07:08 +02:00
|
|
|
methods: {
|
2022-09-07 11:48:19 +02:00
|
|
|
editPlace(item) {
|
2019-09-11 19:12:24 +02:00
|
|
|
this.place.name = item.name
|
|
|
|
this.place.address = item.address
|
2022-09-08 20:37:20 +02:00
|
|
|
if (this.settings.allow_geolocation) {
|
2022-09-19 05:13:57 +02:00
|
|
|
this.place.latitude = item.latitude
|
|
|
|
this.place.longitude = item.longitude
|
2022-09-02 08:32:13 +02:00
|
|
|
}
|
2019-09-11 19:12:24 +02:00
|
|
|
this.place.id = item.id
|
2020-10-07 10:06:49 +02:00
|
|
|
this.dialog = true
|
2019-09-11 19:12:24 +02:00
|
|
|
},
|
2022-09-07 11:48:19 +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)
|
2022-06-07 21:10:17 +02:00
|
|
|
await this.$fetch()
|
2020-10-07 11:29:40 +02:00
|
|
|
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>
|