From d089e389f11b9cbba376e09c9101c8b462c3ea30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20=C3=96hlerking?= <103562092+MarvinOehlerkingCap@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:47:58 +0200 Subject: [PATCH] N21-1206 show classes and goups (#3305) * add new classes sidebar item * add class new to teacher and dashboard --- config/default.schema.json | 5 + config/global.js | 2 + helpers/handlebars/middleware.js | 217 +++++++++++++++++------------ locales/de.json | 2 + locales/en.json | 2 + locales/es.json | 2 + locales/uk.json | 2 + views/administration/dashboard.hbs | 13 ++ 8 files changed, 156 insertions(+), 89 deletions(-) diff --git a/config/default.schema.json b/config/default.schema.json index f7a82f5bf8..671afe11fa 100644 --- a/config/default.schema.json +++ b/config/default.schema.json @@ -592,6 +592,11 @@ "type": "boolean", "default": false, "description": "Changes the login flow to one that supports user login migrations" + }, + "FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED": { + "type": "boolean", + "default": false, + "description": "Enables the new class list view" } }, "allOf": [ diff --git a/config/global.js b/config/global.js index 2f504b1346..0b47c56e7d 100644 --- a/config/global.js +++ b/config/global.js @@ -39,6 +39,7 @@ const { FEATURE_NEW_SCHOOL_ADMINISTRATION_PAGE_AS_DEFAULT_ENABLED, FEATURE_ALERTS_ON_HOMEPAGE_ENABLED, FEATURE_BUTTONS_ON_LOGINPAGE_ENABLED, + FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED, } = process.env; const exp = { @@ -80,6 +81,7 @@ const exp = { FEATURE_NEW_SCHOOL_ADMINISTRATION_PAGE_AS_DEFAULT_ENABLED, FEATURE_ALERTS_ON_HOMEPAGE_ENABLED, FEATURE_BUTTONS_ON_LOGINPAGE_ENABLED, + FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED, }; // eslint-disable-next-line no-console diff --git a/helpers/handlebars/middleware.js b/helpers/handlebars/middleware.js index 32e18518ed..c3549eede1 100644 --- a/helpers/handlebars/middleware.js +++ b/helpers/handlebars/middleware.js @@ -7,6 +7,7 @@ const { NOTIFICATION_SERVICE_ENABLED, FEATURE_TEAMS_ENABLED, FEATURE_NEW_SCHOOL_ADMINISTRATION_PAGE_AS_DEFAULT_ENABLED, + FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED, } = require('../../config/global'); const makeActive = (items, currentUrl) => { @@ -161,6 +162,72 @@ module.exports = (req, res, next) => { } // teacher views + const newClassViewEnabled = FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED === 'true'; + const teacherChildren = [ + { + name: res.$t('global.link.administrationStudents'), + testId: 'Schüler:innen', + icon: 'account-school-outline', + link: '/administration/students/', + }, + { + name: res.$t('global.link.managementTeachers'), + testId: 'Lehrkräfte', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/teachers/', + }, + { + name: res.$t('global.sidebar.link.administrationClasses'), + testId: 'Klassen', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/classes/', + }, + ]; + + // teacher views + const teacherChildrenWithoutStudents = [ + { + name: res.$t('global.link.managementTeachers'), + testId: 'Lehrkräfte', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/teachers/', + }, + { + name: res.$t('global.sidebar.link.administrationClasses'), + testId: 'Klassen', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/classes/', + }, + ]; + + if (newClassViewEnabled) { + teacherChildren.splice(3, 0, { + name: res.$t('global.sidebar.link.administrationClassesNew'), + testId: 'Klassen (neu)', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/groups/classes', + }); + + teacherChildrenWithoutStudents.splice(2, 0, { + name: res.$t('global.sidebar.link.administrationClassesNew'), + testId: 'Klassen (neu)', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/groups/classes', + }); + } + res.locals.sidebarItems.push({ name: res.$t('global.link.management'), testId: 'Verwaltung', @@ -168,33 +235,9 @@ module.exports = (req, res, next) => { link: '/administration/', permission: 'STUDENT_LIST', excludedPermission: 'ADMIN_VIEW', - children: [ - { - name: res.$t('global.link.administrationStudents'), - testId: 'Schüler:innen', - icon: 'account-school-outline', - link: '/administration/students/', - }, - { - name: res.$t('global.link.managementTeachers'), - testId: 'Lehrkräfte', - icon: // eslint-disable-next-line max-len - '', - isExternalIcon: true, - link: '/administration/teachers/', - }, - { - name: res.$t('global.sidebar.link.administrationClasses'), - testId: 'Klassen', - icon: // eslint-disable-next-line max-len - '', - isExternalIcon: true, - link: '/administration/classes/', - }, - ], + children: teacherChildren, }); - // teacher views res.locals.sidebarItems.push({ name: res.$t('global.link.management'), testId: 'Verwaltung', @@ -202,80 +245,76 @@ module.exports = (req, res, next) => { link: '/administration/', permission: 'TEACHER_LIST', excludedPermission: ['ADMIN_VIEW', 'STUDENT_LIST'], - children: [ - { - name: res.$t('global.link.managementTeachers'), - testId: 'Lehrkräfte', - icon: // eslint-disable-next-line max-len - '', - isExternalIcon: true, - link: '/administration/teachers/', - }, - { - name: res.$t('global.sidebar.link.administrationClasses'), - testId: 'Klassen', - icon: // eslint-disable-next-line max-len - '', - isExternalIcon: true, - link: '/administration/classes/', - }, - ], + children: teacherChildrenWithoutStudents, }); // admin views const newSchoolAdminPageAsDefault = FEATURE_NEW_SCHOOL_ADMINISTRATION_PAGE_AS_DEFAULT_ENABLED === 'true'; + const adminChildItems = [ + { + name: res.$t('global.link.administrationStudents'), + testId: 'Schüler:innen', + icon: 'account-school-outline', + link: '/administration/students/', + }, + { + name: res.$t('global.link.managementTeachers'), + testId: 'Lehrkräfte', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/teachers/', + }, + { + name: res.$t('global.sidebar.link.administrationCourses'), + testId: 'Kurse', + icon: 'school-outline', + link: '/administration/courses/', + }, + { + name: res.$t('global.sidebar.link.administrationClasses'), + testId: 'Klassen', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/classes/', + }, + { + name: res.$t('global.link.teams'), + testId: 'Teams', + icon: 'account-group-outline', + link: '/administration/teams/', + }, + { + name: res.$t('global.link.school'), + testId: 'Schule', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: newSchoolAdminPageAsDefault + ? '/administration/school-settings/' + : '/administration/school/', + }, + ]; + + if (newClassViewEnabled) { + adminChildItems.splice(4, 0, { + name: res.$t('global.sidebar.link.administrationClassesNew'), + testId: 'Klassen (neu)', + icon: // eslint-disable-next-line max-len + '', + isExternalIcon: true, + link: '/administration/groups/classes', + }); + } + res.locals.sidebarItems.push({ name: res.$t('global.link.management'), testId: 'Verwaltung', icon: 'cog-outline', link: '/administration/', permission: 'ADMIN_VIEW', - children: [ - { - name: res.$t('global.link.administrationStudents'), - testId: 'Schüler:innen', - icon: 'account-school-outline', - link: '/administration/students/', - }, - { - name: res.$t('global.link.managementTeachers'), - testId: 'Lehrkräfte', - icon: // eslint-disable-next-line max-len - '', - isExternalIcon: true, - link: '/administration/teachers/', - }, - { - name: res.$t('global.sidebar.link.administrationCourses'), - testId: 'Kurse', - icon: 'school-outline', - link: '/administration/courses/', - }, - { - name: res.$t('global.sidebar.link.administrationClasses'), - testId: 'Klassen', - icon: // eslint-disable-next-line max-len - '', - isExternalIcon: true, - link: '/administration/classes/', - }, - { - name: res.$t('global.link.teams'), - testId: 'Teams', - icon: 'account-group-outline', - link: '/administration/teams/', - }, - { - name: res.$t('global.link.school'), - testId: 'Schule', - icon: // eslint-disable-next-line max-len - '', - isExternalIcon: true, - link: newSchoolAdminPageAsDefault - ? '/administration/school-settings/' - : '/administration/school/', - }, - ], + children: adminChildItems, }); // beta user view diff --git a/locales/de.json b/locales/de.json index 0159c6ea5e..aa62b14609 100644 --- a/locales/de.json +++ b/locales/de.json @@ -304,6 +304,7 @@ "dashboard": { "headline": { "manageClasses": "Klassen verwalten", + "manageClassesNew": "Klassen verwalten (neu)", "manageCourses": "Kurse verwalten", "manageSchool": "Schule verwalten", "manageStudents": "Schüler:innen verwalten", @@ -1751,6 +1752,7 @@ "addons": "Add-ons", "administration": "Administration", "administrationClasses": "Klassen", + "administrationClassesNew": "Klassen (neu)", "administrationCourses": "Kurse" } }, diff --git a/locales/en.json b/locales/en.json index ce60fd5614..d8af166ef5 100644 --- a/locales/en.json +++ b/locales/en.json @@ -304,6 +304,7 @@ "dashboard": { "headline": { "manageClasses": "Manage classes", + "manageClassesNew": "Manage classes (new)", "manageCourses": "Manage courses", "manageSchool": "Manage school", "manageStudents": "Manage students", @@ -1751,6 +1752,7 @@ "addons": "Add-ons", "administration": "Administration", "administrationClasses": "Classes", + "administrationClassesNew": "Classes (new)", "administrationCourses": "Courses" } }, diff --git a/locales/es.json b/locales/es.json index 2c0b16f1bc..097bbd9fc9 100644 --- a/locales/es.json +++ b/locales/es.json @@ -304,6 +304,7 @@ "dashboard": { "headline": { "manageClasses": "Administrar clases", + "manageClassesNew": "Administrar clases (nuevo)", "manageCourses": "Administrar cursos", "manageSchool": "Administrar escuela", "manageStudents": "Administrar estudiantes", @@ -1751,6 +1752,7 @@ "addons": "Complementos", "administration": "Administración", "administrationClasses": "Clases", + "administrationClassesNew": "Clases (nuevo)", "administrationCourses": "Cursos" } }, diff --git a/locales/uk.json b/locales/uk.json index b15e07e46e..2340eaffd2 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -252,6 +252,7 @@ "link": { "addons": "Доповнення", "administrationClasses": "Класи", + "administrationClassesNew": "Класи (новий)", "administrationCourses": "Курси", "administration": "Адміністрація" } @@ -1285,6 +1286,7 @@ "dashboard": { "headline": { "manageClasses": "Керувати класами", + "manageClassesNew": "Керувати класами (нове)", "manageCourses": "Керувати курсами", "manageSchool": "Керувати школою", "manageStudents": "Керувати учнями", diff --git a/views/administration/dashboard.hbs b/views/administration/dashboard.hbs index 453c300cd5..ee9cd93571 100644 --- a/views/administration/dashboard.hbs +++ b/views/administration/dashboard.hbs @@ -58,6 +58,19 @@ {{/userHasPermission}} + {{#userHasPermission 'CLASS_LIST'}} + {{#if (getConfig "FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED")}} +
+ +
+ {{/if}} + {{/userHasPermission}} {{#userHasPermission 'ADMIN_VIEW'}}