Add remove user action on dashboard
This commit is contained in:
@@ -18,12 +18,13 @@
|
||||
<v-btn small color="warning" @click="newForm">Baru</v-btn>
|
||||
<v-btn small color="primary" @click="saveUser">Simpan</v-btn>
|
||||
<v-btn small color="info" @click="resetPassword">Reset Password</v-btn>
|
||||
<v-btn small color="error" :disabled="!isEditMode" @click="removeUser">Hapus User</v-btn>
|
||||
</v-subheader>
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-layout row wrap class="pa-2">
|
||||
<v-flex xs12 pa-1>
|
||||
<v-text-field label="Username*" v-model="username"></v-text-field>
|
||||
<v-text-field label="Username*" :readonly="isEditMode" v-model="username"></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12 pa-1>
|
||||
<v-text-field label="Display Name" v-model="displayName"></v-text-field>
|
||||
@@ -75,6 +76,7 @@ module.exports = {
|
||||
},
|
||||
computed: {
|
||||
selectedUser() { return this.$store.state.dashboard_user.selected_user || {} },
|
||||
isEditMode() { return !!(this.selectedUser && this.selectedUser.User_ID) },
|
||||
assignedProjects() { return this.selectedUser.projects || [] },
|
||||
dialogsuccess() { return this.$store.state.dashboard_user.dialog_success },
|
||||
msgsuccess() { return this.$store.state.dashboard_user.msg_success },
|
||||
@@ -153,6 +155,22 @@ module.exports = {
|
||||
alert(resp.message || 'Gagal reset password')
|
||||
}
|
||||
},
|
||||
async removeUser() {
|
||||
if (!this.isEditMode || !this.username) {
|
||||
alert('Pilih user dulu')
|
||||
return
|
||||
}
|
||||
if (!window.confirm('Hapus user ini?')) return
|
||||
let resp = await this.$store.dispatch('dashboard_user/remove_user', {
|
||||
username: this.username
|
||||
})
|
||||
if (resp.status == 'OK') {
|
||||
this.newForm()
|
||||
this.refreshList()
|
||||
} else {
|
||||
alert(resp.message || 'Gagal hapus user')
|
||||
}
|
||||
},
|
||||
async assignProject() {
|
||||
if (!this.username) {
|
||||
alert('Pilih atau isi username dulu')
|
||||
|
||||
Reference in New Issue
Block a user