← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22241: tracker-capture: can not clear values of mandatory data elements

 

------------------------------------------------------------
revno: 22241
committer: Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-03-10 17:56:46 +0100
message:
  tracker-capture: can not clear values of mandatory data elements
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-03-01 16:47:58 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-03-10 16:56:46 +0000
@@ -1307,7 +1307,17 @@
             //check for input validity
             $scope.updateSuccess = false;
         }
-        if (field && field.$invalid && angular.isDefined(value) && value !== "") {
+        
+        var oldValue = null;
+        for(var i=0; i<$scope.currentStageEventsOriginal.length; i++){
+            if($scope.currentStageEventsOriginal[i].event === eventToSave.event) {
+                oldValue = $scope.currentStageEventsOriginal[i][prStDe.dataElement.id];
+                break;
+            }
+        }
+        
+        if (field && field.$invalid) {
+            $scope.currentEvent[prStDe.dataElement.id] = oldValue;
             $scope.currentElement = {id: prStDe.dataElement.id, saved: false, event: eventToSave.event};
             return false;
         }
@@ -1315,13 +1325,6 @@
         //input is valid
         var value = eventToSave[prStDe.dataElement.id];
 
-        var oldValue = null;
-        angular.forEach($scope.currentStageEventsOriginal, function (eventOriginal) {
-            if (eventOriginal.event === eventToSave.event) {
-                oldValue = eventOriginal[prStDe.dataElement.id];
-            }
-        });
-
         if (oldValue !== value) {
             
             value = CommonUtils.formatDataValue(eventToSave.event, value, prStDe.dataElement, $scope.optionSets, 'API');