refactor: admin-edit-user -> vue + fixes
This commit is contained in:
@@ -12,54 +12,54 @@
|
||||
section
|
||||
span {{ $t('modal.deleteuserwarning') }}
|
||||
footer
|
||||
a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('modal.abort') }}
|
||||
a.button.is-red(v-on:click='deleteUser') {{ $t('modal.delete') }}
|
||||
a.button.is-grey.is-outlined(@click='cancel') {{ $t('modal.abort') }}
|
||||
a.button.is-red(@click='deleteUser') {{ $t('modal.delete') }}
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'modal-delete-user',
|
||||
props: ['currentUser'],
|
||||
data () {
|
||||
return {
|
||||
isLoading: false
|
||||
}
|
||||
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')
|
||||
},
|
||||
computed: {
|
||||
isShown () {
|
||||
return this.$store.state.modalDeleteUser.shown
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cancel: function () {
|
||||
this.isLoading = false
|
||||
this.$store.dispatch('modalDeleteUser/close')
|
||||
},
|
||||
discard: 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 {
|
||||
self.isLoading = false
|
||||
self.$store.dispatch('alert', {
|
||||
style: 'red',
|
||||
icon: 'square-cross',
|
||||
msg: resp.msg
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
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 {
|
||||
self.isLoading = false
|
||||
self.$store.dispatch('alert', {
|
||||
style: 'red',
|
||||
icon: 'square-cross',
|
||||
msg: 'Error: ' + err.body.msg
|
||||
msg: resp.msg
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
self.isLoading = false
|
||||
self.$store.dispatch('alert', {
|
||||
style: 'red',
|
||||
icon: 'square-cross',
|
||||
msg: 'Error: ' + err.body.msg
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user