← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15280: searching tei - wip

 

------------------------------------------------------------
revno: 15280
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Thu 2014-05-15 19:16:31 +0200
message:
  searching tei - wip
modified:
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json
  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/styles/style.css
  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/home.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.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/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-05-15 12:45:17 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-05-15 17:16:31 +0000
@@ -3,6 +3,7 @@
     "registering_unit": "Registering unit",
     "program": "Program",
     "please_select": "[Please Select]",
+    "please_select_a_program": "[Please select a program]",
     "not_selected": "Not Selected",
     "view_all": "[View All]",
     "list_all_entities": "List All Entities",

=== 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-15 12:45:17 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-05-15 17:16:31 +0000
@@ -39,7 +39,11 @@
     $scope.emptySearchText = false;
     $scope.searchFilterExists = false;
     $scope.attributes = AttributesFactory.getWithoutProgram();    
-    $scope.searchMode = {listAll: 'LIST_ALL', freeText: 'FREE_TEXT', attributeBased: 'ATTRIBUTE_BASED'};
+    $scope.searchMode = { 
+                            listAll: 'LIST_ALL', 
+                            freeText: 'FREE_TEXT', 
+                            attributeBased: 'ATTRIBUTE_BASED'
+                        };
     
     //Registration
     $scope.showRegistrationDiv = false;
@@ -92,6 +96,7 @@
     };        
     
     $scope.getProgramAttributes = function(program){ 
+        $scope.trackedEntityList = null; 
         $scope.selectedProgram = program;
         if($scope.selectedProgram){
             $scope.attributes = AttributesFactory.getByProgram($scope.selectedProgram);
@@ -102,20 +107,21 @@
     };
     
     $scope.search = function(mode){ 
-        
+
         $scope.emptySearchText = false;
+        $scope.emptySearchAttribute = false;
+        $scope.showSearchDiv = false;
+        $scope.showRegistrationDiv = false;                
+        $scope.gridColumns = $scope.attributes;     
+        $scope.trackedEntityList = null; 
+        
         var queryUrl = null, 
             programUrl = null, 
-            attributeUrl = null;
+            attributeUrl = {url: null, hasValue: false};
     
         if($scope.selectedProgram){
             programUrl = 'program=' + $scope.selectedProgram.id;
-        }
-    
-        $scope.showSearchDiv = false;
-        $scope.showRegistrationDiv = false;    
-            
-        $scope.gridColumns = $scope.attributes;        
+        }      
 
         //generate grid column for the selected program
         angular.forEach($scope.gridColumns, function(gridColumn){
@@ -126,9 +132,7 @@
             }
         });
         
-        if( mode === $scope.searchMode.freeText ){            
-            $scope.trackedEntityList = null;
-            
+        if( mode === $scope.searchMode.freeText ){     
             if(!$scope.searchText){                
                 $scope.emptySearchText = true;
                 return;
@@ -138,22 +142,20 @@
             queryUrl = 'query=' + $scope.searchText;                     
         }
         else if( mode === $scope.searchMode.attributeBased ){
-            $scope.showTrackedEntityDiv = true;      
-            
+            $scope.showTrackedEntityDiv = true;                  
             attributeUrl = EntityQueryFactory.getQueryForAttributes($scope.attributes);
-          
+            
             if(!attributeUrl.hasValue){
-                console.log('empty search filter');
+                $scope.emptySearchAttribute = true;
+                $scope.showSearchDiv = true;
                 return;
             }
         }
        else if( mode === $scope.searchMode.listAll ){   
-            $scope.showTrackedEntityDiv = true; 
-            $scope.trackedEntityList = null;            
+            $scope.showTrackedEntityDiv = true;    
         }      
 
-        //(ouId, ouMode, queryUrl, programUrl, attributeUrl)
-        $scope.trackedEntityList = null; 
+        //get events for the specified parameters
         TrackedEntityInstanceService.search($scope.selectedOrgUnit.id, 
                                             $scope.ouMode,
                                             queryUrl,
@@ -163,33 +165,6 @@
         });
     };
     
