gancio/pages/event/eventAdmin.vue

52 lines
1.9 KiB
Vue
Raw Normal View History

2019-10-22 01:02:47 +02:00
<template lang='pug'>
div
2020-07-28 12:24:39 +02:00
v-btn(text color='primary' v-if='event.is_visible' @click='toggle(false)') {{$t(`common.${event.parentId?'skip':'hide'}`)}}
2021-02-09 12:15:22 +01:00
v-btn(text color='success' v-else @click='toggle(false)') <v-icon color='yellow'>mdi-alert</v-icon> {{$t('common.confirm')}}
2020-07-28 12:24:39 +02:00
v-btn(text color='primary' @click='$router.push(`/add/${event.id}`)') {{$t('common.edit')}}
v-btn(text color='primary' v-if='!event.parentId' @click='remove(false)') {{$t('common.remove')}}
2020-02-11 15:39:57 +01:00
2020-07-28 12:24:39 +02:00
template(v-if='event.parentId')
2021-01-22 23:08:10 +01:00
v-divider
span.mr-1 <v-icon>mdi-repeat</v-icon> {{$t('event.edit_recurrent')}}
2020-07-28 12:24:39 +02:00
v-btn(text color='primary' v-if='event.parent.is_visible' @click='toggle(true)') {{$t('common.pause')}}
v-btn(text color='primary' v-else @click='toggle(true)') {{$t('common.start')}}
v-btn(text color='primary' @click='$router.push(`/add/${event.parentId}`)') {{$t('common.edit')}}
v-btn(text color='primary' @click='remove(true)') {{$t('common.remove')}}
2019-10-22 01:02:47 +02:00
</template>
<script>
2019-10-23 23:30:57 +02:00
2019-10-22 01:02:47 +02:00
export default {
name: 'EventAdmin',
props: {
event: {
type: Object,
default: () => ({})
}
},
2019-10-22 01:02:47 +02:00
methods: {
async remove (parent = false) {
2020-10-07 13:05:19 +02:00
const ret = await this.$root.$confirm(`event.remove_${parent ? 'recurrent_' : ''}confirmation`)
2020-07-28 12:24:39 +02:00
if (!ret) { return }
const id = parent ? this.event.parentId : this.event.id
await this.$axios.delete(`/event/${id}`)
this.$router.replace('/')
2019-10-22 01:02:47 +02: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-10-28 01:30:37 +01:00
await this.$axios.$put(`/event/${method}/${id}`)
if (parent) {
this.event.parent.is_visible = !is_visible
2019-10-22 01:02:47 +02:00
} else {
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>