← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20673: tracker-capture: whenever a program is selected make sure program rules are fetched

 

------------------------------------------------------------
revno: 20673
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-13 18:33:27 +0200
message:
  tracker-capture: whenever a program is selected make sure program rules are fetched
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-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/registration/registration-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-10-09 13:42:57 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-10-13 16:33:27 +0000
@@ -31,8 +31,6 @@
     $scope.registrationMode = 'REGISTRATION';    
     $scope.hiddenFields = {};
     
-    //$scope.editingDisabled = angular.isUndefined($scope.editingDisabled) ? false : $scope.editingDisabled;
-    
     $scope.attributesById = CurrentSelection.getAttributesById();
     if(!$scope.attributesById){
         $scope.attributesById = [];
@@ -66,19 +64,23 @@
         $scope.trackedEntities.selected = $scope.trackedEntities.available[0];
     });
 
+    var getProgramRules = function(){
+        $scope.trackedEntityForm = null;
+        $scope.customForm = null;        
+        $scope.allProgramRules = {constants: [], programIndicators: {}, programValidations: [], programVariables: [], programRules: []};
+        if( angular.isObject($scope.selectedProgram) && $scope.selectedProgram.id ){
+            TrackerRulesFactory.getRules($scope.selectedProgram.id).then(function(rules){                    
+                $scope.allProgramRules = rules;
+            });
+        }        
+    };
+    
     //watch for selection of program
     $scope.$watch('selectedProgram', function(newValue, oldValue) {
         if( newValue !== oldValue )
         {
-            $scope.trackedEntityForm = null;
-            $scope.customForm = null;        
-            $scope.allProgramRules = {constants: [], programIndicators: {}, programValidations: [], programVariables: [], programRules: []};
-            if( angular.isObject($scope.selectedProgram) && $scope.selectedProgram.id ){
-                TrackerRulesFactory.getRules($scope.selectedProgram.id).then(function(rules){                    
-                    $scope.allProgramRules = rules;
-                });
-            }
-
+            getProgramRules();
+            
             if($scope.registrationMode === 'REGISTRATION'){
                 $scope.getAttributes($scope.registrationMode);
             }
@@ -102,6 +104,10 @@
         }
 
         $scope.getAttributes($scope.registrationMode);
+        
+        if($scope.selectedProgram && $scope.selectedProgram.id){
+            getProgramRules();
+        }
     });
         
     $scope.getAttributes = function(_mode){