|
14 | 14 | v-for="(currentUserGroup, index) in store.invitationPayload |
15 | 15 | .currentUserGroups" |
16 | 16 | :key="index" |
| 17 | + class="h-[3.25rem]" |
17 | 18 | > |
18 | 19 | <TableCell> |
19 | 20 | {{ currentUserGroup.name }} |
|
39 | 40 | : t('invitation.masthead.hidden') |
40 | 41 | }} |
41 | 42 | </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> |
57 | 78 | </TableRow> |
58 | 79 | <template v-if="!store.invitationPayload.disabled"> |
59 | 80 | <TableRow |
@@ -173,6 +194,7 @@ const allUserGroupsToAdd = computed( |
173 | 194 | ); |
174 | 195 | updateWithSelectedUserGroups(props.userGroups); |
175 | 196 | hasUserGroupsValue(); |
| 197 | +console.log(store.invitationPayload.currentUserGroups); |
176 | 198 |
|
177 | 199 | /** |
178 | 200 | * update selected user group |
@@ -296,6 +318,15 @@ function updateWithSelectedUserGroups(userGroups) { |
296 | 318 | }); |
297 | 319 | } |
298 | 320 |
|
| 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 | +
|
299 | 330 | /** |
300 | 331 | * remove user roles |
301 | 332 | * @param userId Number |
|
0 commit comments