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.

65 lines
1.8 KiB

  1. <template lang="pug">
  2. transition(:duration="400")
  3. .modal(v-show='isShown', v-cloak)
  4. transition(name='modal-background')
  5. .modal-background(v-show='isShown')
  6. .modal-container
  7. transition(name='modal-content')
  8. .modal-content(v-show='isShown')
  9. header.is-red
  10. span {{ $t('modal.deleteusertitle') }}
  11. p.modal-notify(v-bind:class='{ "is-active": isLoading }'): i
  12. section
  13. span {{ $t('modal.deleteuserwarning') }}
  14. footer
  15. a.button.is-grey.is-outlined(@click='cancel') {{ $t('modal.abort') }}
  16. a.button.is-red(@click='deleteUser') {{ $t('modal.delete') }}
  17. </template>
  18. <script>
  19. export default {
  20. name: 'modal-delete-user',
  21. props: ['currentUser'],
  22. data() {
  23. return {
  24. isLoading: false
  25. }
  26. },
  27. computed: {
  28. isShown() {
  29. return this.$store.state.modalDeleteUser.shown
  30. }
  31. },
  32. methods: {
  33. cancel: function () {
  34. this.isLoading = false
  35. this.$store.dispatch('modalDeleteUser/close')
  36. },
  37. deleteUser: function () {
  38. let self = this
  39. this.isLoading = true
  40. this.$http.delete('/admin/users/' + this.currentUser).then(resp => {
  41. return resp.json()
  42. }).then(resp => {
  43. if (resp.ok) {
  44. window.location.assign('/admin/users')
  45. } else {
  46. self.isLoading = false
  47. self.$store.dispatch('alert', {
  48. style: 'red',
  49. icon: 'ui-2_square-remove-09',
  50. msg: resp.msg
  51. })
  52. }
  53. }).catch(err => {
  54. self.isLoading = false
  55. self.$store.dispatch('alert', {
  56. style: 'red',
  57. icon: 'ui-2_square-remove-09',
  58. msg: 'Error: ' + err.body.msg
  59. })
  60. })
  61. }
  62. }
  63. }
  64. </script>