From 6d611003827e945d2b6b725a1d5cb8768068fdcc Mon Sep 17 00:00:00 2001 From: MOHANKUMAR T <31698165+mohan-13@users.noreply.github.com> Date: Wed, 21 Aug 2024 06:59:05 +0530 Subject: [PATCH] BAH-4062 | Add. Pass currentUser to IPD Dashboard scope (#999) * BAH-4062 | Add. Pass currentUser to IPD Dashboard scope * BAH-4062 | Fix. Unit tests for current user context --- ui/app/adt/controllers/adtController.js | 1 + ui/app/adt/controllers/careViewController.js | 1 + ui/app/bedmanagement/controllers/careViewController.js | 3 ++- ui/app/clinical/common/controllers/visitController.js | 1 + ui/test/unit/adt/controllers/careViewController.spec.js | 5 +++-- .../bedmanagement/controllers/careViewController.spec.js | 5 +++-- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/app/adt/controllers/adtController.js b/ui/app/adt/controllers/adtController.js index 8c9e27945d..9c131a8c1f 100644 --- a/ui/app/adt/controllers/adtController.js +++ b/ui/app/adt/controllers/adtController.js @@ -19,6 +19,7 @@ angular.module('bahmni.adt') $scope.getAdtConceptConfig = $scope.dashboardConfig.conceptName; $scope.hostData = { patient: $scope.patient, + currentUser: $rootScope.currentUser, provider: $rootScope.currentProvider }; diff --git a/ui/app/adt/controllers/careViewController.js b/ui/app/adt/controllers/careViewController.js index 2a8bb41750..93c8964551 100644 --- a/ui/app/adt/controllers/careViewController.js +++ b/ui/app/adt/controllers/careViewController.js @@ -13,6 +13,7 @@ angular.module('bahmni.adt') $window.addEventListener('keydown', handleLogoutShortcut); $scope.$on('$destroy', cleanup); $scope.hostData = { + currentUser: $rootScope.currentUser, provider: $rootScope.currentProvider }; $scope.hostApi = { diff --git a/ui/app/bedmanagement/controllers/careViewController.js b/ui/app/bedmanagement/controllers/careViewController.js index e2f2d664d9..fc69e24020 100644 --- a/ui/app/bedmanagement/controllers/careViewController.js +++ b/ui/app/bedmanagement/controllers/careViewController.js @@ -13,7 +13,8 @@ angular.module('bahmni.ipd') $window.addEventListener('keydown', handleLogoutShortcut); $scope.$on('$destroy', cleanup); $scope.hostData = { - provider: $rootScope.currentProvider + provider: $rootScope.currentProvider, + currentUser: $rootScope.currentUser }; $scope.hostApi = { onHome: function () { diff --git a/ui/app/clinical/common/controllers/visitController.js b/ui/app/clinical/common/controllers/visitController.js index 69991d2a59..907d2694bf 100644 --- a/ui/app/clinical/common/controllers/visitController.js +++ b/ui/app/clinical/common/controllers/visitController.js @@ -38,6 +38,7 @@ angular.module('bahmni.clinical') visitSummary: $scope.visitSummary, forDate: new Date().toUTCString(), provider: $rootScope.currentProvider, + currentUser: $rootScope.currentUser, visitUuid: $scope.visitUuid, isReadMode: $scope.isIpdReadMode, source: $location.search().source diff --git a/ui/test/unit/adt/controllers/careViewController.spec.js b/ui/test/unit/adt/controllers/careViewController.spec.js index 62d38cae82..fd2be6b4c8 100644 --- a/ui/test/unit/adt/controllers/careViewController.spec.js +++ b/ui/test/unit/adt/controllers/careViewController.spec.js @@ -26,11 +26,12 @@ describe("CareViewController", function () { then: function() { } }); let mockProvider = {name: "__test__provider"} + let mockUser = {name: "__test__user"} var createController = function () { controller('CareViewController', { $scope: scope, - $rootScope: {currentProvider: mockProvider, quickLogoutComboKey: 'Escape', cookieExpiryTime:30}, + $rootScope: {currentProvider: mockProvider, quickLogoutComboKey: 'Escape', cookieExpiryTime:30, currentUser: mockUser}, $state: state, auditLogService: auditLogService, sessionService: sessionService, @@ -40,7 +41,7 @@ describe("CareViewController", function () { it('should create host data and host api', function (){ createController(); - expect(scope.hostData).toEqual({provider: mockProvider}); + expect(scope.hostData).toEqual({provider: mockProvider, currentUser: mockUser}); expect(scope.hostApi).not.toBeNull(); }); diff --git a/ui/test/unit/bedmanagement/controllers/careViewController.spec.js b/ui/test/unit/bedmanagement/controllers/careViewController.spec.js index c2180dfaf9..8a2fd33274 100644 --- a/ui/test/unit/bedmanagement/controllers/careViewController.spec.js +++ b/ui/test/unit/bedmanagement/controllers/careViewController.spec.js @@ -18,11 +18,12 @@ describe("CareViewController", function () { then: function() { } }); let mockProvider = {name: "__test__provider"} + let mockUser = { name: "__test__user" } var createController = function () { controller('CareViewController', { $scope: scope, - $rootScope: {currentProvider: mockProvider, quickLogoutComboKey: 'Escape', cookieExpiryTime:30}, + $rootScope: {currentProvider: mockProvider, quickLogoutComboKey: 'Escape', cookieExpiryTime:30, currentUser: mockUser}, $state: state, auditLogService: auditLogService, sessionService: sessionService, @@ -32,7 +33,7 @@ describe("CareViewController", function () { it('should create host data and host api', function (){ createController(); - expect(scope.hostData).toEqual({provider: mockProvider}); + expect(scope.hostData).toEqual({provider: mockProvider, currentUser: mockUser}); expect(scope.hostApi).not.toBeNull(); });