| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-container> | 
					
						
							|  |  |  |     <BasePageTitle divider> | 
					
						
							|  |  |  |       <template #header> | 
					
						
							|  |  |  |         <v-img max-height="125" max-width="125" :src="require('~/static/svgs/manage-members.svg')"></v-img> | 
					
						
							|  |  |  |       </template> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |       <template #title> {{ $t('group.manage-members') }} </template> | 
					
						
							|  |  |  |         <i18n path="group.manage-members-description"> | 
					
						
							|  |  |  |           <template #manage> | 
					
						
							|  |  |  |             <b>{{ $t('group.manage') }}</b> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |           <template #invite> | 
					
						
							|  |  |  |             <b>{{ $t('group.invite') }}</b> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |         </i18n> | 
					
						
							| 
									
										
										
										
											2023-10-07 21:36:47 +02:00
										 |  |  |         <v-container class="mt-1 px-0"> | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |         <nuxt-link class="text-center" :to="`/user/profile/edit`"> {{ $t('group.looking-to-update-your-profile') }} </nuxt-link> | 
					
						
							| 
									
										
										
										
											2023-10-07 21:36:47 +02:00
										 |  |  |       </v-container> | 
					
						
							|  |  |  |       </BasePageTitle> | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |     <v-data-table | 
					
						
							|  |  |  |       :headers="headers" | 
					
						
							|  |  |  |       :items="members || []" | 
					
						
							|  |  |  |       item-key="id" | 
					
						
							|  |  |  |       class="elevation-0" | 
					
						
							|  |  |  |       hide-default-footer | 
					
						
							|  |  |  |       disable-pagination | 
					
						
							|  |  |  |     > | 
					
						
							| 
									
										
										
										
											2021-12-18 19:04:36 -09:00
										 |  |  |       <template #item.avatar="{ item }"> | 
					
						
							|  |  |  |         <UserAvatar :user-id="item.id" /> | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |       </template> | 
					
						
							|  |  |  |       <template #item.admin="{ item }"> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         {{ item.admin ? $t('user.admin') : $t('user.user') }} | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |       </template> | 
					
						
							|  |  |  |       <template #item.manage="{ item }"> | 
					
						
							|  |  |  |         <div class="d-flex justify-center"> | 
					
						
							|  |  |  |           <v-checkbox | 
					
						
							|  |  |  |             v-model="item.canManage" | 
					
						
							|  |  |  |             :disabled="item.id === $auth.user.id || item.admin" | 
					
						
							|  |  |  |             class="" | 
					
						
							|  |  |  |             style="max-width: 30px" | 
					
						
							|  |  |  |             @change="setPermissions(item)" | 
					
						
							|  |  |  |           ></v-checkbox> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </template> | 
					
						
							|  |  |  |       <template #item.organize="{ item }"> | 
					
						
							|  |  |  |         <div class="d-flex justify-center"> | 
					
						
							|  |  |  |           <v-checkbox | 
					
						
							|  |  |  |             v-model="item.canOrganize" | 
					
						
							|  |  |  |             :disabled="item.id === $auth.user.id || item.admin" | 
					
						
							|  |  |  |             class="" | 
					
						
							|  |  |  |             style="max-width: 30px" | 
					
						
							|  |  |  |             @change="setPermissions(item)" | 
					
						
							|  |  |  |           ></v-checkbox> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </template> | 
					
						
							|  |  |  |       <template #item.invite="{ item }"> | 
					
						
							|  |  |  |         <div class="d-flex justify-center"> | 
					
						
							|  |  |  |           <v-checkbox | 
					
						
							|  |  |  |             v-model="item.canInvite" | 
					
						
							|  |  |  |             :disabled="item.id === $auth.user.id || item.admin" | 
					
						
							|  |  |  |             class="" | 
					
						
							|  |  |  |             style="max-width: 30px" | 
					
						
							|  |  |  |             @change="setPermissions(item)" | 
					
						
							|  |  |  |           ></v-checkbox> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </template> | 
					
						
							|  |  |  |     </v-data-table> | 
					
						
							|  |  |  |   </v-container> | 
					
						
							|  |  |  | </template> | 
					
						
							| 
									
										
										
										
											2022-03-23 04:54:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  | <script lang="ts"> | 
					
						
							|  |  |  | import { defineComponent, ref, onMounted, useContext } from "@nuxtjs/composition-api"; | 
					
						
							| 
									
										
										
										
											2021-11-06 11:28:47 -08:00
										 |  |  | import { useUserApi } from "~/composables/api"; | 
					
						
							| 
									
										
										
										
											2022-10-22 11:51:07 -08:00
										 |  |  | import { UserOut } from "~/lib/api/types/user"; | 
					
						
							| 
									
										
										
										
											2021-12-18 19:04:36 -09:00
										 |  |  | import UserAvatar from "~/components/Domain/User/UserAvatar.vue"; | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							| 
									
										
										
										
											2021-12-18 19:04:36 -09:00
										 |  |  |   components: { | 
					
						
							|  |  |  |     UserAvatar, | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2021-11-06 11:28:47 -08:00
										 |  |  |     const api = useUserApi(); | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const { i18n } = useContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const members = ref<UserOut[] | null[]>([]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const headers = [ | 
					
						
							|  |  |  |       { text: "", value: "avatar", sortable: false, align: "center" }, | 
					
						
							|  |  |  |       { text: i18n.t("user.username"), value: "username" }, | 
					
						
							|  |  |  |       { text: i18n.t("user.full-name"), value: "fullName" }, | 
					
						
							|  |  |  |       { text: i18n.t("user.admin"), value: "admin" }, | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |       { text: i18n.t("group.manage"), value: "manage", sortable: false, align: "center" }, | 
					
						
							|  |  |  |       { text: i18n.t("settings.organize"), value: "organize", sortable: false, align: "center" }, | 
					
						
							|  |  |  |       { text: i18n.t("group.invite"), value: "invite", sortable: false, align: "center" }, | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function refreshMembers() { | 
					
						
							|  |  |  |       const { data } = await api.groups.fetchMembers(); | 
					
						
							|  |  |  |       if (data) { | 
					
						
							|  |  |  |         members.value = data; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function setPermissions(user: UserOut) { | 
					
						
							|  |  |  |       const payload = { | 
					
						
							|  |  |  |         userId: user.id, | 
					
						
							|  |  |  |         canInvite: user.canInvite, | 
					
						
							|  |  |  |         canManage: user.canManage, | 
					
						
							|  |  |  |         canOrganize: user.canOrganize, | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       await api.groups.setMemberPermissions(payload); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     onMounted(async () => { | 
					
						
							|  |  |  |       await refreshMembers(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { members, headers, setPermissions }; | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-10-07 09:39:47 -08:00
										 |  |  |   head() { | 
					
						
							|  |  |  |     return { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |       title: this.$t("profile.members"), | 
					
						
							| 
									
										
										
										
											2021-10-07 09:39:47 -08:00
										 |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2022-03-23 04:54:16 +01:00
										 |  |  | </script> |