Added functions to manage users on a list
This commit is contained in:
parent
0a9296243b
commit
8c1d44ae50
1 changed files with 33 additions and 3 deletions
|
@ -91,9 +91,9 @@
|
||||||
</template>
|
</template>
|
||||||
</td>
|
</td>
|
||||||
<td class="actions" v-if="userIsAdmin">
|
<td class="actions" v-if="userIsAdmin">
|
||||||
<button @click="toggleUserType(u.id, u.admin)" class="button buttonright is-primary" v-if="u.id !== user.infos.id">
|
<button @click="toggleUserType(u.id, (u.right === 2))" class="button buttonright is-primary" v-if="u.id !== user.infos.id">
|
||||||
Make
|
Make
|
||||||
<template v-if="!u.admin">
|
<template v-if="u.right === 2">
|
||||||
Admin
|
Admin
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
@ -120,6 +120,17 @@
|
||||||
<p slot="text">Are you sure you want to delete this list and all of its contents?
|
<p slot="text">Are you sure you want to delete this list and all of its contents?
|
||||||
<br/>This includes all tasks and <b>CANNOT BE UNDONE!</b></p>
|
<br/>This includes all tasks and <b>CANNOT BE UNDONE!</b></p>
|
||||||
</modal>
|
</modal>
|
||||||
|
|
||||||
|
<!-- User delete modal -->
|
||||||
|
<modal
|
||||||
|
v-if="showUserDeleteModal"
|
||||||
|
@close="showUserDeleteModal = false"
|
||||||
|
v-on:submit="deleteUser()">
|
||||||
|
<span slot="header">Remove a user from the team</span>
|
||||||
|
<p slot="text">Are you sure you want to remove this user from the team?<br/>
|
||||||
|
He will loose access to all lists and namespaces this team has access to.<br/>
|
||||||
|
<b>This CANNOT BE UNDONE!</b></p>
|
||||||
|
</modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -140,7 +151,9 @@
|
||||||
listUsers: [],
|
listUsers: [],
|
||||||
user: auth.user,
|
user: auth.user,
|
||||||
userIsAdmin: false,
|
userIsAdmin: false,
|
||||||
newUser: {user_id: 0}
|
newUser: {user_id: 0},
|
||||||
|
showUserDeleteModal: false,
|
||||||
|
userToDelete: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
|
@ -214,6 +227,17 @@
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
deleteUser() {
|
||||||
|
HTTP.delete(`lists/` + this.$route.params.id + `/users/` + this.userToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
|
.then(() => {
|
||||||
|
this.showUserDeleteModal = false;
|
||||||
|
this.handleSuccess({message: 'The user was successfully deleted from the list.'})
|
||||||
|
this.loadUsers()
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
this.handleError(e)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
addUser(admin) {
|
addUser(admin) {
|
||||||
if(admin === null) {
|
if(admin === null) {
|
||||||
|
@ -233,6 +257,12 @@
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
toggleUserType(userid, current) {
|
||||||
|
this.userToDelete = userid
|
||||||
|
this.newUser.user_id = userid
|
||||||
|
this.deleteUser()
|
||||||
|
this.addUser(!current)
|
||||||
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
|
|
Loading…
Reference in a new issue