You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

  1. 'use strict'
  2. /* global usrData */
  3. 'use strict'
  4. import $ from 'jquery'
  5. import Vue from 'vue'
  6. // Vue Delete User instance
  7. module.exports = (alerts) => {
  8. let vueDeleteUser = new Vue({
  9. el: '#modal-admin-users-delete',
  10. data: {
  11. loading: false
  12. },
  13. methods: {
  14. open: (ev) => {
  15. $('#modal-admin-users-delete').addClass('is-active')
  16. },
  17. cancel: (ev) => {
  18. $('#modal-admin-users-delete').removeClass('is-active')
  19. },
  20. deleteUser: (ev) => {
  21. vueDeleteUser.loading = true
  22. $.ajax('/admin/users/' + usrData._id, {
  23. dataType: 'json',
  24. method: 'DELETE'
  25. }).then((rData, rStatus, rXHR) => {
  26. vueDeleteUser.loading = false
  27. vueDeleteUser.cancel()
  28. window.location.assign('/admin/users')
  29. }, (rXHR, rStatus, err) => {
  30. vueDeleteUser.loading = false
  31. alerts.pushError('Error', rXHR.responseJSON.msg)
  32. })
  33. }
  34. }
  35. })
  36. $('.btn-deluser-prompt').on('click', vueDeleteUser.open)
  37. }