------------------------------------------------------------
revno: 17980
committer: Abyot Asalefew Gizaw <aby...@gmail.com>
branch nick: dhis2
timestamp: Wed 2015-01-14 12:21:15 +0100
message:
  bug fix in saving trueOnly dataelements in tracker capture
modified:
  
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/profile/profile-controller.js
  
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.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	2015-01-05 16:25:01 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-01-14 11:21:15 +0000
@@ -321,13 +321,21 @@
         angular.forEach($scope.currentEvent.dataValues, function(dataValue){
             var val = dataValue.value;
             var de = $scope.currentStage.programStageDataElements[dataValue.dataElement];
-            if(val){                
-                if( de && de.type === 'int'){
+            if(de){                
+                if(val && de.type === 'int'){
                     val = parseInt(val);
                 }
-                if(de.type === 'date'){
+                if(val && de.type === 'date'){
                     val = DateUtils.formatFromApiToUser(val);
                 }
+                if(de.type === 'trueOnly'){
+                    if(val === 'true'){
+                        val = true;
+                    }
+                    else{
+                        val = '';
+                    }
+                }
             }    
             $scope.currentEvent[dataValue.dataElement] = val;
             if(dataValue.providedElsewhere){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js	2015-01-05 10:34:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js	2015-01-14 11:21:15 +0000
@@ -55,38 +55,18 @@
         $scope.formEmpty = true;
         var tei = angular.copy($scope.selectedTei);
         tei.attributes = [];
-        angular.forEach($scope.selectedTei.attributes, function(attribute){
-            if(attribute.type === 'trueOnly'){ 
-                if(!attribute.value){
-                    tei.attributes.push({attribute: attribute.attribute, value: ''});
-                    $scope.formEmpty = false;                    
-                }
-                else{
-                    tei.attributes.push({attribute: attribute.attribute, value: 'true'});
-                    $scope.formEmpty = false;
-                }
-            }            
-            else{
-                var val = attribute.value;
-                if(!angular.isUndefined(val) && val !== ''){
-                    if(attribute.type === 'date'){   
-                        val = DateUtils.formatFromUserToApi(val);
-                    }
-                    if(attribute.type === 'optionSet' && $scope.optionSets.optionCodesByName[  '"' + val + '"']){   
-                        val = $scope.optionSets.optionCodesByName[  '"' + val + '"'];
-                    }                    
-                    $scope.formEmpty = false;
-                }
-                tei.attributes.push({attribute: attribute.attribute, value: val});
-            }             
+        angular.forEach($scope.selectedTei.attributes, function(attribute){            
+            tei.attributes.push({attribute: attribute.attribute, value: attribute.value, type: attribute.type});
+            if(attribute.value && $scope.formEmpty){
+                $scope.formEmpty = false;
+            }           
         });
         
-        if($scope.formEmpty){
-            //form is empty            
+        if($scope.formEmpty){//form is empty  
             return false;
         }
-
-        TEIService.update(tei).then(function(updateResponse){
+        
+        TEIService.update(tei, $scope.optionSets).then(function(updateResponse){
             
             if(updateResponse.status !== 'SUCCESS'){//update has failed
                 var dialogOptions = {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-01-08 16:39:10 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-01-14 11:21:15 +0000
@@ -380,21 +380,31 @@
                         attsById[att.id] = att;
                     });
 
-                    angular.forEach(tei.attributes, function(att){                        
-                        var val = att.value;
-                        if(val){
-                            if(att.type === 'date'){
-                                val = DateUtils.formatFromApiToUser(val);
-                            }
-                            if(att.type === 'optionSet' && 
-                                    attsById[att.attribute] && 
-                                    attsById[att.attribute].optionSet && 
-                                    attsById[att.attribute].optionSet.id && 
-                                    optionSets[attsById[att.attribute].optionSet.id]){   
-                                val = OptionSetService.getName(optionSets[attsById[att.attribute].optionSet.id].options, val);                                
-                            }
-                            att.value = val;
-                        }                        
+                    angular.forEach(tei.attributes, function(att){
+                        if(att.type === 'trueOnly'){
+                            if(att.value === 'true'){
+                                att.value = true;
+                            }
+                            else{
+                                att.value = '';
+                            }
+                        }
+                        else{
+                            var val = att.value;
+                            if(val){
+                                if(att.type === 'date'){
+                                    val = DateUtils.formatFromApiToUser(val);
+                                }
+                                if(att.type === 'optionSet' && 
+                                        attsById[att.attribute] && 
+                                        attsById[att.attribute].optionSet && 
+                                        attsById[att.attribute].optionSet.id && 
+                                        optionSets[attsById[att.attribute].optionSet.id]){   
+                                    val = OptionSetService.getName(optionSets[attsById[att.attribute].optionSet.id].options, val);                                
+                                }
+                                att.value = val;
+                            }
+                        }                                                
                     });                    
                 });    
                 return tei;
@@ -413,13 +423,13 @@
 
                 angular.forEach(tei.attributes, function(att){                        
                     
-                    if(att.type === 'trueOnly'){ 
-                        if(!att.value){
+                    if(att.type === 'trueOnly'){
+                        if(att.value){
+                            att.value = 'true';
+                        }
+                        else{
                             att.value = '';
                         }
-                        else{
-                            att.value = true;
-                        }
                     }            
                     else{
                         var val = att.value;

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to