From bf6e028feb82a0aa9308dae55c6e23a144198b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20=C3=96hlerking?= Date: Fri, 15 Sep 2023 14:03:41 +0200 Subject: [PATCH 1/3] add new classes sidebar item --- config/default.schema.json | 5 ++ config/global.js | 2 + helpers/handlebars/middleware.js | 107 ++++++++++++++++++------------- locales/de.json | 1 + locales/en.json | 1 + locales/es.json | 1 + locales/uk.json | 1 + 7 files changed, 72 insertions(+), 46 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..1a7f168e07 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) => { @@ -224,58 +225,72 @@ module.exports = (req, res, next) => { // admin views const newSchoolAdminPageAsDefault = FEATURE_NEW_SCHOOL_ADMINISTRATION_PAGE_AS_DEFAULT_ENABLED === 'true'; + let 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/', + }, + ]; + + const newClassViewEnabled = FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED === 'true'; + if (newClassViewEnabled) { + adminChildItems = 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 ca4a844af3..57fd8e6d30 100644 --- a/locales/de.json +++ b/locales/de.json @@ -1748,6 +1748,7 @@ "addons": "Add-ons", "administration": "Administration", "administrationClasses": "Klassen", + "administrationClassesNew": "Klassen (neu)", "administrationCourses": "Kurse" } }, diff --git a/locales/en.json b/locales/en.json index f5770fd808..3d34118deb 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1748,6 +1748,7 @@ "addons": "Add-ons", "administration": "Administration", "administrationClasses": "Classes", + "administrationClassesNew": "Classes (new)", "administrationCourses": "Courses" } }, diff --git a/locales/es.json b/locales/es.json index 249aa0c180..fde84c06ff 100644 --- a/locales/es.json +++ b/locales/es.json @@ -1748,6 +1748,7 @@ "addons": "Complementos", "administration": "Administración", "administrationClasses": "Clases", + "administrationClassesNew": "Clases (nuevo)", "administrationCourses": "Cursos" } }, diff --git a/locales/uk.json b/locales/uk.json index 2940d35f1d..eedf02773d 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -252,6 +252,7 @@ "link": { "addons": "Доповнення", "administrationClasses": "Класи", + "administrationClassesNew": "Класи (новий)", "administrationCourses": "Курси", "administration": "Адміністрація" } From 4c28b91798ec5afe95f1fab0eda70456f4c3b7f6 Mon Sep 17 00:00:00 2001 From: Malte Berg Date: Thu, 21 Sep 2023 13:22:15 +0200 Subject: [PATCH 2/3] fix sidebar --- helpers/handlebars/middleware.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers/handlebars/middleware.js b/helpers/handlebars/middleware.js index 1a7f168e07..09b07d727d 100644 --- a/helpers/handlebars/middleware.js +++ b/helpers/handlebars/middleware.js @@ -225,7 +225,7 @@ module.exports = (req, res, next) => { // admin views const newSchoolAdminPageAsDefault = FEATURE_NEW_SCHOOL_ADMINISTRATION_PAGE_AS_DEFAULT_ENABLED === 'true'; - let adminChildItems = [ + const adminChildItems = [ { name: res.$t('global.link.administrationStudents'), testId: 'Schüler:innen', @@ -274,7 +274,7 @@ module.exports = (req, res, next) => { const newClassViewEnabled = FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED === 'true'; if (newClassViewEnabled) { - adminChildItems = adminChildItems.splice(4, 0, { + adminChildItems.splice(4, 0, { name: res.$t('global.sidebar.link.administrationClassesNew'), testId: 'Klassen (neu)', icon: // eslint-disable-next-line max-len From 04711dc441a0e47afaa2fd3383fe1a98382d5eb0 Mon Sep 17 00:00:00 2001 From: Malte Berg Date: Thu, 21 Sep 2023 16:30:26 +0200 Subject: [PATCH 3/3] add class new to teacher and dashboard --- helpers/handlebars/middleware.js | 112 +++++++++++++++++------------ locales/de.json | 1 + locales/en.json | 1 + locales/es.json | 1 + locales/uk.json | 1 + views/administration/dashboard.hbs | 13 ++++ 6 files changed, 85 insertions(+), 44 deletions(-) diff --git a/helpers/handlebars/middleware.js b/helpers/handlebars/middleware.js index 09b07d727d..c3549eede1 100644 --- a/helpers/handlebars/middleware.js +++ b/helpers/handlebars/middleware.js @@ -162,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', @@ -169,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', @@ -203,24 +245,7 @@ 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 @@ -272,7 +297,6 @@ module.exports = (req, res, next) => { }, ]; - const newClassViewEnabled = FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED === 'true'; if (newClassViewEnabled) { adminChildItems.splice(4, 0, { name: res.$t('global.sidebar.link.administrationClassesNew'), diff --git a/locales/de.json b/locales/de.json index 04377b4669..ca01172bdc 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", diff --git a/locales/en.json b/locales/en.json index 4d632f870f..a7c7ad6805 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", diff --git a/locales/es.json b/locales/es.json index 7d54da511c..a312a8b4b3 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", diff --git a/locales/uk.json b/locales/uk.json index ec65994831..c9e57c5014 100644 --- a/locales/uk.json +++ b/locales/uk.json @@ -1284,6 +1284,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'}}