Skip to content

Commit

Permalink
Parvathy | BAH-2359 | Fix. dependency injection issue
Browse files Browse the repository at this point in the history
* Parvathy | BAH-2359 | Fix. dependency injection issue

* Parvathy | BAH-2359 | Fix. failing tests
  • Loading branch information
parvathy00 authored Aug 23, 2023
1 parent 7c41377 commit a8b4211
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
7 changes: 2 additions & 5 deletions ui/app/clinical/consultation/services/exitAlertService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('bahmni.clinical')
.factory('exitAlertService', ['messagingService', 'spinner', '$state', '$location',
function (messagingService, spinner, $state, $location) {
.factory('exitAlertService', ['messagingService', 'spinner', '$state',
function (messagingService, spinner, $state) {
return {
showExitAlert: function (isNavigating, dirtyConsultationForm, event, spinnerToken) {
if (isNavigating && dirtyConsultationForm) {
Expand All @@ -14,9 +14,6 @@ angular.module('bahmni.clinical')
$state.newPatientUuid = currentUuid;
next.url.includes("/patient/search") ? $state.isPatientSearch = true : $state.isPatientSearch = false;
return (next.url.includes("/patient/search") || (uuid !== currentUuid));
},
redirectUrl: function () {
return $state.isPatientSearch ? $location.path('/default/patient/search') : $location.path('/default/patient/' + $state.newPatientUuid + "/dashboard");
}
};
}
Expand Down
6 changes: 3 additions & 3 deletions ui/app/common/ui-helper/controllers/messageController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

angular.module("bahmni.common.uiHelper").controller("MessageController", [ "$scope", "messagingService", "$translate", "$state", "exitAlertService",
function ($scope, messagingService, $translate, $state, exitAlertService) {
angular.module("bahmni.common.uiHelper").controller("MessageController", [ "$scope", "messagingService", "$translate", "$state", "$location",
function ($scope, messagingService, $translate, $state, $location) {
$scope.messages = messagingService.messages;

$scope.getMessageText = function (level) {
Expand Down Expand Up @@ -35,7 +35,7 @@ angular.module("bahmni.common.uiHelper").controller("MessageController", [ "$sco
$scope.discardChanges = function (level) {
$state.discardChanges = true;
$scope.hideMessage(level);
exitAlertService.redirectUrl();
return $state.isPatientSearch ? $location.path('/default/patient/search') : $location.path('/default/patient/' + $state.newPatientUuid + "/dashboard");
};
}
]);
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,4 @@ describe('exitAlertService', function () {
expect($state.newPatientUuid).toBe(currentUuid);
});

it('should redirect to patient search when isPatientSearch is true', function () {
$state.isPatientSearch = true;
exitAlertService.redirectUrl();
expect($location.path).toHaveBeenCalledWith('/default/patient/search');
});

it('should redirect to patient dashboard when isPatientSearch is false', function () {
$state.isPatientSearch = false;
$state.newPatientUuid = 'newPatientUuid';
exitAlertService.redirectUrl();
expect($location.path).toHaveBeenCalledWith('/default/patient/newPatientUuid/dashboard');
});
});

0 comments on commit a8b4211

Please sign in to comment.