improve admin, user management, confirmation, dialog
This commit is contained in:
58
components/admin/Events.vue
Normal file
58
components/admin/Events.vue
Normal file
@@ -0,0 +1,58 @@
|
||||
<template lang='pug'>
|
||||
v-container
|
||||
v-card-title {{$t('common.events')}}
|
||||
v-card-subtitle {{$t('admin.event_confirm_description')}}
|
||||
v-card-text
|
||||
v-data-table(
|
||||
:items='unconfirmedEvents'
|
||||
:headers='headers')
|
||||
template(v-slot:item.actions='{ item }')
|
||||
v-btn(text small @click.stop='toggle(item)'
|
||||
:color='item.visible?"warning":"success"') {{item.visible?$t('common.deactivate'):$t('common.activate')}}
|
||||
v-btn(text small @click='edit(item)') {{$t('common.edit')}}
|
||||
v-btn(text small @click='remove(item)'
|
||||
color='error') {{$t('common.delete')}}
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
unconfirmedEvents: { type: Array, default: () => [] }
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
valid: false,
|
||||
dialog: false,
|
||||
editing: false,
|
||||
headers: [
|
||||
{ value: 'title', text: 'Title' },
|
||||
{ value: 'actions', text: 'Actions', align: 'right' }
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
edit (event) {
|
||||
this.$router.push(`/add/${event.id}`)
|
||||
},
|
||||
async toggle (event) {
|
||||
try {
|
||||
event.is_visible = !event.is_visible
|
||||
await this.$axios.$put(`/event/${event.id}`, event)
|
||||
this.events = this.events.map(a => a.id === event.id ? event : a)
|
||||
this.setevents(cloneDeep(this.events.filter(a => a.visible)))
|
||||
} catch (e) {}
|
||||
},
|
||||
async remove (event) {
|
||||
const ret = await this.$root.$confirm(this.$t('common.confirm'),
|
||||
this.$t('event.remove_confirmation'))
|
||||
if (!ret) { return }
|
||||
await this.$axios.delete(`/event/${event.id}`)
|
||||
this.$root.$message({
|
||||
message: this.$t('admin.event_remove_ok')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -6,24 +6,24 @@
|
||||
append-icon='mdi-magnify'
|
||||
label='Search',
|
||||
single-line hide-details)
|
||||
v-btn(text color='primary' small @click='newUserDialog = true') <v-icon>mdi-plus-user</v-icon> {{$t('common.new_user')}}
|
||||
v-btn(color='primary' small @click='newUserDialog = true') <v-icon>mdi-plus</v-icon> {{$t('common.new_user')}}
|
||||
|
||||
//- ADD NEW USER
|
||||
v-dialog(v-model='newUserDialog' width='500')
|
||||
v-dialog(v-model='newUserDialog' :fullscreen="$vuetify.breakpoint.xsOnly")
|
||||
|
||||
v-card
|
||||
v-card-title {{$t('common.new_user')}}
|
||||
v-card-text
|
||||
v-form
|
||||
v-form(v-model='valid')
|
||||
v-text-field(v-model='new_user.email'
|
||||
:label="$t('common.email')"
|
||||
:rules="[$validators.required('email')]")
|
||||
:rules="$validators.email")
|
||||
v-switch(v-model='new_user.is_admin' :label="$t('common.admin')" inset)
|
||||
v-alert(type='info' :closable='false') {{$t('admin.user_add_help')}}
|
||||
v-card-actions
|
||||
v-spacer
|
||||
v-btn(@click='newUserDialog=false' color='error') {{$t('common.cancel')}}
|
||||
v-btn(@click='createUser' color='primary') {{$t('common.send')}}
|
||||
v-btn(@click='createUser' :disabled='!valid' color='primary') {{$t('common.send')}}
|
||||
|
||||
v-card-text
|
||||
//- USERS LIST
|
||||
@@ -51,6 +51,7 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
newUserDialog: false,
|
||||
valid: false,
|
||||
new_user: {
|
||||
email: '',
|
||||
is_admin: false
|
||||
@@ -66,9 +67,7 @@ export default {
|
||||
computed: mapState(['settings']),
|
||||
methods: {
|
||||
async deleteUser (user) {
|
||||
const ret = await this.$root.$confirm(this.$t('common.confirm'),
|
||||
this.$t('admin.delete_user_confirm'),
|
||||
{ type: 'error' })
|
||||
const ret = await this.$root.$confirm(this.$t('common.confirm'), this.$t('admin.delete_user_confirm'))
|
||||
if (!ret) { return }
|
||||
await this.$axios.delete(`/user/${user.id}`)
|
||||
this.$root.$message({ message: this.$t('admin.user_remove_ok') })
|
||||
|
||||
Reference in New Issue
Block a user