Skip to content

Commit

Permalink
BAH-4062 | Add. Pass currentUser to IPD Dashboard scope (#999)
Browse files Browse the repository at this point in the history
* BAH-4062 | Add. Pass currentUser to IPD Dashboard scope

* BAH-4062 | Fix. Unit tests for current user context
  • Loading branch information
mohan-13 authored Aug 21, 2024
1 parent 03f75a3 commit 6d61100
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions ui/app/adt/controllers/adtController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ angular.module('bahmni.adt')
$scope.getAdtConceptConfig = $scope.dashboardConfig.conceptName;
$scope.hostData = {
patient: $scope.patient,
currentUser: $rootScope.currentUser,
provider: $rootScope.currentProvider
};

Expand Down
1 change: 1 addition & 0 deletions ui/app/adt/controllers/careViewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion ui/app/bedmanagement/controllers/careViewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
1 change: 1 addition & 0 deletions ui/app/clinical/common/controllers/visitController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ui/test/unit/adt/controllers/careViewController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
});

Expand Down

0 comments on commit 6d61100

Please sign in to comment.