Team rights update now have a dropdown
All checks were successful
the build was successful

This commit is contained in:
kolaente 2019-03-03 00:13:02 +01:00
parent 5325962ba6
commit 44765a588b
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 38 additions and 25 deletions

View File

@ -46,13 +46,13 @@
</router-link>
</td>
<td class="type">
<template v-if="t.right === 2">
<template v-if="t.right === rights.ADMIN">
<span class="icon is-small">
<icon icon="lock"/>
</span>
Admin
</template>
<template v-else-if="t.right === 1">
<template v-else-if="t.right === rights.READ_WRITE">
<span class="icon is-small">
<icon icon="pen"/>
</span>
@ -66,19 +66,17 @@
</template>
</td>
<td class="actions" v-if="userIsAdmin">
<button @click="toggleTeamType(t.id, (t.right === 2))" class="button buttonright is-primary">
Make
<template v-if="t.right === 2">
Member
</template>
<template v-else>
Admin
</template>
</button>
<button @click="teamStuffModel.teamID = t.id; showTeamDeleteModal = true" class="button is-danger">
<span class="icon is-small">
<icon icon="trash-alt"/>
</span>
<div class="select">
<select @change="teamStuffModel.teamID = t.id;toggleTeamType()" v-model="selectedRight" class="button buttonright">
<option :value="rights.READ" :selected="t.right === rights.READ">Read only</option>
<option :value="rights.READ_WRITE" :selected="t.right === rights.READ_WRITE">Read & write</option>
<option :value="rights.ADMIN" :selected="t.right === rights.ADMIN">Admin</option>
</select>
</div>
<button @click="teamStuffModel.teamID = t.id; showTeamDeleteModal = true" class="button is-danger icon-only">
<span class="icon is-small">
<icon icon="trash-alt"/>
</span>
</button>
</td>
</tr>
@ -109,6 +107,7 @@
import TeamListService from '../../services/teamList'
import TeamService from '../../services/team'
import TeamModel from '../../models/team'
import rights from '../../models/rights'
export default {
name: 'team',
@ -125,6 +124,8 @@
team: TeamModel,
foundTeams: [],
rights: rights,
selectedRight: rights.READ,
currentUser: auth.user.infos,
typeString: '',
@ -182,9 +183,9 @@
if(admin === null) {
admin = false
}
this.teamStuffModel.right = 0
this.teamStuffModel.right = rights.READ
if (admin) {
this.teamStuffModel.right = 2
this.teamStuffModel.right = rights.ADMIN
}
this.teamStuffModel.teamID = this.team.id
@ -198,12 +199,14 @@
message.error(e, this)
})
},
toggleTeamType(teamid, current) {
this.teamStuffModel.teamID = teamid
this.teamStuffModel.right = 0
if (!current) {
this.teamStuffModel.right = 2
toggleTeamType() {
if (this.selectedRight !== rights.ADMIN &&
this.selectedRight !== rights.READ &&
this.selectedRight !== rights.READ_WRITE
) {
this.selectedRight = rights.READ
}
this.teamStuffModel.right = this.selectedRight
this.teamStuffService.update(this.teamStuffModel)
.then(r => {
@ -258,7 +261,7 @@
}
td.type, td.actions{
width: 200px;
width: 250px;
}
td.actions{

5
src/models/rights.json Normal file
View File

@ -0,0 +1,5 @@
{
"READ": 0,
"READ_WRITE": 1,
"ADMIN": 2
}

View File

@ -28,6 +28,10 @@
box-shadow: 0.1em 0.1em 0.7em lighten($dark, 75) !important;
}
&.icon-only{
padding-left: 16px;
}
@each $name, $pair in $colors {
$color: nth($pair, 1);

View File

@ -105,10 +105,11 @@
* [x] Move everything to models
* [x] Make sure all loading properties are depending on its service
* [x] Fix the first request afer login being made with an old token
* [ ] Team sharing
* [x] Team sharing
* [x] Refactor team sharing to not make a new request every time something was changed
* [x] Team sharing should be able to search for a team instead of its ID, like it's the case with users
* [ ] Dropdown for rights
* [x] Dropdown for rights
* [ ] Same improvements also for user sharing
## Waiting for backend