From 56b73ffa4675b79e11796799167b157b67b42651 Mon Sep 17 00:00:00 2001 From: BacLuc Date: Sun, 6 Jun 2021 17:03:20 +0200 Subject: [PATCH] frontend/CollaboratorListItem.vue: disable dropdown and deactivate button for last manager But allow deactivating your own CampCollaboration, as long as you are not the last manager. Issue: #1415 --- .../components/camp/CollaboratorListItem.vue | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/camp/CollaboratorListItem.vue b/frontend/src/components/camp/CollaboratorListItem.vue index fdea051a8ad..838bc13c7fc 100644 --- a/frontend/src/components/camp/CollaboratorListItem.vue +++ b/frontend/src/components/camp/CollaboratorListItem.vue @@ -38,11 +38,11 @@ :my="0" dense vee-rules="required" - :disabled="disabled" /> + :disabled="disabled || isLastManager" /> {{ $tc("components.camp.collaboratorListItem.deactivate") }} @@ -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