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