Skip to content

Commit

Permalink
Parvathy | BAH-2359 | Fix. Eslint issues and test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
parvathy00 committed Jul 28, 2023
1 parent 66d4249 commit 95d10ad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ui/app/clinical/consultation/directives/alertOnExit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular.module('bahmni.clinical')
var uuid = $state.params.patientUuid;
var currentUuid = current.patientUuid;
var isNavigating = exitAlertService.setIsNavigating(next, uuid, currentUuid);
$state.dirtyConsultationForm = $state.discardChanges ? false : $state.dirtyConsultationForm;
$state.dirtyConsultationForm = $state.discardChanges ? false : $state.dirtyConsultationForm;
exitAlertService.showExitAlert(isNavigating, $state.dirtyConsultationForm, event, next.spinnerToken);
});
}
Expand Down
9 changes: 4 additions & 5 deletions ui/app/common/concept-set/directives/formControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,19 @@ angular.module('bahmni.common.conceptSet')
$state.dirtyForm = true;
return;
}
for(var i=0;i<$scope.form.observations.length;i++) {
for (var i = 0; i < $scope.form.observations.length; i++) {
var formObservation = $scope.form.observations[i];
for (var j = 0; j < $scope.$parent.consultation.observations.length; j++) {
var consultationObservation = $scope.$parent.consultation.observations[j];
if((consultationObservation.value == formObservation.value) || (consultationObservation.value.uuid && formObservation.value.uuid && (consultationObservation.value.uuid == formObservation.value.uuid))) {
if ((consultationObservation.value == formObservation.value) || (consultationObservation.value.uuid && formObservation.value.uuid && (consultationObservation.value.uuid == formObservation.value.uuid))) {
isChanged[i] = false;
break;
} else {
isChanged[i] = true;
}

}
}
if(isChanged.includes(true)) {
if (isChanged.includes(true)) {
$state.dirtyForm = true;
}
}
Expand All @@ -118,7 +117,7 @@ angular.module('bahmni.common.conceptSet')
checkFormChanges($scope);
}
isNavigating = exitAlertService.setIsNavigating(next, uuid, currentUuid);
$state.dirtyConsultationForm = $state.discardChanges ? false : $state.dirtyForm;
$state.dirtyConsultationForm = $state.discardChanges ? false : $state.dirtyForm;
exitAlertService.showExitAlert(isNavigating, $state.dirtyConsultationForm, event, next.spinnerToken);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('alertOnExit Directive', function () {
var event = $rootScope.$broadcast('$stateChangeStart', next, current);

expect(exitAlertService.setIsNavigating).toHaveBeenCalledWith(next, 'currentPatientUuid', 'previousPatientUuid');
expect(exitAlertService.setDirtyConsultationForm).toHaveBeenCalled();
expect(exitAlertService.showExitAlert).toHaveBeenCalledWith(true, true, event, 'spinner');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe('exitAlertService', function () {
};
$state = {
newPatientUuid: '',
discardChanges: false,
dirtyConsultationForm: true
};
$location = {
Expand Down Expand Up @@ -74,23 +73,6 @@ describe('exitAlertService', function () {
expect($state.newPatientUuid).toBe(currentUuid);
});

it('should return false for setDirtyConsultationForm when discardChanges is true', function () {
$state.discardChanges = true;
expect(exitAlertService.setDirtyConsultationForm()).toBe(false);
});

it('should return true for setDirtyConsultationForm when discardChanges is false and dirtyConsultationForm is true', function () {
$state.discardChanges = false;
$state.dirtyConsultationForm = true;
expect(exitAlertService.setDirtyConsultationForm()).toBe(true);
});

it('should return false for setDirtyConsultationForm when discardChanges is false and dirtyConsultationForm is false', function () {
$state.discardChanges = false;
$state.dirtyConsultationForm = false;
expect(exitAlertService.setDirtyConsultationForm()).toBe(false);
});

it('should redirect to patient search when isPatientSearch is true', function () {
$state.isPatientSearch = true;
exitAlertService.redirectUrl();
Expand Down

0 comments on commit 95d10ad

Please sign in to comment.