Skip to content

Commit

Permalink
frontend/CollaboratorListItem.vue: disable dropdown and deactivate bu…
Browse files Browse the repository at this point in the history
…tton if not manager

But allow deactivating your own CampCollaboration, as long as
you are not the last manager.
Prohibit the removal of the last manager.

Issue: ecamp#1415
  • Loading branch information
BacLuc committed Jun 6, 2021
1 parent 3a49056 commit c2ee1d9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions frontend/src/components/camp/CollaboratorListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
:my="0"
dense
vee-rules="required"
:disabled="disabled" />
:disabled="disabled || isLastManager" />
</v-list-item-action>
<v-list-item-action class="ml-2">
<button-delete
v-if="!disabled"
:disabled="(disabled && !isOwnCampCollaboration) || isLastManager"
icon="mdi-cancel"
@click="api.del(collaborator)">
{{ $tc("components.camp.collaboratorListItem.deactivate") }}
Expand All @@ -67,6 +67,22 @@ export default {
data: () => ({
resendingEmail: false
}),
computed: {
isLastManager () {
const camp = this.collaborator.camp()
const isManager = this.collaborator.role === 'manager'
const lastManager = camp
?.campCollaborations()
?.items
?.filter(collaborator => collaborator.status === 'established')
.filter(collaborator => collaborator.role === 'manager')
.length <= 1
return isManager && lastManager
},
isOwnCampCollaboration () {
return this.api.get().profile().user().id === this.collaborator.user().id
}
},
methods: {
resendInvitation () {
this.resendingEmail = true
Expand Down

0 comments on commit c2ee1d9

Please sign in to comment.