Skip to content

Commit 528c62b

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 8309fb3 + f7c169c commit 528c62b

File tree

19 files changed

+222
-106
lines changed

19 files changed

+222
-106
lines changed

assets/css/app.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,16 @@ form .field {
619619
display: none;
620620
}
621621

622+
.sub-item-indent {
623+
padding-left: 20px;
624+
}
625+
626+
.sub-item-indent.active {
627+
background-color: #e0e0e0;
628+
color: #333;
629+
font-weight: bold;
630+
}
631+
622632
//@import 'primevue-md-light-indigo/theme.css';
623633
//@import '~primevue/resources/primevue.min.css';
624634
//@import '~primeflex/primeflex.css';

assets/vue/components/message/MessageLayout.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<div class="message-layout flex">
33
<div class="sidebar">
44
<UserProfileCard />
5-
<SocialSideMenu />
65
</div>
76
<div class="content flex-grow">
87
<router-view></router-view>
@@ -11,7 +10,6 @@
1110
</template>
1211
<script setup>
1312
import UserProfileCard from "../social/UserProfileCard.vue"
14-
import SocialSideMenu from "../social/SocialSideMenu.vue"
1513
import { onMounted, provide } from "vue"
1614
import { useSocialInfo } from "../../composables/useSocialInfo"
1715
import { useSecurityStore } from "../../store/securityStore"

assets/vue/components/personalfile/Layout.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<div class="flex flex-col md:flex-row gap-4">
33
<div class="md:basis-1/3 lg:basis-1/4 2xl:basis-1/6 flex flex-col">
44
<UserProfileCard />
5-
<SocialSideMenu />
65
</div>
76
<div class="md:basis-2/3 lg:basis-3/4 2xl:basis-5/6">
87
<h2 v-t="'My files'" class="mr-auto" />
@@ -13,7 +12,6 @@
1312
</template>
1413
<script setup>
1514
import UserProfileCard from "../social/UserProfileCard.vue"
16-
import SocialSideMenu from "../social/SocialSideMenu.vue"
1715
import { onMounted, provide } from "vue"
1816
import { useSocialInfo } from "../../composables/useSocialInfo"
1917

