gancio-upstream/components/EventAdmin.vue

141 lines
4.9 KiB
Vue
Raw Normal View History

2019-10-22 01:02:47 +02:00
<template lang='pug'>
2022-11-21 13:21:32 +01:00
span
2023-03-28 21:54:06 +02:00
v-list(dense nav color='transparent')
2022-11-21 13:21:32 +01:00
v-list-group(:append-icon='mdiChevronUp' :value='true')
template(v-slot:activator)
2022-11-29 14:40:19 +01:00
v-list-item.text-overline {{$t('common.admin_actions')}}
2020-02-11 15:39:57 +01:00
2022-11-21 13:21:32 +01:00
//- Hide / confirm event
v-list-item(@click='toggle(false)')
v-list-item-icon
v-icon(v-if='event.is_visible' v-text='mdiEyeOff')
v-icon(v-else='event.is_visible' v-text='mdiEye')
v-list-item-content
v-list-item-title(v-text="$t(`common.${event.is_visible?(event.parentId?'skip':'hide'):'confirm'}`)")
2022-11-21 13:21:32 +01:00
//- Edit event
v-list-item(:to='`/add/${event.id}`')
v-list-item-icon
v-icon(v-text='mdiCalendarEdit')
v-list-item-content
v-list-item-title(v-text="$t('common.edit')")
2023-08-05 23:11:51 +02:00
//- Clone
v-list-item(v-if='!event.parentId' :to='`/add/${event.id}?clone=true`')
v-list-item-icon
v-icon(v-text='mdiScanner')
v-list-item-content
v-list-item-title(v-text="$t('common.clone')")
2022-11-21 13:21:32 +01:00
//- Remove
v-list-item(v-if='!event.parentId' @click='remove(false)')
2022-11-21 13:21:32 +01:00
v-list-item-icon
v-icon(v-text='mdiDelete')
v-list-item-content
v-list-item-title(v-text="$t('common.remove')")
//- Moderation
v-list-item(v-if='settings.enable_moderation' @click='$emit("openModeration")')
v-list-item-icon
v-icon(v-text='mdiMessageTextOutline')
v-list-item-content
v-list-item-title(v-text="$t('common.moderation')")
2022-11-21 13:21:32 +01:00
//- Disable author
2024-04-01 12:11:08 +02:00
v-list-item(v-if='settings.enable_moderation && !event.isAnon && $auth.user.is_admin' @click='disableAuthor')
v-list-item-icon
v-icon(v-text='mdiAccountOff')
v-list-item-content
v-list-item-title(v-text="$t('event.disable_author')")
v-list-item(v-if='event.isAnon && $auth?.user?.is_admin' @click='$emit("openAssignAuthor")')
v-list-item-icon
v-icon(v-text='mdiClipboardAccount')
v-list-item-content
v-list-item-title(v-text="$t('event.assign_to_user')")
2022-11-21 13:21:32 +01:00
template(v-if='event.parentId')
2022-11-29 14:40:19 +01:00
v-list-item.text-overline(v-html="$t('common.recurring_event_actions')")
2022-11-21 13:21:32 +01:00
//- Pause / Start to generate recurring event
v-list-item(@click='toggle(true)')
v-list-item-icon
v-icon(v-text='event.parent.is_visible ? mdiPause : mdiPlay')
v-list-item-content
v-list-item-title(v-text="$t(`common.${event.parent.is_visible ? 'pause': 'start'}`)")
//- Edit event
v-list-item(:to='`/add/${event.parentId}`')
v-list-item-icon
v-icon(v-text='mdiCalendarEdit')
v-list-item-content
v-list-item-title(v-text="$t('common.edit')")
//- Remove
v-list-item(@click='remove(true)')
v-list-item-icon
v-icon(v-text='mdiDeleteForever')
v-list-item-content
v-list-item-title(v-text="$t('common.remove')")
2023-11-21 01:39:18 +01:00
2019-10-22 01:02:47 +02:00
</template>
<script>
import { mdiChevronUp, mdiRepeat, mdiDelete, mdiCalendarEdit, mdiEyeOff, mdiEye, mdiPause, mdiPlay, mdiDeleteForever, mdiScanner,
mdiMessageTextOutline, mdiAccountOff, mdiClipboardAccount } from '@mdi/js'
2023-11-21 01:39:18 +01:00
import { mapState } from 'vuex'
2019-10-22 01:02:47 +02:00
export default {
name: 'EventAdmin',
data () {
2023-11-21 01:39:18 +01:00
return {
mdiChevronUp, mdiRepeat, mdiDelete, mdiCalendarEdit, mdiEyeOff, mdiEye, mdiPause, mdiPlay, mdiDeleteForever, mdiScanner,
mdiMessageTextOutline, mdiAccountOff, mdiClipboardAccount
2023-11-21 01:39:18 +01:00
}
},
props: {
event: {
type: Object,
default: () => ({})
2023-11-21 01:39:18 +01:00
},
},
computed: {
...mapState(['settings'])
},
2019-10-22 01:02:47 +02:00
methods: {
async disableAuthor () {
const ret = await this.$root.$confirm('event.disable_author_confirm')
if (!ret) { return }
try {
await this.$axios.$put(`/event/disable_author/${this.event.id}`)
this.$root.$message("Author disabled!", { color: 'success' })
this.event.isAnon = true
} catch (e) {
this.$root.$message(e, { color: 'warning' })
}
},
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)
}
2023-11-21 01:39:18 +01:00
},
2019-10-22 01:02:47 +02:00
}
}
2019-10-28 17:33:20 +01:00
</script>