Skip to content

Commit 1c44473

Browse files
committed
not allow to delete all roles from a user account
1 parent b6ab18d commit 1c44473

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

src/pages/userInvitation/UserInvitationUserGroupsTable.vue

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
v-for="(currentUserGroup, index) in store.invitationPayload
1515
.currentUserGroups"
1616
:key="index"
17+
class="h-[3.25rem]"
1718
>
1819
<TableCell>
1920
{{ currentUserGroup.name }}
@@ -39,21 +40,41 @@
3940
: t('invitation.masthead.hidden')
4041
}}
4142
</TableCell>
42-
<TableCell v-if="!currentUserGroup.dateEnd">
43-
<PkpButton
44-
:is-warnable="true"
45-
@click="removeUserGroup(currentUserGroup, index)"
46-
>
47-
{{ t('invitation.role.removeRole.button') }}
48-
</PkpButton>
49-
</TableCell>
50-
<TableCell v-else>
51-
<div
52-
class="rounded border-light bg-[#fbe7f1] px-2 py-2 text-center text-lg-semibold leading-5"
53-
>
54-
{{ t('invitation.removeRoles') }}
55-
</div>
56-
</TableCell>
43+
<template v-if="numberOfActiveRoles > 1">
44+
<template v-if="!currentUserGroup.dateEnd">
45+
<TableCell>
46+
<PkpButton
47+
:is-warnable="true"
48+
@click="removeUserGroup(currentUserGroup, index)"
49+
>
50+
{{ t('invitation.role.removeRole.button') }}
51+
</PkpButton>
52+
</TableCell>
53+
</template>
54+
<template v-else>
55+
<TableCell>
56+
<div
57+
class="rounded border-light bg-[#fbe7f1] px-2 py-2 text-center text-lg-semibold leading-5"
58+
>
59+
{{ t('invitation.removeRoles') }}
60+
</div>
61+
</TableCell>
62+
</template>
63+
</template>
64+
<template v-else>
65+
<template v-if="!currentUserGroup.dateEnd">
66+
<TableCell></TableCell>
67+
</template>
68+
<template v-else>
69+
<TableCell>
70+
<div
71+
class="rounded border-light bg-[#fbe7f1] px-2 py-2 text-center text-lg-semibold leading-5"
72+
>
73+
{{ t('invitation.removeRoles') }}
74+
</div>
75+
</TableCell>
76+
</template>
77+
</template>
5778
</TableRow>
5879
<template v-if="!store.invitationPayload.disabled">
5980
<TableRow
@@ -173,6 +194,7 @@ const allUserGroupsToAdd = computed(
173194
);
174195
updateWithSelectedUserGroups(props.userGroups);
175196
hasUserGroupsValue();
197+
console.log(store.invitationPayload.currentUserGroups);
176198
177199
/**
178200
* update selected user group
@@ -296,6 +318,15 @@ function updateWithSelectedUserGroups(userGroups) {
296318
});
297319
}
298320
321+
/**
322+
* count number of active roles
323+
*/
324+
const numberOfActiveRoles = computed(() => {
325+
return store.invitationPayload.currentUserGroups.filter(
326+
(userGroup) => userGroup.dateEnd === null,
327+
).length;
328+
});
329+
299330
/**
300331
* remove user roles
301332
* @param userId Number

0 commit comments

Comments
 (0)