-    //get events for the selected program (and org unit)
-    $scope.loadTrackedEntities = function(){
-        
-        console.log('am I called...');
-        
-        $scope.showTrackedEntityDiv = !$scope.showTrackedEntityDiv;        
-        $scope.showSearchDiv = false;
-        $scope.showRegistrationDiv = false;      
-        $scope.trackedEntityList = null;
-        
-        $scope.gridColumns = $scope.attributes;
-
-        //generate grid column for the selected program
-        angular.forEach($scope.gridColumns, function(gridColumn){
-            gridColumn.showFilter =  false;
-            gridColumn.hide = false;                   
-            if(gridColumn.type === 'date'){
-                 $scope.filterText[gridColumn.id]= {start: '', end: ''};
-            }
-        });
-            
-        //Load entities for the selected orgunit
-        TrackedEntityInstanceService.getByOrgUnit($scope.selectedOrgUnit.id).then(function(data){
-            $scope.trackedEntityList = data;                
-        });
-    };
-    
     $scope.clearEntities = function(){
         $scope.trackedEntityList = null;
     };
@@ -203,7 +178,9 @@
     $scope.showSearch = function(){        
         $scope.showSearchDiv = !$scope.showSearchDiv;
         $scope.showRegistrationDiv = false;
-        $scope.showTrackedEntityDiv = false;       
+        $scope.showTrackedEntityDiv = false;   
+        $scope.selectedProgram = '';
+        $scope.emptySearchAttribute = false;
     };
     
     $scope.hideSearch = function(){        
@@ -243,7 +220,7 @@
     
     $scope.showDashboard = function(currentEntity){       
         SelectedEntity.setSelectedEntity(currentEntity);
-        storage.set('SELECTED_OU', $scope.selectedOrgUnit);        
+        storage.set('SELECTED_OU', $scope.selectedOrgUnit);          
         $location.path('/dashboard').search({selectedEntityId: currentEntity.id});                                    
     };  
        
@@ -313,7 +290,7 @@
     
     //selections
     $scope.selectedEntityId = ($location.search()).selectedEntityId;       
-    $scope.selectedOrgUnit = storage.get('SELECTED_OU');     
+    $scope.selectedOrgUnit = storage.get('SELECTED_OU');   
         
     if( $scope.selectedEntityId ){
         
@@ -389,7 +366,7 @@
 
     TranslationService.translate();
     
-    //selected org unit
+    //selected org unit 
     $scope.selectedOrgUnit = storage.get('SELECTED_OU');  
     
     //programs for enrollment

=== 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-15 12:45:17 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-05-15 17:16:31 +0000
@@ -152,14 +152,25 @@
 })
 
 /* Service for getting tracked entity instances */
