From c5a8d798ce8f226db3470eaef50e3e0c84567491 Mon Sep 17 00:00:00 2001 From: olewandowski1 Date: Thu, 9 Jan 2025 12:19:26 +0100 Subject: [PATCH] SELV3-792: adjust the naming of the rights when a role is of the reports type --- src/admin-role-form/right.filter.js | 29 ++++++++++++++++++++++++++--- src/admin-role-form/role-form.html | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/admin-role-form/right.filter.js b/src/admin-role-form/right.filter.js index 0966a3ac..d66875c3 100644 --- a/src/admin-role-form/right.filter.js +++ b/src/admin-role-form/right.filter.js @@ -41,15 +41,38 @@ .module('admin-role-form') .filter('right', roleRightFilter); - roleRightFilter.$inject = ['messageService', '$filter']; + roleRightFilter.$inject = ['messageService', '$filter', 'ROLE_TYPES']; - function roleRightFilter(messageService, $filter) { - return function(rightName) { + function roleRightFilter(messageService, $filter, ROLE_TYPES) { + return function(rightName, roleType) { if (!rightName) { return undefined; } + + if (roleType === ROLE_TYPES.REPORTS) { + return createReportRightName(rightName); + } + return messageService.get('adminRoleForm.' + $filter('camelCase')(rightName)); }; } + /** + * @ngdoc method + * @methodOf admin-role-form.filter:right + * @name createReportRightName + * + * @description + * Formats the given right name into more user-friendly string. First, it replaces all underscores. Then, it + * lowercases the string, splits it by spaces, capitalizes the first letter of each word, and joins them back. + */ + function createReportRightName(rightName) { + return rightName + .replace(/_/g, ' ') + .toLowerCase() + .split(' ') + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); + } + })(); diff --git a/src/admin-role-form/role-form.html b/src/admin-role-form/role-form.html index 3d9686e1..f3e766a1 100644 --- a/src/admin-role-form/role-form.html +++ b/src/admin-role-form/role-form.html @@ -12,7 +12,7 @@

{{(vm.role.id ? 'adminRoleForm.updateRole' : 'adminRoleForm.createRole') | m Rights