2017-04-01 21:07:01 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
/* global usrData */
|
|
|
|
|
|
|
|
'use strict'
|
|
|
|
|
|
|
|
import $ from 'jquery'
|
|
|
|
import Vue from 'vue'
|
2017-01-06 04:19:29 +00:00
|
|
|
|
|
|
|
// Vue Delete User instance
|
|
|
|
|
2017-04-01 21:07:01 +00:00
|
|
|
module.exports = (alerts) => {
|
|
|
|
let vueDeleteUser = new Vue({
|
|
|
|
el: '#modal-admin-users-delete',
|
|
|
|
data: {
|
|
|
|
loading: false
|
2017-02-09 01:52:37 +00:00
|
|
|
},
|
2017-04-01 21:07:01 +00:00
|
|
|
methods: {
|
|
|
|
open: (ev) => {
|
|
|
|
$('#modal-admin-users-delete').addClass('is-active')
|
|
|
|
},
|
|
|
|
cancel: (ev) => {
|
|
|
|
$('#modal-admin-users-delete').removeClass('is-active')
|
|
|
|
},
|
|
|
|
deleteUser: (ev) => {
|
|
|
|
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-04-01 21:07:01 +00:00
|
|
|
})
|
2017-01-06 04:19:29 +00:00
|
|
|
|
2017-04-01 21:07:01 +00:00
|
|
|
$('.btn-deluser-prompt').on('click', vueDeleteUser.open)
|
|
|
|
}
|