-.factory('TrackedEntityInstanceService', function($http, AttributesFactory) {
+.factory('TrackedEntityInstanceService', function($http, $filter) {
     
     var promise;
     return {
         
         get: function(entityUid) {
-            promise = $http.get(  '../api/trackedEntityInstances/' +  entityUid ).then(function(response){                                
-                return response.data;
+            promise = $http.get(  '../api/trackedEntityInstances/' +  entityUid ).then(function(response){     
+                var tei = response.data;
+                
+                angular.forEach(tei.attributes, function(attribute){                   
+                   if(attribute.type && attribute.value){                       
+                       if(attribute.type === 'date'){                           
+                           attribute.value = moment(attribute.value, 'YYYY-MM-DD')._d;
+                           attribute.value = Date.parse(attribute.value);
+                           attribute.value = $filter('date')(attribute.value, 'yyyy-MM-dd');                           
+                       }
+                   } 
+                });
+                return tei;
             });            
             return promise;
         },
@@ -338,50 +349,59 @@
     };    
 })
 
-.service('EntityQueryFactory', function(){
-    
-    var query = {url: null, hasValue: false};
+.service('EntityQueryFactory', function(){  
     
     this.getQueryForAttributes = function(attributes){
         
-        angular.forEach(attributes, function(attribute){
-                
-            //console.log('attribute', attribute.valueType);
+        var query = {url: null, hasValue: false};
+        
+        angular.forEach(attributes, function(attribute){           
 
-            if(attribute.value && attribute.value !== ""){                    
-                query.hasValue = true;
+            if(attribute.value && attribute.value !== ''){                    
+                query.hasValue = true;                
                 if(angular.isArray(attribute.value)){
-                    var index = 0;
-
-                    angular.forEach(attribute.value, function(val){                            
-                        if(query.url){
-                            query.url = query.url + '&attribute=' + attribute.id + ':LIKE:' + val;
+                    var index = 0, q = '';
+                    
+                    angular.forEach(attribute.value, function(val){
+                        
+                        if(index < attribute.value.length-1){
+                            q = q + val + ';';
                         }
                         else{
-                            query.url = 'attribute=' + attribute.id + ':LIKE:' + val;
-                        }
+                            q = q + val;
+                        }                        
                         index++;
                     });
+                    
+                    if(query.url){
+                        if(q){
+                            query.url = query.url + '&filter=' + attribute.id + ':IN:' + q;
+                        }
+                    }
+                    else{
+                        if(q){
+                            query.url = 'filter=' + attribute.id + ':IN:' + q;
+                        }
+                    }                    
                 }
                 else{                        
                     if(query.url){
-                        query.url = query.url + '&attribute=' + attribute.id + ':LIKE:' + attribute.value;
+                        query.url = query.url + '&filter=' + attribute.id + ':LIKE:' + attribute.value;
                     }
                     else{
-                        query.url = 'attribute=' + attribute.id + ':LIKE:' + attribute.value;
+                        query.url = 'filter=' + attribute.id + ':LIKE:' + attribute.value;
                     }
                 }
             }
-            else{
+            /*else{
                 if(query.url){
-                    query.url = query.url + '&attribute=' + attribute.id;
+                    query.url = query.url + '&filter=' + attribute.id;
                 }
                 else{
-                    query.url = 'attribute=' + attribute.id;
+                    query.url = 'filter=' + attribute.id;
                 }
-            }
+            }*/
         });
-            
         return query;
     };    
 })
@@ -605,6 +625,8 @@
             
 });
 
+
+
 /*
 * Helper functions
 */

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-05-15 12:45:17 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-05-15 17:16:31 +0000
@@ -398,6 +398,10 @@
     padding-right: 40px;
 }
 
+.btn-no-border {
+    border: none !important;
+}
+
 .max-column-width {
     max-width:200px !important; 
     word-wrap:break-word; 

=== 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-12 14:08:02 +0000
+++ 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
@@ -8,7 +8,7 @@
     <table class="table">
         <tr>
             <td>
-                {{'program'| translate}}
+                {{'program'| translate}}{{selectedProgram.name}}
             </td>
             <td>
                 <select ng-model="selectedProgram"

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html	2014-05-15 12:45:17 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html	2014-05-15 17:16:31 +0000
@@ -8,7 +8,7 @@
     </div>
     <img id="ouwt_loader" src="../images/ajax-loader-bar.gif"/>
 </div>
-<div class="page" id="mainPage">
+<div class="page" id="mainPage" ng-show="selectedOrgUnit">
     <h1>
         <span ng-show="!selectedProgram">
             {{'search'| translate}} {{selectedProgram.trackedEntity.name}}
@@ -22,36 +22,48 @@
     <div class="row">
         <input type="text" selected-org-unit ng-model="selectedOrgUnit.name" ng-hide=true>
         <div class="input-group col-md-6">
-            <input type="text" placeholder="{{'your_search_input_here'| translate}}" ng-model="searchText" class="form-control" ng-class="{true: 'invalid-input'} [!searchText && emptySearchText]" ng-focus="hideSearch()" ng-disabled="showRegistrationDiv">
+            <input type="text" placeholder="{{'your_search_input_here'| translate}}" ng-model="searchText" class="form-control" ng-class="{true: 'invalid - input'} [!searchText && emptySearchText]" ng-focus="hideSearch()" ng-disabled="showRegistrationDiv">
             <span class="input-group-btn">
-                <button class="btn btn-default" type="button" title="{{'more' | translate}}" ng-click="showSearch()" ng-disabled="showRegistrationDiv"><i class="fa fa-caret-down"></i></button>
+                <button class="btn btn-default" type="button" title="{{'more'| translate}}" ng-click="showSearch()" ng-disabled="showRegistrationDiv"><i class="fa fa-cog"></i></button>
             </span>                
         </div>        
-        <div class="btn-group col-md-6">
-            <button type="button" 
-                    class="btn btn-default"
-                    ng-disabled="showRegistrationDiv"
-                    ng-click="search(searchMode.freeText)">
-                {{'search'| translate}}
-            </button>
-            <button type="button" 
-                    class="btn btn-default" 
-                    ng-click="search(searchMode.listAll)">
-                {{'list_all'| translate}}
-            </button>
-            <button type="button" 
-                    class="btn btn-default" 
-                    ng-click="showRegistration()">
-                {{'add_new'| translate}}
-            </button>
+        <div class="col-md-6">
+            <div class="btn-group">
+                <button type="button" 
+                        class="btn btn-default"
+                        ng-disabled="showRegistrationDiv"
+                        ng-click="search(searchMode.freeText)">
+                    {{'search'| translate}}
+                </button>
+                <button type="button" 
+                        class="btn btn-default" 
+                        ng-click="search(searchMode.listAll)">
+                    {{'list_all'| translate}}
+                </button>
+            </div>
+            <span class="horizonal-spacing">
+                <button type="button" 
+                        class="btn btn-default" 
+                        ng-click="showRegistration()">
+                    {{'add_new'| translate}}
+                </button>
+            </span>
         </div>        
     </div>
     <div class="row" ng-if="!searchText && emptySearchText">
         <div class="col-md-6">
-            <div class="alert alert-danger">{{'search_input_required' | translate}}</div>         
+            <div class="alert alert-danger">{{'search_input_required'| translate}}</div>         
         </div>
     </div>
-    
+
+    <div class="row">
+        <div class="col-md-6">
+            <select class="form-control" ng-model="pr" ng-change="getProgramAttributes(pr)" ng-options="program as program.name for program in programs | orderBy: 'name'">
+                <option value="">{{'please_select_a_program'| translate}}</option>
+            </select>
+        </div>        
+    </div>
+
     <!-- search begins -->
     <div class="row" ng-if="showSearchDiv">
         <div class="col-md-6">
@@ -59,7 +71,7 @@
         </div>
     </div>
     <!-- search ends -->
-    
+
     <!--registration begins -->
     <div class="row" ng-if="showRegistrationDiv">
         <div class="col-md-6">
@@ -67,7 +79,7 @@
         </div>
     </div>
     <!-- registration ends -->
-    
+
     <!-- entity grid begins -->
     <div ng-if="showTrackedEntityDiv">
         <div ng-include="'views/trackedEntityList.html'"></div>  

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html	2014-05-14 13:04:39 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html	2014-05-15 17:16:31 +0000
@@ -10,7 +10,7 @@
                     <input type='radio' ng-model='ouMode' value='DESCENDANTS'>{{'use_all_children'| translate}}
                 </td>
             </tr>
-            <tr>
+            <!--<tr>
                 <td>
                     {{'program'| translate}}
                 </td>
@@ -19,7 +19,7 @@
                         <option value="">{{'please_select'| translate}}</option>
                     </select>
                 </td>
-            </tr>      
+            </tr>     --> 
 
             <tr ng-repeat="attribute in attributes">
                 <td>
@@ -55,11 +55,17 @@
             </tr>         
         </table>
     </div>
-    
+
+    <div class="row" ng-if="emptySearchAttribute">
+        <div class="col-md-6">
+            <div class="alert alert-danger">{{'search_input_required'| translate}}</div>         
+        </div>
+    </div>
+
     <div class="btn-group">
         <button type="button" 
                 class="btn btn-default"
-               ng-click="search(searchMode.attributeBased)">
+                ng-click="search(searchMode.attributeBased)">
             {{'search'| translate}}
         </button>
         <button type="button" 
@@ -69,5 +75,4 @@
         </button>        
     </div>
 
-</div>
-
+</div>
\ No newline at end of file