2019-10-22 01:02:47 +02:00
|
|
|
<template lang='pug'>
|
2020-01-30 12:37:19 +01:00
|
|
|
div
|
2019-10-22 01:02:47 +02:00
|
|
|
el-divider {{$t('common.admin')}}
|
2020-01-30 12:37:19 +01:00
|
|
|
el-menu.menu
|
|
|
|
el-menu-item
|
|
|
|
div(v-if='event.is_visible' @click='toggle(false)') <i class='el-icon-open'/> {{$t('common.hide')}}
|
|
|
|
div(v-else @click='toggle(false)') <i class='el-icon-turn-off'/> {{$t('common.confirm')}}
|
|
|
|
el-menu-item(@click='$router.replace(`/add/${event.id}`)') <i class='el-icon-edit'/> {{$t('common.edit')}}
|
2020-02-10 01:12:49 +01:00
|
|
|
el-menu-item(@click='remove(false)') <i class='el-icon-delete'/> {{$t('common.remove')}}
|
2020-01-30 12:37:19 +01:00
|
|
|
div(v-if='event.parentId')
|
|
|
|
el-divider {{$t('event.recurrent')}}
|
|
|
|
el-menu-item(v-if='event.parent.is_visible' @click='toggle(true)') <i class='el-icon-video-pause'/> {{$t('common.pause')}}
|
|
|
|
el-menu-item(v-else @click='toggle(true)') <i class='el-icon-video-play'/> {{$t('common.start')}}
|
|
|
|
el-menu-item(@click='$router.replace(`/add/${event.parentId}`)') <i class='el-icon-edit'/> {{$t('common.edit')}}
|
2020-02-09 18:17:19 +01:00
|
|
|
el-menu-item(@click='remove(true)') <i class='el-icon-delete'/> {{$t('common.remove')}}
|
2019-10-22 01:02:47 +02:00
|
|
|
</template>
|
|
|
|
<script>
|
2019-10-23 23:30:57 +02:00
|
|
|
import { MessageBox } from 'element-ui'
|
2019-10-24 15:19:48 +02:00
|
|
|
import { mapActions } from 'vuex'
|
2019-10-23 23:30:57 +02:00
|
|
|
|
2019-10-22 01:02:47 +02:00
|
|
|
export default {
|
|
|
|
name: 'EventAdmin',
|
2020-01-30 12:37:19 +01:00
|
|
|
props: {
|
|
|
|
event: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({})
|
|
|
|
}
|
|
|
|
},
|
2019-10-22 01:02:47 +02:00
|
|
|
methods: {
|
2019-10-24 15:19:48 +02:00
|
|
|
...mapActions(['delEvent']),
|
2020-01-30 12:37:19 +01:00
|
|
|
async remove (parent = false) {
|
2019-10-22 01:02:47 +02:00
|
|
|
try {
|
2020-02-10 01:12:49 +01:00
|
|
|
await MessageBox.confirm(this.$t(`event.remove_${parent ? 'recurrent_' : ''}confirmation`), this.$t('common.confirm'), {
|
2019-10-22 01:02:47 +02:00
|
|
|
confirmButtonText: this.$t('common.ok'),
|
|
|
|
cancelButtonText: this.$t('common.cancel'),
|
2020-01-30 12:37:19 +01:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
const id = parent ? this.event.parentId : this.event.id
|
2020-01-31 14:56:31 +01:00
|
|
|
await this.$axios.delete(`/event/${id}`)
|
2020-01-30 12:37:19 +01:00
|
|
|
this.delEvent(Number(id))
|
2019-10-22 01:02:47 +02:00
|
|
|
this.$router.replace('/')
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
},
|
2020-01-30 12:37:19 +01:00
|
|
|
async toggle (parent = false) {
|
|
|
|
const id = parent ? this.event.parentId : this.event.id
|
|
|
|
const is_visible = parent ? this.event.parent.is_visible : this.event.is_visible
|
|
|
|
const method = is_visible ? 'unconfirm' : 'confirm'
|
2019-10-22 01:02:47 +02:00
|
|
|
try {
|
2020-01-30 12:37:19 +01:00
|
|
|
await this.$axios.$get(`/event/${method}/${id}`)
|
|
|
|
if (parent) {
|
|
|
|
this.event.parent.is_visible = !is_visible
|
2019-10-22 01:02:47 +02:00
|
|
|
} else {
|
2020-01-30 12:37:19 +01:00
|
|
|
this.event.is_visible = !is_visible
|
2019-10-22 01:02:47 +02:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-28 17:33:20 +01:00
|
|
|
</script>
|