2021-10-04 20:16:37 -08:00
|
|
|
<template>
|
|
|
|
<v-container>
|
|
|
|
<BasePageTitle divider>
|
|
|
|
<template #header>
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-img
|
|
|
|
width="100%"
|
|
|
|
max-height="125"
|
|
|
|
max-width="125"
|
|
|
|
:src="require('~/static/svgs/manage-members.svg')"
|
|
|
|
/>
|
2021-10-04 20:16:37 -08:00
|
|
|
</template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<template #title>
|
|
|
|
{{ $t('group.manage-members') }}
|
|
|
|
</template>
|
|
|
|
<i18n-t keypath="group.manage-members-description">
|
|
|
|
<template #manage>
|
|
|
|
<b>{{ $t('group.manage') }}</b>
|
|
|
|
</template>
|
|
|
|
<template #invite>
|
|
|
|
<b>{{ $t('group.invite') }}</b>
|
|
|
|
</template>
|
|
|
|
</i18n-t>
|
|
|
|
<v-container class="mt-1 px-0">
|
|
|
|
<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>
|
2025-06-20 00:09:12 +07:00
|
|
|
</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
|
|
|
|
>
|
2025-06-20 00:09:12 +07:00
|
|
|
<template #[`item.avatar`]="{ item }">
|
|
|
|
<UserAvatar
|
|
|
|
v-if="item"
|
|
|
|
:tooltip="false"
|
|
|
|
:user-id="item.id"
|
|
|
|
/>
|
2021-10-04 20:16:37 -08:00
|
|
|
</template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<template #[`item.admin`]="{ item }">
|
|
|
|
{{ item && item.admin ? $t('user.admin') : $t('user.user') }}
|
2021-10-04 20:16:37 -08:00
|
|
|
</template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<template #[`item.manageHousehold`]="{ item }">
|
|
|
|
<div
|
|
|
|
v-if="item"
|
|
|
|
class="d-flex justify-center"
|
|
|
|
>
|
2024-09-17 10:48:14 -05:00
|
|
|
<v-checkbox
|
|
|
|
v-model="item.canManageHousehold"
|
2025-06-20 00:09:12 +07:00
|
|
|
:disabled="item.id === sessionUser?.id || item.admin"
|
|
|
|
color="primary"
|
2024-09-17 10:48:14 -05:00
|
|
|
class=""
|
|
|
|
style="max-width: 30px"
|
2025-06-20 00:09:12 +07:00
|
|
|
hide-details
|
2024-09-17 10:48:14 -05:00
|
|
|
@change="setPermissions(item)"
|
2025-06-20 00:09:12 +07:00
|
|
|
/>
|
2024-09-17 10:48:14 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<template #[`item.manage`]="{ item }">
|
|
|
|
<div
|
|
|
|
v-if="item"
|
|
|
|
class="d-flex justify-center"
|
|
|
|
>
|
2021-10-04 20:16:37 -08:00
|
|
|
<v-checkbox
|
|
|
|
v-model="item.canManage"
|
2025-06-20 00:09:12 +07:00
|
|
|
:disabled="item.id === sessionUser?.id || item.admin"
|
2021-10-04 20:16:37 -08:00
|
|
|
class=""
|
|
|
|
style="max-width: 30px"
|
2025-06-20 00:09:12 +07:00
|
|
|
hide-details
|
|
|
|
color="primary"
|
2021-10-04 20:16:37 -08:00
|
|
|
@change="setPermissions(item)"
|
2025-06-20 00:09:12 +07:00
|
|
|
/>
|
2021-10-04 20:16:37 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<template #[`item.organize`]="{ item }">
|
|
|
|
<div
|
|
|
|
v-if="item"
|
|
|
|
class="d-flex justify-center"
|
|
|
|
>
|
2021-10-04 20:16:37 -08:00
|
|
|
<v-checkbox
|
|
|
|
v-model="item.canOrganize"
|
2025-06-20 00:09:12 +07:00
|
|
|
:disabled="item.id === sessionUser?.id || item.admin"
|
2021-10-04 20:16:37 -08:00
|
|
|
class=""
|
|
|
|
style="max-width: 30px"
|
2025-06-20 00:09:12 +07:00
|
|
|
hide-details
|
|
|
|
color="primary"
|
2021-10-04 20:16:37 -08:00
|
|
|
@change="setPermissions(item)"
|
2025-06-20 00:09:12 +07:00
|
|
|
/>
|
2021-10-04 20:16:37 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<template #[`item.invite`]="{ item }">
|
|
|
|
<div
|
|
|
|
v-if="item"
|
|
|
|
class="d-flex justify-center"
|
|
|
|
>
|
2021-10-04 20:16:37 -08:00
|
|
|
<v-checkbox
|
|
|
|
v-model="item.canInvite"
|
2025-06-20 00:09:12 +07:00
|
|
|
:disabled="item.id === sessionUser?.id || item.admin"
|
2021-10-04 20:16:37 -08:00
|
|
|
class=""
|
|
|
|
style="max-width: 30px"
|
2025-06-20 00:09:12 +07:00
|
|
|
hide-details
|
|
|
|
color="primary"
|
2021-10-04 20:16:37 -08:00
|
|
|
@change="setPermissions(item)"
|
2025-06-20 00:09:12 +07:00
|
|
|
/>
|
2021-10-04 20:16:37 -08:00
|
|
|
</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">
|
2021-11-06 11:28:47 -08:00
|
|
|
import { useUserApi } from "~/composables/api";
|
2025-06-20 00:09:12 +07:00
|
|
|
import type { 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
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
export default defineNuxtComponent({
|
2021-12-18 19:04:36 -09:00
|
|
|
components: {
|
|
|
|
UserAvatar,
|
|
|
|
},
|
2025-06-20 00:09:12 +07:00
|
|
|
middleware: ["sidebase-auth"],
|
2021-10-04 20:16:37 -08:00
|
|
|
setup() {
|
2025-06-20 00:09:12 +07:00
|
|
|
const $auth = useMealieAuth();
|
2021-11-06 11:28:47 -08:00
|
|
|
const api = useUserApi();
|
2025-06-20 00:09:12 +07:00
|
|
|
const i18n = useI18n();
|
2021-10-04 20:16:37 -08:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
useSeoMeta({
|
|
|
|
title: i18n.t("profile.members"),
|
|
|
|
});
|
2021-10-04 20:16:37 -08:00
|
|
|
|
|
|
|
const members = ref<UserOut[] | null[]>([]);
|
|
|
|
|
|
|
|
const headers = [
|
2025-06-20 00:09:12 +07:00
|
|
|
{ title: "", value: "avatar", sortable: false, align: "center" },
|
|
|
|
{ title: i18n.t("user.username"), value: "username" },
|
|
|
|
{ title: i18n.t("user.full-name"), value: "fullName" },
|
|
|
|
{ title: i18n.t("user.admin"), value: "admin" },
|
|
|
|
{ title: i18n.t("group.manage"), value: "manage", sortable: false, align: "center" },
|
|
|
|
{ title: i18n.t("settings.organize"), value: "organize", sortable: false, align: "center" },
|
|
|
|
{ title: i18n.t("group.invite"), value: "invite", sortable: false, align: "center" },
|
|
|
|
{ title: i18n.t("group.manage-household"), value: "manageHousehold", sortable: false, align: "center" },
|
2021-10-04 20:16:37 -08:00
|
|
|
];
|
|
|
|
|
|
|
|
async function refreshMembers() {
|
2024-08-22 10:14:32 -05:00
|
|
|
const { data } = await api.households.fetchMembers();
|
2021-10-04 20:16:37 -08:00
|
|
|
if (data) {
|
2024-10-11 19:36:26 -05:00
|
|
|
members.value = data.items;
|
2021-10-04 20:16:37 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function setPermissions(user: UserOut) {
|
|
|
|
const payload = {
|
|
|
|
userId: user.id,
|
|
|
|
canInvite: user.canInvite,
|
2024-09-17 10:48:14 -05:00
|
|
|
canManageHousehold: user.canManageHousehold,
|
2021-10-04 20:16:37 -08:00
|
|
|
canManage: user.canManage,
|
|
|
|
canOrganize: user.canOrganize,
|
|
|
|
};
|
|
|
|
|
2024-08-22 10:14:32 -05:00
|
|
|
await api.households.setMemberPermissions(payload);
|
2021-10-04 20:16:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
await refreshMembers();
|
|
|
|
});
|
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
return { members, headers, setPermissions, sessionUser: $auth.user };
|
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>
|