← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15303: communication between tei dashboard controller

 

------------------------------------------------------------
revno: 15303
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Mon 2014-05-19 16:00:19 +0200
message:
  communication between tei dashboard controller
modified:
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html


--
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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-05-19 11:33:07 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-05-19 14:00:19 +0000
@@ -51,7 +51,9 @@
     //watch for selection of org unit from tree
     $scope.$watch('selectedOrgUnit', function() {
         
-        if( angular.isObject($scope.selectedOrgUnit)){                  
+        if( angular.isObject($scope.selectedOrgUnit)){   
+            
+            storage.set('SELECTED_OU', $scope.selectedOrgUnit);
             
             $scope.trackedEntityList = [];
             $scope.selectedProgram = '';
@@ -264,9 +266,10 @@
         });
     };
     
-    $scope.showDashboard = function(currentEntity){       
-        storage.set('SELECTED_OU', $scope.selectedOrgUnit);          
-        $location.path('/dashboard').search({selectedEntityId: currentEntity.id, selectedOrgUnitId: $scope.selectedOrgUnit.id});                                    
+    $scope.showDashboard = function(currentEntity){
+        
+        $location.path('/dashboard').search({selectedEntityId: currentEntity.id,                                            
+                                            selectedProgramId: $scope.selectedProgram ? $scope.selectedProgram.id: null});                                    
     };  
        
     $scope.getHelpContent = function(){
@@ -311,6 +314,7 @@
     
     //do translation of the registration page
     TranslationService.translate();   
+    $scope.selectedOrgUnit = storage.get('SELECTED_OU');
     $scope.enrollment = {enrollmentDate: '', incidentDate: ''};    
     
     $scope.attributes = AttributesFactory.getWithoutProgram();
@@ -364,12 +368,14 @@
                         };
                     EnrollmentService.enroll(enrollment).then(function(data){
                         if(data.status === 'SUCCESS'){
-                            $location.path('/dashboard').search({selectedEntityId: tei.reference});  
+                            $location.path('/dashboard').search({selectedEntityId: tei.reference,
+                                                                selectedProgramId: $scope.selectedProgram ? $scope.selectedProgram.id: null});   
                         }
                     });
                 }
                 else{
-                    $location.path('/dashboard').search({selectedEntityId: tei.reference});  
+                    $location.path('/dashboard').search({selectedEntityId: tei.reference,
+                                                        selectedProgramId: $scope.selectedProgram ? $scope.selectedProgram.id: null});
                 }
             }
             else{
@@ -413,14 +419,22 @@
     $rootScope.dashboardWidgets.smaller.push($rootScope.notesWidget);
     
     //selections
-    $scope.selectedEntityId = ($location.search()).selectedEntityId;       
-    $scope.selectedOrgUnit = storage.get('SELECTED_OU');   
+    $scope.selectedEntityId = ($location.search()).selectedEntityId; 
+    $scope.selectedProgramId = ($location.search()).selectedProgramId; 
+    $scope.selectedOrgUnit = storage.get('SELECTED_OU');
+    
+    if($scope.selectedProgramId && storage.get($scope.selectedProgramId)){
+        $scope.selectedProgram = storage.get($scope.selectedProgramId);
+    }
+    else{
+        $scope.selectedProgram = null;
+    }
         
     if( $scope.selectedEntityId ){
         
         //Fetch the selected entity
-        TEIService.get($scope.selectedEntityId).then(function(data){            
-            CurrentSelection.set({tei: data, ou: $scope.selectedOrgUnit});
+        TEIService.get($scope.selectedEntityId).then(function(data){              
+            CurrentSelection.set({tei: data, pr: $scope.selectedProgram});
             
             //broadcast selected entity for dashboard controllers
             $rootScope.$broadcast('selectedEntity', {});
@@ -448,8 +462,7 @@
 
         modalInstance.result.then(function () {
         });
-    };   
-
+    };
 })
 
 //Controller for the profile section
@@ -473,9 +486,12 @@
         
         var selections = CurrentSelection.get();
         $scope.selectedEntity = selections.tei;
-        $scope.selectedOrgUnit = selections.ou;
-
-        $scope.trackedEntity = storage.get($scope.selectedEntity.trackedEntity);       
+        
+        angular.forEach(storage.get('TRACKED_ENTITIES'), function(te){
+            if($scope.selectedEntity.trackedEntity === te.id){
+                $scope.trackedEntity = te;
+            }
+        }); 
     });
 })
 
