2017-05-30 01:58:33 +00:00
|
|
|
<template lang="pug">
|
|
|
|
transition(:duration="400")
|
|
|
|
.modal(v-show='isShown', v-cloak)
|
|
|
|
transition(name='modal-background')
|
|
|
|
.modal-background(v-show='isShown')
|
|
|
|
.modal-container
|
|
|
|
transition(name='modal-content')
|
|
|
|
.modal-content(v-show='isShown')
|
|
|
|
header.is-red
|
|
|
|
span {{ $t('modal.deleteusertitle') }}
|
|
|
|
p.modal-notify(v-bind:class='{ "is-active": isLoading }'): i
|
|
|
|
section
|
|
|
|
span {{ $t('modal.deleteuserwarning') }}
|
|
|
|
footer
|
2017-06-10 02:33:33 +00:00
|
|
|
a.button.is-grey.is-outlined(@click='cancel') {{ $t('modal.abort') }}
|
|
|
|
a.button.is-red(@click='deleteUser') {{ $t('modal.delete') }}
|
2017-05-30 01:58:33 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-06-10 02:33:33 +00:00
|
|
|
export default {
|
|
|
|
name: 'modal-delete-user',
|
|
|
|
props: ['currentUser'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isShown() {
|
|
|
|
return this.$store.state.modalDeleteUser.shown
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
cancel: function () {
|
|
|
|
this.isLoading = false
|
|
|
|
this.$store.dispatch('modalDeleteUser/close')
|
2017-05-30 01:58:33 +00:00
|
|
|
},
|
2017-06-10 02:33:33 +00:00
|
|
|
deleteUser: function () {
|
|
|
|
let self = this
|
|
|
|
this.isLoading = true
|
|
|
|
this.$http.delete('/admin/users/' + this.currentUser).then(resp => {
|
|
|
|
return resp.json()
|
|
|
|
}).then(resp => {
|
|
|
|
if (resp.ok) {
|
|
|
|
window.location.assign('/admin/users')
|
|
|
|
} else {
|
2017-05-30 01:58:33 +00:00
|
|
|
self.isLoading = false
|
|
|
|
self.$store.dispatch('alert', {
|
|
|
|
style: 'red',
|
|
|
|
icon: 'square-cross',
|
2017-06-10 02:33:33 +00:00
|
|
|
msg: resp.msg
|
2017-05-30 01:58:33 +00:00
|
|
|
})
|
2017-06-10 02:33:33 +00:00
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
self.isLoading = false
|
|
|
|
self.$store.dispatch('alert', {
|
|
|
|
style: 'red',
|
|
|
|
icon: 'square-cross',
|
|
|
|
msg: 'Error: ' + err.body.msg
|
2017-05-30 01:58:33 +00:00
|
|
|
})
|
2017-06-10 02:33:33 +00:00
|
|
|
})
|
2017-05-30 01:58:33 +00:00
|
|
|
}
|
|
|
|
}
|
2017-06-10 02:33:33 +00:00
|
|
|
}
|
2017-05-30 01:58:33 +00:00
|
|
|
</script>
|