|
|
|
@ -1,122 +1,135 @@ |
|
|
|
|
<template> |
|
|
|
|
<div class="p-grid p-nogutter social-groups"> |
|
|
|
|
<div class="p-col-12"> |
|
|
|
|
<div class="p-d-flex p-jc-between p-ai-center p-mb-4"> |
|
|
|
|
<h1>Social groups</h1> |
|
|
|
|
<Button |
|
|
|
|
class="create-group-button" |
|
|
|
|
icon="pi pi-plus" |
|
|
|
|
label="Create a social group" |
|
|
|
|
@click="showCreateGroupDialog = true" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<TabView class="social-group-tabs"> |
|
|
|
|
<TabPanel |
|
|
|
|
:class="{ 'active-tab': activeTab === 'Newest' }" |
|
|
|
|
header="Newest" |
|
|
|
|
header-class="tab-header" |
|
|
|
|
<div class="p-4 social-groups"> |
|
|
|
|
<div class="flex justify-between items-center mb-4"> |
|
|
|
|
<h1 class="text-2xl font-semibold">Social Groups</h1> |
|
|
|
|
<Button |
|
|
|
|
class="bg-blue-500 text-white rounded-md px-4 py-2" |
|
|
|
|
icon="pi pi-plus" |
|
|
|
|
label="Create a social group" |
|
|
|
|
@click="showCreateGroupDialog = true" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div class="tabs mb-4"> |
|
|
|
|
<button |
|
|
|
|
:class="['tab', { 'tab-active': activeTab === 'Newest' }]" |
|
|
|
|
@click="activeTab = 'Newest'" |
|
|
|
|
> |
|
|
|
|
Newest |
|
|
|
|
</button> |
|
|
|
|
<button |
|
|
|
|
:class="['tab', { 'tab-active': activeTab === 'Popular' }]" |
|
|
|
|
@click="activeTab = 'Popular'" |
|
|
|
|
> |
|
|
|
|
Popular |
|
|
|
|
</button> |
|
|
|
|
<button |
|
|
|
|
:class="['tab', { 'tab-active': activeTab === 'My groups' }]" |
|
|
|
|
@click="activeTab = 'My groups'" |
|
|
|
|
> |
|
|
|
|
My Groups |
|
|
|
|
</button> |
|
|
|
|
<button |
|
|
|
|
:class="['tab', { 'tab-active': activeTab === 'Search Groups' }]" |
|
|
|
|
@click="activeTab = 'Search Groups'" |
|
|
|
|
> |
|
|
|
|
Search Groups |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
<div v-show="activeTab === 'Newest'"> |
|
|
|
|
<div class="group-list"> |
|
|
|
|
<div |
|
|
|
|
v-for="group in newestGroups" |
|
|
|
|
:key="group['@id']" |
|
|
|
|
class="group-item flex items-center p-4 bg-white shadow-md rounded-md mb-4" |
|
|
|
|
> |
|
|
|
|
<div class="group-list"> |
|
|
|
|
<div |
|
|
|
|
v-for="group in newestGroups" |
|
|
|
|
:key="group['@id']" |
|
|
|
|
class="group-item" |
|
|
|
|
<img |
|
|
|
|
v-if="group.pictureUrl" |
|
|
|
|
:src="group.pictureUrl" |
|
|
|
|
alt="Group Image" |
|
|
|
|
class="w-16 h-16 rounded-full mr-4" |
|
|
|
|
/> |
|
|
|
|
<i |
|
|
|
|
v-else |
|
|
|
|
class="mdi mdi-account-group-outline text-4xl text-gray-500 mr-4" |
|
|
|
|
></i> |
|
|
|
|
<div class="group-details"> |
|
|
|
|
<a |
|
|
|
|
:href="`/resources/usergroups/show/${extractGroupId(group)}`" |
|
|
|
|
class="text-lg font-semibold text-blue-600 hover:underline" |
|
|
|
|
>{{ group.title }}</a |
|
|
|
|
> |
|
|
|
|
<img |
|
|
|
|
v-if="group.pictureUrl" |
|
|
|
|
:src="group.pictureUrl" |
|
|
|
|
alt="Group Image" |
|
|
|
|
class="group-image" |
|
|
|
|
/> |
|
|
|
|
<i |
|
|
|
|
v-else |
|
|
|
|
class="mdi mdi-account-group-outline group-icon" |
|
|
|
|
></i> |
|
|
|
|
<div class="group-details"> |
|
|
|
|
<a |
|
|
|
|
:href="`/resources/usergroups/show/${extractGroupId(group)}`" |
|
|
|
|
class="group-title" |
|
|
|
|
>{{ group.title }}</a |
|
|
|
|
> |
|
|
|
|
<div class="group-info"> |
|
|
|
|
<span class="group-member-count">{{ group.memberCount }} {{ t("Member") }}</span> |
|
|
|
|
<span class="group-description">{{ group.description }}</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="group-info text-gray-500"> |
|
|
|
|
<span class="group-member-count">{{ group.memberCount }} Members</span> |
|
|
|
|
<span class="group-description">{{ group.description }}</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</TabPanel> |
|
|
|
|
<TabPanel |
|
|
|
|
:class="{ 'active-tab': activeTab === 'Popular' }" |
|
|
|
|
header="Popular" |
|
|
|
|
header-class="tab-header" |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div v-show="activeTab === 'Popular'"> |
|
|
|
|
<div class="group-list"> |
|
|
|
|
<div |
|
|
|
|
v-for="group in popularGroups" |
|
|
|
|
:key="group['@id']" |
|
|
|
|
class="group-item flex items-center p-4 bg-white shadow-md rounded-md mb-4" |
|
|
|
|
> |
|
|
|
|
<div class="group-list"> |
|
|
|
|
<div |
|
|
|
|
v-for="group in popularGroups" |
|
|
|
|
:key="group['@id']" |
|
|
|
|
class="group-item" |
|
|
|
|
<img |
|
|
|
|
v-if="group.pictureUrl" |
|
|
|
|
:src="group.pictureUrl" |
|
|
|
|
alt="Group Image" |
|
|
|
|
class="w-16 h-16 rounded-full mr-4" |
|
|
|
|
/> |
|
|
|
|
<i |
|
|
|
|
v-else |
|
|
|
|
class="mdi mdi-account-group-outline text-4xl text-gray-500 mr-4" |
|
|
|
|
></i> |
|
|
|
|
<div class="group-details"> |
|
|
|
|
<a |
|
|
|
|
:href="`/resources/usergroups/show/${extractGroupId(group)}`" |
|
|
|
|
class="text-lg font-semibold text-blue-600 hover:underline" |
|
|
|
|
>{{ group.title }}</a |
|
|
|
|
> |
|
|
|
|
<img |
|
|
|
|
v-if="group.pictureUrl" |
|
|
|
|
:src="group.pictureUrl" |
|
|
|
|
alt="Group Image" |
|
|
|
|
class="group-image" |
|
|
|
|
/> |
|
|
|
|
<i |
|
|
|
|
v-else |
|
|
|
|
class="mdi mdi-account-group-outline group-icon" |
|
|
|
|
></i> |
|
|
|
|
<div class="group-details"> |
|
|
|
|
<a |
|
|
|
|
:href="`/resources/usergroups/show/${extractGroupId(group)}`" |
|
|
|
|
class="group-title" |
|
|
|
|
>{{ group.title }}</a |
|
|
|
|
> |
|
|
|
|
<div class="group-info"> |
|
|
|
|
<span class="group-member-count">{{ group.memberCount }} {{ t("Member") }}</span> |
|
|
|
|
<span class="group-description">{{ group.description }}</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="group-info text-gray-500"> |
|
|
|
|
<span class="group-member-count">{{ group.memberCount }} Members</span> |
|
|
|
|
<span class="group-description">{{ group.description }}</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</TabPanel> |
|
|
|
|
<TabPanel |
|
|
|
|
:class="{ 'active-tab': activeTab === 'My groups' }" |
|
|
|
|
header="My groups" |
|
|
|
|
header-class="tab-header" |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div v-show="activeTab === 'My groups'"> |
|
|
|
|
<div class="group-list"> |
|
|
|
|
<div |
|
|
|
|
v-for="group in myGroups" |
|
|
|
|
:key="group['@id']" |
|
|
|
|
class="group-item flex items-center p-4 bg-white shadow-md rounded-md mb-4" |
|
|
|
|
> |
|
|
|
|
<div class="group-list"> |
|
|
|
|
<div |
|
|
|
|
v-for="group in myGroups" |
|
|
|
|
:key="group['@id']" |
|
|
|
|
class="group-item" |
|
|
|
|
<img |
|
|
|
|
v-if="group.pictureUrl" |
|
|
|
|
:src="group.pictureUrl" |
|
|
|
|
alt="Group Image" |
|
|
|
|
class="w-16 h-16 rounded-full mr-4" |
|
|
|
|
/> |
|
|
|
|
<i |
|
|
|
|
v-else |
|
|
|
|
class="mdi mdi-account-group-outline text-4xl text-gray-500 mr-4" |
|
|
|
|
></i> |
|
|
|
|
<div class="group-details"> |
|
|
|
|
<a |
|
|
|
|
:href="`/resources/usergroups/show/${extractGroupId(group)}`" |
|
|
|
|
class="text-lg font-semibold text-blue-600 hover:underline" |
|
|
|
|
>{{ group.title }}</a |
|
|
|
|
> |
|
|
|
|
<img |
|
|
|
|
v-if="group.pictureUrl" |
|
|
|
|
:src="group.pictureUrl" |
|
|
|
|
alt="Group Image" |
|
|
|
|
class="group-image" |
|
|
|
|
/> |
|
|
|
|
<i |
|
|
|
|
v-else |
|
|
|
|
class="mdi mdi-account-group-outline group-icon" |
|
|
|
|
></i> |
|
|
|
|
<div class="group-details"> |
|
|
|
|
<a |
|
|
|
|
:href="`/resources/usergroups/show/${extractGroupId(group)}`" |
|
|
|
|
class="group-title" |
|
|
|
|
>{{ group.title }}</a |
|
|
|
|
> |
|
|
|
|
<div class="group-info"> |
|
|
|
|
<span class="group-member-count">{{ group.memberCount }} {{ t("Member") }}</span> |
|
|
|
|
<span class="group-description">{{ group.description }}</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="group-info text-gray-500"> |
|
|
|
|
<span class="group-member-count">{{ group.memberCount }} Members</span> |
|
|
|
|
<span class="group-description">{{ group.description }}</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</TabPanel> |
|
|
|
|
</TabView> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div v-show="activeTab === 'Search Groups'"> |
|
|
|
|
<GroupSearch /> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
@ -188,32 +201,33 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script setup> |
|
|
|
|
import Button from "primevue/button" |
|
|
|
|
import TabView from "primevue/tabview" |
|
|
|
|
import TabPanel from "primevue/tabpanel" |
|
|
|
|
import { onMounted, ref } from "vue" |
|
|
|
|
import useVuelidate from "@vuelidate/core" |
|
|
|
|
import { required } from "@vuelidate/validators" |
|
|
|
|
import BaseInputTextWithVuelidate from "../../components/basecomponents/BaseInputTextWithVuelidate.vue" |
|
|
|
|
import BaseFileUpload from "../../components/basecomponents/BaseFileUpload.vue" |
|
|
|
|
import BaseCheckbox from "../../components/basecomponents/BaseCheckbox.vue" |
|
|
|
|
import { useI18n } from "vue-i18n" |
|
|
|
|
import usergroupService from "../../services/usergroupService" |
|
|
|
|
import Button from "primevue/button"; |
|
|
|
|
import TabView from "primevue/tabview"; |
|
|
|
|
import TabPanel from "primevue/tabpanel"; |
|
|
|
|
import { onMounted, ref } from "vue"; |
|
|
|
|
import useVuelidate from "@vuelidate/core"; |
|
|
|
|
import { required } from "@vuelidate/validators"; |
|
|
|
|
import BaseInputTextWithVuelidate from "../../components/basecomponents/BaseInputTextWithVuelidate.vue"; |
|
|
|
|
import BaseFileUpload from "../../components/basecomponents/BaseFileUpload.vue"; |
|
|
|
|
import BaseCheckbox from "../../components/basecomponents/BaseCheckbox.vue"; |
|
|
|
|
import { useI18n } from "vue-i18n"; |
|
|
|
|
import usergroupService from "../../services/usergroupService"; |
|
|
|
|
import GroupSearch from "../../components/usergroup/GroupSearch.vue" |
|
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
|
|
const newestGroups = ref([]) |
|
|
|
|
const popularGroups = ref([]) |
|
|
|
|
const myGroups = ref([]) |
|
|
|
|
const activeTab = ref("Newest") |
|
|
|
|
const showCreateGroupDialog = ref(false) |
|
|
|
|
const selectedFile = ref(null) |
|
|
|
|
const { t } = useI18n(); |
|
|
|
|
const newestGroups = ref([]); |
|
|
|
|
const popularGroups = ref([]); |
|
|
|
|
const myGroups = ref([]); |
|
|
|
|
const activeTab = ref("Newest"); |
|
|
|
|
const showCreateGroupDialog = ref(false); |
|
|
|
|
const selectedFile = ref(null); |
|
|
|
|
|
|
|
|
|
const groupForm = ref({ |
|
|
|
|
name: "", |
|
|
|
|
description: "", |
|
|
|
|
url: "", |
|
|
|
|
picture: null, |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
const v$ = useVuelidate( |
|
|
|
|
{ |
|
|
|
|
groupForm: { |
|
|
|
@ -222,14 +236,14 @@ const v$ = useVuelidate( |
|
|
|
|
url: {}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ groupForm }, |
|
|
|
|
) |
|
|
|
|
{ groupForm } |
|
|
|
|
); |
|
|
|
|
const permissionsOptions = [ |
|
|
|
|
{ label: "Open", value: "1" }, |
|
|
|
|
{ label: "Closed", value: "2" }, |
|
|
|
|
] |
|
|
|
|
]; |
|
|
|
|
const createGroup = async () => { |
|
|
|
|
v$.value.$touch() |
|
|
|
|
v$.value.$touch(); |
|
|
|
|
if (!v$.value.$invalid) { |
|
|
|
|
const groupData = { |
|
|
|
|
title: groupForm.value.name, |
|
|
|
@ -238,45 +252,45 @@ const createGroup = async () => { |
|
|
|
|
visibility: groupForm.value.permissions.value, |
|
|
|
|
allowMembersToLeaveGroup: groupForm.value.allowLeave ? 1 : 0, |
|
|
|
|
groupType: 1, |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
try { |
|
|
|
|
const newGroup = await usergroupService.createGroup(groupData) |
|
|
|
|
const newGroup = await usergroupService.createGroup(groupData); |
|
|
|
|
|
|
|
|
|
if (selectedFile.value && newGroup && newGroup.id) { |
|
|
|
|
await usergroupService.uploadPicture(newGroup.id, { |
|
|
|
|
picture: selectedFile.value, |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showCreateGroupDialog.value = false |
|
|
|
|
resetForm() |
|
|
|
|
updateGroupsList() |
|
|
|
|
showCreateGroupDialog.value = false; |
|
|
|
|
resetForm(); |
|
|
|
|
updateGroupsList(); |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("Failed to create group or upload picture:", error.response.data) |
|
|
|
|
console.error("Failed to create group or upload picture:", error.response.data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const updateGroupsList = () => { |
|
|
|
|
usergroupService.listNewest().then((newest) => (newestGroups.value = newest)) |
|
|
|
|
usergroupService.listPopular().then((popular) => (popularGroups.value = popular)) |
|
|
|
|
usergroupService.listMine().then((mine) => (myGroups.value = mine)) |
|
|
|
|
} |
|
|
|
|
usergroupService.listNewest().then((newest) => (newestGroups.value = newest)); |
|
|
|
|
usergroupService.listPopular().then((popular) => (popularGroups.value = popular)); |
|
|
|
|
usergroupService.listMine().then((mine) => (myGroups.value = mine)); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const extractGroupId = (group) => { |
|
|
|
|
const match = group["@id"].match(/\/api\/usergroup\/(\d+)/) |
|
|
|
|
return match ? match[1] : null |
|
|
|
|
} |
|
|
|
|
const match = group["@id"].match(/\/api\/usergroup\/(\d+)/); |
|
|
|
|
return match ? match[1] : null; |
|
|
|
|
}; |
|
|
|
|
const redirectToGroupDetails = (groupId) => { |
|
|
|
|
router.push({ name: "UserGroupShow", params: { group_id: groupId } }) |
|
|
|
|
} |
|
|
|
|
router.push({ name: "UserGroupShow", params: { group_id: groupId } }); |
|
|
|
|
}; |
|
|
|
|
onMounted(async () => { |
|
|
|
|
updateGroupsList() |
|
|
|
|
}) |
|
|
|
|
updateGroupsList(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const closeDialog = () => { |
|
|
|
|
showCreateGroupDialog.value = false |
|
|
|
|
} |
|
|
|
|
showCreateGroupDialog.value = false; |
|
|
|
|
}; |
|
|
|
|
const resetForm = () => { |
|
|
|
|
groupForm.value = { |
|
|
|
|
name: "", |
|
|
|
@ -285,8 +299,8 @@ const resetForm = () => { |
|
|
|
|
picture: null, |
|
|
|
|
permissions: "", |
|
|
|
|
allowLeave: false, |
|
|
|
|
} |
|
|
|
|
selectedFile.value = null |
|
|
|
|
v$.value.$reset() |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
selectedFile.value = null; |
|
|
|
|
v$.value.$reset(); |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|