assets/vue/components/social/MyGroupsCard.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,18 @@ function search() {
6969
7070
async function fetchGroups(userId) {
7171
try {
72-
const response = await axios.get( `/social-network/groups/${userId}`)
73-
groups.value = response.data.groups
74-
goToUrl.value = response.data.groups.find(group => group.go_to)?.go_to || ''
72+
const response = await axios.get(`/social-network/groups/${userId}`)
73+
if (response.data) {
74+
groups.value = response.data.items
75+
goToUrl.value = response.data.go_to
76+
}
7577
} catch (error) {
76-
console.error('Error fetching groups:', error)
78+
groups.value = []
79+
goToUrl.value = ''
7780
}
7881
}
7982
83+
8084
watchEffect(() => {
8185
if (user.value && user.value.id) {
8286
fetchGroups(user.value.id)

assets/vue/components/user/Layout.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
<template>
2-
<div class="flex flex-col md:flex-row gap-4">
3-
<div class="md:basis-1/3 lg:basis-1/4 2xl:basis-1/6 flex flex-col">
2+
<div class="flex flex-col md:flex-row gap-4 w-full">
3+
<div class="flex flex-col w-full md:w-1/5">
44
<UserProfileCard />
5-
<SocialSideMenu />
65
</div>
7-
<div class="md:basis-2/3 lg:basis-1/2 2xl:basis-4/6">
6+
<div class="flex-grow w-full md:w-4/5">
87
<router-view />
98
</div>
109
</div>
1110
</template>
1211

1312
<script setup>
1413
import UserProfileCard from "../social/UserProfileCard.vue"
15-
import SocialSideMenu from "../social/SocialSideMenu.vue"
16-
1714
import { onMounted, provide } from "vue"
1815
import { useSocialInfo } from "../../composables/useSocialInfo"
1916

assets/vue/components/usergroup/Layout.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<div class="md:basis-1/3 lg:basis-1/4 2xl:basis-1/6 flex flex-col">
44
<UserProfileCard v-if="!isLoading && !isGroup" />
55
<GroupInfoCard v-if="!isLoading && isGroup" />
6-
<SocialSideMenu v-if="!isLoading && !isGroup" />
76
<SocialGroupMenu v-if="!isLoading && isGroup" />
87
</div>
98
<div class="md:basis-2/3 lg:basis-3/4 2xl:basis-5/6">
@@ -13,7 +12,6 @@
1312
</template>
1413
<script setup>
1514
import UserProfileCard from "../social/UserProfileCard.vue"
16-
import SocialSideMenu from "../social/SocialSideMenu.vue"
1715
import { provide } from "vue"
1816
import { useSocialInfo } from "../../composables/useSocialInfo"
1917
import SocialGroupMenu from "../social/SocialGroupMenu.vue"

assets/vue/components/userreluser/Layout.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<div class="flex flex-col md:flex-row gap-4">
33
<div class="md:basis-1/3 lg:basis-1/4 2xl:basis-1/6 flex flex-col">
44
<UserProfileCard />
5-
<SocialSideMenu />
65
</div>
76
<div class="md:basis-2/3 lg:basis-3/4 2xl:basis-5/6">
87
<router-view></router-view>
@@ -11,7 +10,6 @@
1110
</template>
1211
<script setup>
1312
import UserProfileCard from "../social/UserProfileCard.vue"
14-
import SocialSideMenu from "../social/SocialSideMenu.vue"
1513
import { onMounted, provide } from "vue"
1614
import { useSocialInfo } from "../../composables/useSocialInfo"
1715

assets/vue/composables/sidebarMenu.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
import { useI18n } from "vue-i18n"
2-
import { computed } from "vue"
2+
import { computed, ref } from "vue"
33
import { useSecurityStore } from "../store/securityStore"
44
import { usePlatformConfig } from "../store/platformConfig"
55
import { useEnrolledStore } from "../store/enrolledStore"
6-
import { useRouter } from "vue-router"
6+
import { useRoute, useRouter } from "vue-router"
7+
import { useSocialMenuItems } from "./useSocialMenuItems"
78

89
export function useSidebarMenu() {
910
const { t } = useI18n()
1011
const router = useRouter()
12+
const route = useRoute()
1113
const securityStore = useSecurityStore()
1214
const platformConfigStore = usePlatformConfig()
1315
const enrolledStore = useEnrolledStore()
16+
const { items: socialItems } = useSocialMenuItems();
1417
const showTabsSetting = platformConfigStore.getSetting("platform.show_tabs")
1518
const showCatalogue = platformConfigStore.getSetting("platform.catalog_show_courses_sessions")
1619

20+
const isActive = (item) => {
21+
if (item.route) {
22+
return route.path === item.route || (item.route.name && route.name === item.route.name)
23+
} else if (item.items) {
24+
return item.items.some(subItem => isActive(subItem))
25+
}
26+
return false
27+
};
28+
1729
const menuItemsBeforeMyCourse = computed(() => {
1830
const items = []
1931

@@ -118,11 +130,29 @@ export function useSidebarMenu() {
118130
}
119131

120132
if (showTabsSetting.indexOf("social") > -1) {
133+
const styledSocialItems = socialItems.value.map(item => {
134+
const newItem = {
135+
...item,
136+
class: `sub-item-indent${isActive(item) ? ' active' : ''}`
137+
};
138+
139+
if (newItem.isLink && newItem.route) {
140+
newItem.command = () => window.location.href = newItem.route
141+
} else if (newItem.route) {
142+
newItem.command = () => router.push(newItem.route)
143+
} else if (newItem.link) {
144+
newItem.command = () => window.location.href = newItem.link
145+
}
146+
147+
return newItem
148+
});
149+
121150
items.push({
122151
icon: "mdi mdi-sitemap-outline",
123152
label: t("Social network"),
124-
command: () => router.push({ name: "SocialWall" }),
125-
})
153+
items: styledSocialItems,
154+
expanded: isActive({ items: styledSocialItems })
155+
});
126156
}
127157

128158
if (platformConfigStore.plugins?.bbb?.show_global_conference_link) {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { computed, ref } from 'vue';
2+
import { useI18n } from 'vue-i18n';
3+
import { useMessageRelUserStore } from "../store/messageRelUserStore"
4+
import { useSecurityStore } from "../store/securityStore"
5+
import { usePlatformConfig } from "../store/platformConfig"
6+
import axios from 'axios';
7+
import { useSocialInfo } from "./useSocialInfo"
8+
import { storeToRefs } from "pinia"
9+
10+
export function useSocialMenuItems() {
11+
const { t } = useI18n();
12+
const messageRelUserStore = useMessageRelUserStore();
13+
const securityStore = useSecurityStore();
14+
const platformConfigStore = usePlatformConfig();
15+
const invitationsCount = ref(0);
16+
const groupLink = ref({ name: "UserGroupShow" });
17+
18+
const { isCurrentUser} = useSocialInfo()
19+
const { user } = storeToRefs(securityStore)
20+
21+
const unreadMessagesCount = computed(() => messageRelUserStore.countUnread);
22+
const globalForumsCourse = computed(() => platformConfigStore.getSetting("forum.global_forums_course_id"));
23+
const isValidGlobalForumsCourse = computed(() => {
24+
const courseId = globalForumsCourse.value;
25+
return courseId !== null && courseId !== undefined && courseId > 0;
26+
});
27+
28+
const fetchInvitationsCount = async (userId) => {
29+
if (!userId) return;
30+
try {
31+
const { data } = await axios.get(`/social-network/invitations/count/${userId}`);
32+
invitationsCount.value = data.totalInvitationsCount;
33+
} catch (error) {
34+
console.error("Error fetching invitations count:", error);
35+
}
36+
};
37+
38+
const getGroupLink = async () => {
39+
try {
40+
const response = await axios.get("/social-network/get-forum-link");
41+
if (isValidGlobalForumsCourse.value) {
42+
groupLink.value = response.data.go_to;
43+
} else {
44+
groupLink.value = { name: "UserGroupList" };
45+
}
46+
} catch (error) {
47+
console.error("Error fetching forum link:", error);
48+
groupLink.value = { name: "UserGroupList" };
49+
}
50+
};
51+
52+
console.log('user.value ::: ', user.value.id)
53+
54+
if (user.value && user.value.id) {
55+
fetchInvitationsCount(user.value.id);
56+
getGroupLink();
57+
}
58+
59+
const items = computed(() => {
60+
return isCurrentUser.value ? [
61+
{ icon: 'mdi mdi-home', label: t("Home"), route: '/social' },
62+
{ icon: 'mdi mdi-email', label: t("Messages"), route: '/resources/messages', badgeCount: unreadMessagesCount.value },
63+
{ icon: 'mdi mdi-mailbox', label: t("Invitations"), route: { name: 'Invitations' }, badgeCount: invitationsCount.value },
64+
{ icon: 'mdi mdi-handshake', label: t("My friends"), route: { name: 'UserRelUserList' } },
65+
{ icon: 'mdi mdi-group', label: t("Social groups"), route: groupLink.value, isLink: isValidGlobalForumsCourse.value },
66+
{ icon: 'mdi mdi-magnify', label: t("Search"), route: '/social/search' },
67+
{ icon: 'mdi mdi-briefcase', label: t("My files"), route: { name: 'PersonalFileList', params: { node: securityStore.user.resourceNode.id } } },
68+
{ icon: 'mdi mdi-account', label: t("Personal data"), route: '/resources/users/personal_data' },
69+
{ icon: 'mdi mdi-star', label: t("Promoted messages"), route: { path: '/social', query: { filterType: 'promoted' } } }
70+
] : [
71+
{ icon: 'mdi mdi-home', label: t("Home"), route: '/social' },
72+
{ icon: 'mdi mdi-email', label: t("Send message"), link: `/main/inc/ajax/user_manager.ajax.php?a=get_user_popup&user_id=${user.value.id}`, isExternal: true }
73+
];
74+
});
75+
76+
return { items };
77+
}

assets/vue/views/account/Home.vue

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,18 @@
22
<div class="flex flex-col md:flex-row gap-4">
33
<div class="md:basis-1/3 lg:basis-1/4 2xl:basis-1/6 flex flex-col">
44
<UserProfileCard />
5-
<SocialSideMenu />
65
</div>
76
<div class="md:basis-2/3 lg:basis-3/4 2xl:basis-5/6">
8-
<div id="account-home">
9-
<div class="flex mb-4">
10-
<Avatar
11-
:image="user.illustrationUrl + '?w=80&h=80&fit=crop'"
12-
class="flex-none mr-2"
13-
shape="circle"
14-
size="large"
15-
/>
16-
<div class="flex-1">
17-
<p class="text-body-1">
18-
{{ user.fullName }}
19-
</p>
20-
<p class="text-caption">
21-
{{ user.username }}
22-
</p>
23-
</div>
24-
</div>
25-
</div>
7+
<SocialWall :hidePostForm="true" />
268
</div>
279
</div>
2810
</template>
2911

3012
<script setup>
3113
import { onMounted, provide } from "vue"
32-
33-
import Avatar from "primevue/avatar"
34-
import SocialSideMenu from "../../components/social/SocialSideMenu.vue";
3514
import UserProfileCard from "../../components/social/UserProfileCard.vue"
3615
import { useSocialInfo } from "../../composables/useSocialInfo"
16+
import SocialWall from "../social/SocialWall.vue"
3717
3818
3919
const { user, isCurrentUser, groupInfo, isGroup, loadUser } = useSocialInfo();

assets/vue/views/message/MessageList.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ import { MESSAGE_STATUS_DELETED, MESSAGE_TYPE_INBOX } from "../../components/mes
179179
import { GET_USER_MESSAGE_TAGS } from "../../graphql/queries/MessageTag"
180180
import { useNotification } from "../../composables/notification"
181181
import { useMessageRelUserStore } from "../../store/messageRelUserStore"
182-
import SocialSideMenu from "../../components/social/SocialSideMenu.vue"
183182
import { useSecurityStore } from "../../store/securityStore"
184183
185184
const route = useRoute()

0 commit comments

Comments
 (0)