Skip to content

Commit

Permalink
Merge pull request #5953 from christianbeeznest/storm-22243
Browse files Browse the repository at this point in the history
Platform: Add visibility settings for main menu and topbar entries - refs BT#22243
  • Loading branch information
NicoDucou authored Dec 5, 2024
2 parents abac015 + e426642 commit 7a938e6
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 128 deletions.
65 changes: 38 additions & 27 deletions assets/vue/components/layout/TopbarLoggedIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,44 @@ const ticketUrl = computed(() => {
})
const elUserSubmenu = ref(null)
const userSubmenuItems = computed(() => [
{
label: props.currentUser.fullName,
items: [
{
label: t("My profile"),
url: router.resolve({ name: "AccountHome" }).href,
},
{
label: t("My General Certificate"),
url: "/main/social/my_skills_report.php?a=generate_custom_skill",
},
{
label: t("My skills"),
url: "/main/social/my_skills_report.php",
},
{
separator: true,
},
{
label: t("Sign out"),
url: "/logout",
icon: "mdi mdi-logout-variant",
},
],
},
])
const userSubmenuItems = computed(() => {
const items = [
{
label: props.currentUser.fullName,
items: [
{
label: t("My profile"),
url: router.resolve({ name: "AccountHome" }).href,
},
],
},
]
if (platformConfigStore.getSetting("platform.show_tabs").indexOf("topbar_certificate") > -1) {
items[0].items.push({
label: t("My General Certificate"),
url: "/main/social/my_skills_report.php?a=generate_custom_skill",
})
}
if (platformConfigStore.getSetting("platform.show_tabs").indexOf("topbar_skills") > -1) {
items[0].items.push({
label: t("My skills"),
url: "/main/social/my_skills_report.php",
})
}
items[0].items.push(
{ separator: true },
{
label: t("Sign out"),
url: "/logout",
icon: "mdi mdi-logout-variant",
}
)
return items
})
function toggleUserMenu(event) {
elUserSubmenu.value.toggle(event)
Expand Down
172 changes: 80 additions & 92 deletions assets/vue/composables/sidebarMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,29 @@ export function useSidebarMenu() {
return false
}

const menuItemsBeforeMyCourse = computed(() => {
const items = []

if (showTabsSetting.indexOf("campus_homepage") > -1) {
items.push({
icon: "mdi mdi-home",
label: t("Home"),
route: { name: "Home" },
})
const createMenuItem = (key, icon, label, routeName, subItems = null) => {
if (showTabsSetting.indexOf(key) > -1) {
const item = {
icon: `mdi ${icon}`,
label: t(label),
}
if (routeName) item.route = { name: routeName }
if (subItems) item.items = subItems
return item
}
return null
}

return items
const menuItemsBeforeMyCourse = computed(() => {
const items = []
items.push(createMenuItem("campus_homepage", "mdi-home", "Home", "Home"))
return items.filter(Boolean)
})

const menuItemMyCourse = computed(() => {
const items = []

if (securityStore.isAuthenticated) {
if (securityStore.isAuthenticated && showTabsSetting.indexOf("my_courses") > -1) {
const courseItems = []

if (enrolledStore.isEnrolledInCourses) {
Expand Down Expand Up @@ -76,33 +81,33 @@ export function useSidebarMenu() {
const menuItemsAfterMyCourse = computed(() => {
const items = []

if (showCatalogue > -1) {
if (showTabsSetting.indexOf("catalogue") > -1) {
if (showCatalogue == 0 || showCatalogue == 2) {
items.push({
icon: "mdi mdi-bookmark-multiple",
label: t("Explore more courses"),
route: { name: "CatalogueCourses" },
})
items.push(
createMenuItem(
"catalogue",
"mdi-bookmark-multiple",
"Explore more courses",
"CatalogueCourses"
)
)
}
if (showCatalogue > 0) {
items.push({
icon: "mdi mdi-bookmark-multiple-outline",
label: t("Sessions catalogue"),
route: { name: "CatalogueSessions" },
})
items.push(
createMenuItem(
"catalogue",
"mdi-bookmark-multiple-outline",
"Sessions catalogue",
"CatalogueSessions"
)
)
}
}

if (showTabsSetting.indexOf("my_agenda") > -1) {
items.push({
icon: "mdi mdi-calendar-text",
label: t("Events"),
route: { name: "CCalendarEventList" },
})
}
items.push(createMenuItem("my_agenda", "mdi-calendar-text", "Events", "CCalendarEventList"))

if (showTabsSetting.indexOf("reporting") > -1) {
let subItems = []
const subItems = []

if (securityStore.isTeacher || securityStore.isHRM || securityStore.isSessionAdmin) {
subItems.push({
Expand Down Expand Up @@ -155,75 +160,58 @@ export function useSidebarMenu() {
})
}

if (platformConfigStore.plugins?.bbb?.show_global_conference_link) {
items.push({
icon: "mdi mdi-video",
label: t("Videoconference"),
url: platformConfigStore.plugins.bbb.listingURL,
})
}

if (securityStore.isStudentBoss || securityStore.isStudent) {
items.push({
icon: "mdi mdi-text-box-search",
items: [
{
label: t("Diagnosis Management"),
url: "/main/search/load_search.php",
visible: securityStore.isStudentBoss,
},
{
label: t("Diagnostic Form"),
url: "/main/search/search.php",
},
],
label: t("Diagnosis"),
})
}

if (securityStore.isAdmin || securityStore.isSessionAdmin) {
const adminItems = [
items.push(
createMenuItem(
"videoconference",
"mdi-video",
"Videoconference",
null,
platformConfigStore.plugins?.bbb?.show_global_conference_link
? [
{
label: t("Conference Room"),
url: platformConfigStore.plugins.bbb.listingURL,
},
]
: null
)
)

items.push(
createMenuItem("diagnostics", "mdi-text-box-search", "Diagnosis Management", null, [
{
label: t("Administration"),
route: { name: "AdminIndex" },
label: t("Diagnosis Management"),
url: "/main/search/load_search.php",
visible: securityStore.isStudentBoss,
},
]

if (
securityStore.isSessionAdmin &&
"true" === platformConfigStore.getSetting("session.limit_session_admin_list_users")
) {
adminItems.push({
label: t("Add user"),
url: "/main/admin/user_add.php",
})
} else {
adminItems.push({
label: t("Users"),
url: "/main/admin/user_list.php",
})
}
{
label: t("Diagnostic Form"),
url: "/main/search/search.php",
},
])
)

if (showTabsSetting.indexOf("platform_administration") > -1) {
if (securityStore.isAdmin || securityStore.isSessionAdmin) {
const adminItems = [
{ label: t("Administration"), route: { name: "AdminIndex" } },
...(securityStore.isSessionAdmin &&
"true" === platformConfigStore.getSetting("session.limit_session_admin_list_users")
? [{ label: t("Add user"), url: "/main/admin/user_add.php" }]
: [{ label: t("Users"), url: "/main/admin/user_list.php" }]),
{ label: t("Courses"), url: "/main/admin/course_list.php" },
{ label: t("Sessions"), url: "/main/session/session_list.php" },
]

if (securityStore.isAdmin) {
adminItems.push({
label: t("Courses"),
url: "/main/admin/course_list.php",
items.push({
icon: "mdi mdi-cog",
items: adminItems,
label: t("Administration"),
})
}

adminItems.push({
label: t("Sessions"),
url: "/main/session/session_list.php",
})

items.push({
icon: "mdi mdi-cog",
items: adminItems,
label: t("Administration"),
})
}

return items
return items.filter(Boolean)
})

async function initialize() {
Expand Down
20 changes: 11 additions & 9 deletions src/CoreBundle/Settings/PlatformSettingsSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
class PlatformSettingsSchema extends AbstractSettingsSchema
{
private static array $tabs = [
'TabsCampusHomepage' => 'campus_homepage',
'TabsMyCourses' => 'my_courses',
'TabsReporting' => 'reporting',
'TabsPlatformAdministration' => 'platform_administration',
'mypersonalopenarea' => 'my_agenda',
'TabsMyAgenda' => 'my_profile',
'TabsMyGradebook' => 'my_gradebook',
'TabsSocial' => 'social',
'TabsDashboard' => 'dashboard',
'MenuCampusHomepage' => 'campus_homepage',
'MenuMyCourses' => 'my_courses',
'MenuReporting' => 'reporting',
'MenuPlatformAdministration' => 'platform_administration',
'MenuMyAgenda' => 'my_agenda',
'MenuSocial' => 'social',
'MenuVideoConference' => 'videoconference',
'MenuDiagnostics' => 'diagnostics',
'MenuCatalogue' => 'catalogue',
'TopbarCertificate' => 'topbar_certificate',
'TopbarSkills' => 'topbar_skills',
];

public function buildSettings(AbstractSettingsBuilder $builder): void
Expand Down

0 comments on commit 7a938e6

Please sign in to comment.