wikijs-fork/client/js/modals/admin-users-delete.js

35 lines
882 B
JavaScript
Raw Normal View History

2017-02-10 18:13:40 +00:00
/* global $, Vue, usrData, alerts */
// Vue Delete User instance
let vueDeleteUser = new Vue({
2017-02-09 01:52:37 +00:00
el: '#modal-admin-users-delete',
data: {
2017-02-10 18:13:40 +00:00
loading: false
2017-02-09 01:52:37 +00:00
},
methods: {
open: (ev) => {
$('#modal-admin-users-delete').addClass('is-active')
},
cancel: (ev) => {
$('#modal-admin-users-delete').removeClass('is-active')
},
deleteUser: (ev) => {
2017-02-10 18:13:40 +00:00
vueDeleteUser.loading = true
$.ajax('/admin/users/' + usrData._id, {
dataType: 'json',
method: 'DELETE'
}).then((rData, rStatus, rXHR) => {
vueDeleteUser.loading = false
vueDeleteUser.cancel()
window.location.assign('/admin/users')
}, (rXHR, rStatus, err) => {
vueDeleteUser.loading = false
alerts.pushError('Error', rXHR.responseJSON.msg)
})
2017-02-09 01:52:37 +00:00
}
}
})
2017-02-09 01:52:37 +00:00
$('.btn-deluser-prompt').on('click', vueDeleteUser.open)