1
0

Hide UI elements if the user does not have the right to use them (#211)

Hide Team UI elements if the user does not have the rights to use them

Fix replacing the right saved in the model when updating

Hide UI-Elements on task if the user does not have the rights to use them

Hide UI-Elements on gantt if the user does not have the rights to use them

Hide UI-Elements on kanban if the user does not have rights to use them

Fix canWrite condition

Hide list components if the user has no right to write to the list

Add max right to model

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/211
This commit is contained in:
konrad
2020-08-11 18:18:59 +00:00
parent e64b4e3329
commit 3c07c6e8c0
22 changed files with 282 additions and 132 deletions

View File

@ -61,7 +61,6 @@
</div>
</div>
<div class="card is-fullwidth">
<header class="card-header">
<p class="card-header-title">
Team Members
@ -188,6 +187,7 @@
import UserService from '../../services/user'
import LoadingComponent from '../../components/misc/loading'
import ErrorComponent from '../../components/misc/error'
import Rights from '../../models/rights.json'
export default {
name: 'EditTeam',
@ -201,7 +201,6 @@
showDeleteModal: false,
showUserDeleteModal: false,
userIsAdmin: false,
newMember: UserModel,
foundUsers: [],
@ -234,9 +233,14 @@
// call again the method if the route changes
'$route': 'loadTeam',
},
computed: mapState({
userInfo: state => state.auth.info,
}),
computed: {
userIsAdmin() {
return this.team && this.team.maxRight && this.team.maxRight > Rights.READ
},
...mapState({
userInfo: state => state.auth.info,
}),
},
methods: {
loadTeam() {
this.team = new TeamModel({id: this.teamId})
@ -244,13 +248,6 @@
.then(response => {
this.$set(this, 'team', response)
this.setTitle(`Edit Team ${this.team.name}`)
let members = response.members
for (const m in members) {
members[m].teamId = this.teamId
if (members[m].id === this.userInfo.id && members[m].admin) {
this.userIsAdmin = true
}
}
})
.catch(e => {
this.error(e, this)
@ -313,7 +310,7 @@
member.admin = !member.admin
this.teamMemberService.update(member)
.then(r => {
for(const tm in this.team.members) {
for (const tm in this.team.members) {
if (this.team.members[tm].id === member.id) {
this.$set(this.team.members[tm], 'admin', r.admin)
break
@ -357,5 +354,9 @@
.team-members {
padding: 0;
.table {
border-top: 0;
}
}
</style>