@@ -495,11 +511,15 @@
     $scope.enrollments = [];
     $scope.programs = []; 
     
+    $scope.selectedOrgUnit = storage.get('SELECTED_OU');
+    
     //listen for the selected items
-    $scope.$on('selectedEntity', function(event, args) {     
+    $scope.$on('selectedEntity', function(event, args) {
+        
         var selections = CurrentSelection.get();
-        $scope.selectedEntity = selections.tei;
-        $scope.selectedOrgUnit = selections.ou;       
+        $scope.selectedEntity = selections.tei;    
+        
+        $scope.selectedOrgUnit = storage.get('SELECTED_OU');
         
         angular.forEach(storage.get('TRACKER_PROGRAMS'), function(program){
             program = storage.get(program.id);
@@ -507,7 +527,16 @@
                program.trackedEntity.id === $scope.selectedEntity.trackedEntity){
                 $scope.programs.push(program);
             }
-        });        
+        });
+        
+        if(selections.pr){       
+            angular.forEach($scope.programs, function(program){
+                if(selections.pr.id === program.id){
+                    $scope.selectedProgram = program;
+                    $scope.loadEvents();
+                }
+            });
+        }
     }); 
     
     $scope.loadEvents = function() {
@@ -529,8 +558,6 @@
                 angular.forEach($scope.selectedProgram.programStages, function(stage){
                    $scope.programStages.push(storage.get(stage.id));               
                 });
-                
-                console.log('the stages are:  ', $scope.programStages);
 
                 if($scope.selectedEnrollment){
                     $scope.selectedEnrollment.dateOfIncident = $filter('date')($scope.selectedEnrollment.dateOfIncident, 'yyyy-MM-dd');
@@ -561,6 +588,8 @@
 
     TranslationService.translate();
     
+    $scope.selectedOrgUnit = storage.get('SELECTED_OU');
+    
     //listen for the selected items
     $scope.$on('dataentry', function(event, args) {  
 
@@ -569,7 +598,6 @@
         $scope.dhis2Events = [];       
     
         $scope.selectedEntity = args.selectedEntity;
-        $scope.selectedOrgUnit = args.selectedOrgUnit
         $scope.selectedProgramId = args.selectedProgramId;        
         $scope.selectedEnrollment = args.selectedEnrollment;
         
@@ -701,10 +729,8 @@
                 storage,
                 TranslationService) {
 
-    TranslationService.translate();
-    
-    $scope.attributes = storage.get('ATTRIBUTES');
-    
+    TranslationService.translate();    
+    $scope.attributes = storage.get('ATTRIBUTES');    
 })
 
 //Controller for the notes section

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-05-19 11:33:07 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-05-19 14:00:19 +0000
@@ -520,14 +520,14 @@
 
 /* current selections */
 .service('CurrentSelection', function(){
-    this.selection = '';
+    this.currentSelection = '';
     
-    this.set = function(selection){  
-        this.selection = selection;        
+    this.set = function(currentSelection){  
+        this.currentSelection = currentSelection;        
     };
     
     this.get = function(){
-        return this.selection;
+        return this.currentSelection;
     };
 })
 

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html	2014-05-15 17:16:31 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/enrollment.html	2014-05-19 14:00:19 +0000
@@ -8,7 +8,7 @@
     <table class="table">
         <tr>
             <td>
-                {{'program'| translate}}{{selectedProgram.name}}
+                {{'program'| translate}}
             </td>
             <td>
                 <select ng-model="selectedProgram"

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html	2014-04-04 11:55:55 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/profile.html	2014-05-19 14:00:19 +0000
@@ -1,6 +1,6 @@
 <div class="panel panel-default" ng-controller="ProfileController">
     <div class="panel-heading">
-        {{trackedEntity.name|| 'entity' | translate}} {{profileWidget.title| translate}}
+        {{trackedEntity.name || 'entity' | translate}} {{profileWidget.title| translate}}
         <span class="pull-right">
             <a href ng-click="removeWidget(profileWidget)" title="{{'remove'| translate}}"><span class='black'><i class="fa fa-times-circle"></i></span></a>            
         </span>