|
|
@ -1,18 +1,24 @@ |
|
|
|
import { useI18n } from "vue-i18n" |
|
|
|
import { useI18n } from "vue-i18n" |
|
|
|
|
|
|
|
import { ref, onMounted, watch } from "vue" |
|
|
|
import { useSecurityStore } from "../store/securityStore" |
|
|
|
import { useSecurityStore } from "../store/securityStore" |
|
|
|
import { usePlatformConfig } from "../store/platformConfig" |
|
|
|
import { usePlatformConfig } from "../store/platformConfig" |
|
|
|
|
|
|
|
import { useEnrolledStore } from "../store/enrolledStore" |
|
|
|
|
|
|
|
|
|
|
|
export function useSidebarMenu() { |
|
|
|
export function useSidebarMenu() { |
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
const securityStore = useSecurityStore() |
|
|
|
const securityStore = useSecurityStore() |
|
|
|
const platformConfigStore = usePlatformConfig() |
|
|
|
const platformConfigStore = usePlatformConfig() |
|
|
|
|
|
|
|
const enrolledStore = useEnrolledStore() |
|
|
|
const showTabsSetting = platformConfigStore.getSetting("platform.show_tabs") |
|
|
|
const showTabsSetting = platformConfigStore.getSetting("platform.show_tabs") |
|
|
|
|
|
|
|
|
|
|
|
const items = [] |
|
|
|
const items = ref([]) |
|
|
|
|
|
|
|
const coursesItems = ref([]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateItems = () => { |
|
|
|
|
|
|
|
items.value = [] |
|
|
|
|
|
|
|
|
|
|
|
if (showTabsSetting.indexOf("campus_homepage") > -1) { |
|
|
|
if (showTabsSetting.indexOf("campus_homepage") > -1) { |
|
|
|
items.push({ |
|
|
|
items.value.push({ |
|
|
|
icon: "mdi mdi-home", |
|
|
|
icon: "mdi mdi-home", |
|
|
|
label: t("Home"), |
|
|
|
label: t("Home"), |
|
|
|
to: { name: "Home" }, |
|
|
|
to: { name: "Home" }, |
|
|
@ -20,25 +26,18 @@ export function useSidebarMenu() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (securityStore.isAuthenticated) { |
|
|
|
if (securityStore.isAuthenticated) { |
|
|
|
if (showTabsSetting.indexOf("campus_homepage") > -1) { |
|
|
|
if (coursesItems.value.length > 0) { |
|
|
|
items.push({ |
|
|
|
const coursesMenu = { |
|
|
|
icon: "mdi mdi-book-open-page-variant", |
|
|
|
icon: "mdi mdi-book-open-page-variant", |
|
|
|
items: [ |
|
|
|
label: coursesItems.value.length > 1 ? t("Courses") : coursesItems.value[0].label, |
|
|
|
{ |
|
|
|
items: coursesItems.value.length > 1 ? coursesItems.value : undefined, |
|
|
|
label: t("My courses"), |
|
|
|
to: coursesItems.value.length === 1 ? coursesItems.value[0].to : undefined, |
|
|
|
to: { name: "MyCourses" }, |
|
|
|
} |
|
|
|
}, |
|
|
|
items.value.push(coursesMenu) |
|
|
|
{ |
|
|
|
|
|
|
|
label: t("My sessions"), |
|
|
|
|
|
|
|
to: { name: "MySessions" }, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
label: t("Courses"), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (showTabsSetting.indexOf("my_agenda") > -1) { |
|
|
|
if (showTabsSetting.indexOf("my_agenda") > -1) { |
|
|
|
items.push({ |
|
|
|
items.value.push({ |
|
|
|
icon: "mdi mdi-calendar-text", |
|
|
|
icon: "mdi mdi-calendar-text", |
|
|
|
label: t("Events"), |
|
|
|
label: t("Events"), |
|
|
|
to: { name: "CCalendarEventList" }, |
|
|
|
to: { name: "CCalendarEventList" }, |
|
|
@ -65,7 +64,7 @@ export function useSidebarMenu() { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
items.push({ |
|
|
|
items.value.push({ |
|
|
|
icon: "mdi mdi-chart-box", |
|
|
|
icon: "mdi mdi-chart-box", |
|
|
|
label: t("Reporting"), |
|
|
|
label: t("Reporting"), |
|
|
|
items: subItems, |
|
|
|
items: subItems, |
|
|
@ -73,7 +72,7 @@ export function useSidebarMenu() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (showTabsSetting.indexOf("social") > -1) { |
|
|
|
if (showTabsSetting.indexOf("social") > -1) { |
|
|
|
items.push({ |
|
|
|
items.value.push({ |
|
|
|
icon: "mdi mdi-sitemap-outline", |
|
|
|
icon: "mdi mdi-sitemap-outline", |
|
|
|
label: t("Social network"), |
|
|
|
label: t("Social network"), |
|
|
|
to: { name: "SocialWall" }, |
|
|
|
to: { name: "SocialWall" }, |
|
|
@ -81,7 +80,7 @@ export function useSidebarMenu() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (platformConfigStore.plugins?.bbb?.show_global_conference_link) { |
|
|
|
if (platformConfigStore.plugins?.bbb?.show_global_conference_link) { |
|
|
|
items.push({ |
|
|
|
items.value.push({ |
|
|
|
icon: "mdi mdi-video", |
|
|
|
icon: "mdi mdi-video", |
|
|
|
label: t("Videoconference"), |
|
|
|
label: t("Videoconference"), |
|
|
|
url: platformConfigStore.plugins.bbb.listingURL, |
|
|
|
url: platformConfigStore.plugins.bbb.listingURL, |
|
|
@ -90,7 +89,7 @@ export function useSidebarMenu() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (securityStore.isStudentBoss || securityStore.isStudent) { |
|
|
|
if (securityStore.isStudentBoss || securityStore.isStudent) { |
|
|
|
items.push({ |
|
|
|
items.value.push({ |
|
|
|
icon: "mdi mdi-text-box-search", |
|
|
|
icon: "mdi mdi-text-box-search", |
|
|
|
items: [ |
|
|
|
items: [ |
|
|
|
{ |
|
|
|
{ |
|
|
@ -139,12 +138,41 @@ export function useSidebarMenu() { |
|
|
|
url: "/main/session/session_list.php", |
|
|
|
url: "/main/session/session_list.php", |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
items.push({ |
|
|
|
items.value.push({ |
|
|
|
icon: "mdi mdi-cog", |
|
|
|
icon: "mdi mdi-cog", |
|
|
|
items: adminItems, |
|
|
|
items: adminItems, |
|
|
|
label: t("Administration"), |
|
|
|
label: t("Administration"), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const updateCoursesItems = () => { |
|
|
|
|
|
|
|
coursesItems.value = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enrolledStore.isEnrolledInCourses) { |
|
|
|
|
|
|
|
coursesItems.value.push({ |
|
|
|
|
|
|
|
label: t("My courses"), |
|
|
|
|
|
|
|
to: { name: "MyCourses" }, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enrolledStore.isEnrolledInSessions) { |
|
|
|
|
|
|
|
coursesItems.value.push({ |
|
|
|
|
|
|
|
label: t("My sessions"), |
|
|
|
|
|
|
|
to: { name: "MySessions" }, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateItems(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
|
|
|
|
await enrolledStore.initialize(); |
|
|
|
|
|
|
|
updateCoursesItems(); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch(() => enrolledStore.isEnrolledInCourses, updateCoursesItems) |
|
|
|
|
|
|
|
watch(() => enrolledStore.isEnrolledInSessions, updateCoursesItems) |
|
|
|
|
|
|
|
|
|
|
|
return items |
|
|
|
return items |
|
|
|
} |
|
|
|
} |
|
|
|