← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21299: tracker-capture: restructuring first page - WIP

 

------------------------------------------------------------
revno: 21299
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-12-03 17:03:04 +0100
message:
  tracker-capture: restructuring first page - WIP
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.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-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2015-12-03 14:08:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2015-12-03 16:03:04 +0000
@@ -30,6 +30,8 @@
     $scope.maxOptionSize = 30;
     $scope.model = {};
     
+    $scope.trackerCapture = {displayMode: 'SEARCH'};
+    
     //Selection
     $scope.ouModes = [{name: 'SELECTED'}, {name: 'CHILDREN'}, {name: 'DESCENDANTS'}, {name: 'ACCESSIBLE'}];         
     $scope.selectedOuMode = $scope.ouModes[0];    
@@ -38,18 +40,11 @@
     $scope.treeLoaded = false;
     $scope.searchOuTree = false;
     $scope.teiListMode = {onlyActive: false};
-    $scope.enrollmentStatus = 'ALL';
-    
-    //Paging
-    $scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5};   
-    
-    //EntityList
-    $scope.showTrackedEntityDiv = false;
-    
+    $scope.enrollmentStatus = 'ALL';    
+       
     //Searching
     $scope.showSearchDiv = false;
     $scope.searchText = null;
-    $scope.emptySearchText = false;
     $scope.searchFilterExists = false;   
     $scope.defaultOperators = OperatorFactory.defaultOperators;
     $scope.boolOperators = OperatorFactory.boolOperators;
@@ -57,10 +52,21 @@
     $scope.searchMode = { listAll: 'LIST_ALL', freeText: 'FREE_TEXT', attributeBased: 'ATTRIBUTE_BASED' };    
     $scope.optionSets = null;
     $scope.attributesById = null;
-    $scope.doSearch = true;
-    
-    //Registration
-    $scope.showRegistrationDiv = false;    
+    $scope.doSearch = true;    
+       
+    function resetParams(){
+        $scope.trackedEntityList = null;
+        $scope.sortColumn = {};
+        $scope.emptySearchText = false;
+        $scope.emptySearchAttribute = false;
+        $scope.showRegistrationDiv = false;  
+        $scope.showTrackedEntityDiv = false;        
+        $scope.teiFetched = false;        
+        $scope.queryUrl = null;
+        $scope.programUrl = null;
+        $scope.attributeUrl = {url: null, hasValue: false};
+        $scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5};
+    }
     
     //watch for selection of org unit from tree
     $scope.$watch('selectedOrgUnit', function() {           
@@ -119,6 +125,7 @@
             $scope.settingsLabel = $translate.instant('settings');
             $scope.displayModeLabel = $translate.instant('display_mode');
             
+            resetParams();
             $scope.loadPrograms($scope.selectedOrgUnit);
         }
     });
@@ -162,6 +169,7 @@
     };
     
     $scope.getProgramAttributes = function(program){ 
+        resetParams();
         $scope.selectedProgram = program;
         $scope.trackedEntityList = null;
         $scope.processAttributes();              
@@ -175,7 +183,7 @@
                 $scope.doSearch = false;
             }
 
-            if($scope.doSearch){
+            if($scope.doSearch && $scope.trackerCapture.displayMode === 'LIST'){
                 $scope.search($scope.searchMode);
             } 
         });
@@ -205,21 +213,12 @@
     };
    
     //$scope.searchParam = {bools: []};
-    $scope.search = function(mode){        
+    $scope.search = function(mode){  
+        resetParams()
         var grid = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
         $scope.gridColumns = grid.columns;
             
-        $scope.selectedSearchMode = mode;
-        $scope.emptySearchText = false;
-        $scope.emptySearchAttribute = false;
-        $scope.showRegistrationDiv = false;  
-        $scope.showTrackedEntityDiv = false;        
-        $scope.teiFetched = false;
-        $scope.trackedEntityList = null;
-        
-        $scope.queryUrl = null;
-        $scope.programUrl = null;
-        $scope.attributeUrl = {url: null, hasValue: false};
+        $scope.selectedSearchMode = mode;        
     
         if($scope.selectedProgram){
             $scope.programUrl = 'program=' + $scope.selectedProgram.id;
@@ -228,10 +227,13 @@
         //check search mode
         if( $scope.selectedSearchMode === $scope.searchMode.freeText ){     
 
-            if( $scope.searchText ){
-                $scope.queryUrl = 'query=LIKE:' + $scope.searchText;
-            }            
-                        
+            if(!$scope.searchText){                
+                $scope.emptySearchText = true;
+                $scope.teiFetched = false;
+                return;
+            }       
+            
+            $scope.queryUrl = 'query=LIKE:' + $scope.searchText;            
             $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
             $scope.searchingOrgUnit = $scope.selectedOrgUnit;
         }
@@ -320,8 +322,7 @@
     };
     
     $scope.showRegistration = function(){
-        $scope.showRegistrationDiv = !$scope.showRegistrationDiv;
-        
+        $scope.showRegistrationDiv = !$scope.showRegistrationDiv;        
         if($scope.showRegistrationDiv){
             $scope.showTrackedEntityDiv = false;
             $scope.showSearchDiv = false;
@@ -329,15 +330,6 @@
                 $rootScope.$broadcast('registrationWidget', {registrationMode: 'REGISTRATION'});
             }, 200);
         }
-        else{            
-            $scope.doSearch = true;
-            if(!$scope.trackedEntityList){
-                if($scope.doSearch){
-                    $scope.search($scope.searchMode);
-                }
-            }                        
-            $scope.showTrackedEntityDiv = true;
-        }
     };    
     
     $scope.showDisplayMode = function(){        

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html	2015-12-03 14:08:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html	2015-12-03 16:03:04 +0000
@@ -123,6 +123,7 @@
             <div class="col-md-4 trim hideInPrint">            
                 <button type="button" 
                         class="btn btn-success"
+                        ng-if="trackerCapture.displayMode === 'LIST'"
                         ng-disabled="showRegistrationDiv"
                         ng-click="search(searchMode.listAll)">
                     {{listAllLabel}}