← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18545: minor

 

------------------------------------------------------------
revno: 18545
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-10 09:12:33 +0100
message:
  minor
modified:
  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/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-03-09 14:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-03-10 08:12:33 +0000
@@ -181,21 +181,25 @@
                             programs.push(pr);
                         }
                     });
+                    
                     if(programs.length === 0){
                         selectedProgram = null;
                     }
+                    else if(programs.length === 1){
+                        selectedProgram = programs[0];
+                    } 
                     else{
                         if(selectedProgram){
-                            angular.forEach(programs, function(pr){                            
-                                if(pr.id === selectedProgram.id){                                
-                                    selectedProgram = pr;
+                            var continueLoop = true;
+                            for(var i=0; i<programs.length && continueLoop; i++){
+                                if(programs[i].id === selectedProgram.id){                                
+                                    selectedProgram = programs[i];
+                                    continueLoop = false;
                                 }
-                            });
-                        }
-                        else{                        
-                            if(programs.length === 1){
-                                selectedProgram = programs[0];
-                            }                        
+                            }
+                            if(continueLoop){
+                                selectedProgram = null;
+                            }
                         }
                     }