refactor: admin-edit-user -> vue + fixes

This commit is contained in:
NGPixel
2017-06-09 22:33:33 -04:00
parent d590c67d50
commit 33c05b327b
8 changed files with 285 additions and 282 deletions

View File

@@ -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>