← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16389: tracker capture - pressing enter during searching is now considered as submit for primary functio...

 

------------------------------------------------------------
revno: 16389
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-12 16:48:01 +0200
message:
  tracker capture - pressing enter during searching is now considered as submit for primary functions. This means pressing enter does have no effect on list all
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/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/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-07-23 13:33:13 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-08-12 14:48:01 +0000
@@ -125,7 +125,7 @@
                             $scope.selectedProgram = $scope.programs[0];
                         }                        
                     }
-                }                
+                } 
             });
         }        
     };
@@ -165,10 +165,10 @@
         if($scope.doSearch){
             $scope.search($scope.searchMode);
         }       
-    };
-    
+    };   
+   
     $scope.search = function(mode){ 
-
+        
         $scope.teiFetched = false;
         $scope.selectedSearchMode = mode;
         $scope.emptySearchText = false;
@@ -198,11 +198,15 @@
                 return;
             }       
  
-            $scope.queryUrl = 'query=' + $scope.searchText;                     
+            $scope.queryUrl = 'query=' + $scope.searchText;     
+            
+            $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
         }
         
         if( $scope.selectedSearchMode === $scope.searchMode.attributeBased ){
             
+            $scope.searchText = '';
+            
             $scope.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.attributes, $scope.enrollment);
             
             if(!$scope.attributeUrl.hasValue && !$scope.selectedProgram){
@@ -213,6 +217,12 @@
             }
         }
         
+        if( $scope.selectedSearchMode === $scope.searchMode.listAll ){
+            $scope.searchText = '';
+            
+            $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
+        }
+        
         $scope.fetchTeis();
     };
     
@@ -347,6 +357,111 @@
     };    
 })
 
+//Controller for the search function
+//own controller is required because of the ng-include for the search
+.controller('SearchController',
+        function($scope,
+                Paginator,
+                TEIGridService,
+                TEIService,
+                EntityQueryFactory,
+                TranslationService) {
+
+    TranslationService.translate();
+    
+    $scope.search = function(mode){ 
+        
+        $scope.teiFetched = false;
+        $scope.selectedSearchMode = mode;
+        $scope.emptySearchText = false;
+        $scope.emptySearchAttribute = false;
+        //$scope.showSearchDiv = false;
+        $scope.showRegistrationDiv = false;  
+        $scope.showReportDiv = false;
+        $scope.showTrackedEntityDiv = false;
+        $scope.trackedEntityList = null; 
+        $scope.teiCount = null;
+        
+        $scope.queryUrl = null;
+        $scope.programUrl = null;
+        $scope.attributeUrl = {url: null, hasValue: false};
+    
+        if($scope.selectedProgram){
+            $scope.programUrl = 'program=' + $scope.selectedProgram.id;
+        }        
+        
+        //check search mode
+        if( $scope.selectedSearchMode === $scope.searchMode.freeText ){     
+
+            if(!$scope.searchText){                
+                $scope.emptySearchText = true;
+                $scope.teiFetched = false;   
+                $scope.teiCount = null;
+                return;
+            }       
+ 
+            $scope.queryUrl = 'query=' + $scope.searchText;     
+            
+            $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
+        }
+        
+        if( $scope.selectedSearchMode === $scope.searchMode.attributeBased ){
+            
+            $scope.searchText = '';
+            
+            $scope.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.attributes, $scope.enrollment);
+            
+            if(!$scope.attributeUrl.hasValue && !$scope.selectedProgram){
+                $scope.emptySearchAttribute = true;
+                $scope.teiFetched = false;   
+                $scope.teiCount = null;
+                return;
+            }
+        }
+        
+        if( $scope.selectedSearchMode === $scope.searchMode.listAll ){
+            $scope.searchText = '';
+            
+            $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
+        }
+        
+        $scope.fetchTeis();
+    };
+    
+    $scope.fetchTeis = function(){
+        
+        //get events for the specified parameters
+        TEIService.search($scope.selectedOrgUnit.id, 
+                                            $scope.selectedOuMode.name,
+                                            $scope.queryUrl,
+                                            $scope.programUrl,
+                                            $scope.attributeUrl.url,
+                                            $scope.pager,
+                                            true).then(function(data){
+            //$scope.trackedEntityList = data;            
+            if(data.rows){
+                $scope.teiCount = data.rows.length;
+            }                    
+            
+            if( data.metaData.pager ){
+                $scope.pager = data.metaData.pager;
+                $scope.pager.toolBarDisplay = 5;
+
+                Paginator.setPage($scope.pager.page);
+                Paginator.setPageCount($scope.pager.pageCount);
+                Paginator.setPageSize($scope.pager.pageSize);
+                Paginator.setItemCount($scope.pager.total);                    
+            }
+            
+            //process tei grid
+            $scope.trackedEntityList = TEIGridService.format(data);
+            $scope.showTrackedEntityDiv = true;
+            $scope.teiFetched = true;  
+            $scope.doSearch = true;
+        });
+    };    
+})
+        
 //Controller for column show/hide
 .controller('ColumnDisplayController', 
     function($scope, 

=== 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-08-08 14:59:22 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-08-12 14:48:01 +0000
@@ -698,7 +698,25 @@
         }
         return query;
         
-    };    
+    };   
+    
+    this.resetAttributesQuery = function(attributes, enrollment){
+        
+        angular.forEach(attributes, function(attribute){           
+            
+            attribute.operator = '';
+            attribute.exactValue = '';
+            attribute.startValue = '';
+            attribute.endValue = '';
+            attribute.value = '';           
+        });
+        
+        if(enrollment){
+            enrollment.programStartDate = '';
+            enrollment.programEndDate = '';          
+        }        
+        return attributes;        
+    }; 
 })
 
 /* service for dealing with custom form */

=== 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-07-21 09:53:38 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html	2014-08-12 14:48:01 +0000
@@ -58,13 +58,125 @@
             </div>                
         </div>
         <div id="searchDropDownParent" class="input-group col-md-4">
-            <input type="text" placeholder="{{'type_here_for_simple_search'| translate}}" ng-model="searchText" class="form-control expanded" ng-class="{true: 'invalid-input'} [!searchText && emptySearchText]" ng-focus="showHideSearch()" ng-disabled="showRegistrationDiv || showReportDiv">
+            <input type="text" placeholder="{{'type_here_for_simple_search'| translate}}" ng-model="searchText" class="form-control expanded" d2-enter="search(searchMode.freeText)" ng-class="{true: 'invalid-input'} [!searchText && emptySearchText]" ng-focus="showHideSearch()" ng-disabled="showRegistrationDiv || showReportDiv">
             <div class="input-group-btn">
                 <button class="btn btn-default search-dropdown-button trim" type="button" title="{{'advanced_search'| translate}}" data-toggle="dropdown" ng-click="showHideSearch()" ng-disabled="showRegistrationDiv || showReportDiv"><i class="fa fa-caret-down"></i></button>
                 <button class="btn btn-primary trim" type="button" title="{{'search'| translate}}" ng-disabled="showRegistrationDiv || showReportDiv" ng-click="search(searchMode.freeText)"><i class="fa fa-search"></i></button>
                 <div id="searchDropDown" class="dropdown-menu dropdown-menu-right">
-                    <form ng-include="'views/search.html'">                       
-                    </form>                    
+                    <form ng-submit="search(searchMode.attributeBased)">
+                        <!-- had to disable ng-include to avoid dealing with a separate controller/scope issue-->
+                        <!--<div ng-include="'views/search.html'"></div>-->
+                        <div class="search-container-main">
+                            <div class="search-container">    
+                                <table data-stop-propagation="true" class="table-borderless table-striped">
+                                    <tr>
+                                        <td>{{'org_unit'| translate}}</td>
+                                        <td>                    
+                                            <label><input type="radio" ng-model="selectedOuMode.name" name="selected" value="SELECTED"> {{'SELECTED'| translate}}</label><br/>
+                                            <label><input type="radio" ng-model="selectedOuMode.name" name="children" value="CHILDREN"> {{'CHILDREN'| translate}}</label><br/>
+                                            <label><input type="radio" ng-model="selectedOuMode.name" name="descendants" value="DESCENDANTS"> {{'DESCENDANTS'| translate}}</label><br/>
+                                            <label><input type="radio" ng-model="selectedOuMode.name" name="accessible" value="ACCESSIBLE"> {{'ACCESSIBLE'| translate}}</label>
+                                        </td>
+                                    </tr>
+                                    <tr ng-if="selectedProgram">
+                                        <td>{{'enrollment_date'| translate}}</td>
+                                        <td>
+                                            <div class="dataelement-filter">
+                                                <div class="filter-operator">
+                                                    <select ng-model="enrollment.operator" class="form-control-select2" ng-options="operator | translate for operator in defaultOperators">
+                                                    </select>
+                                                </div>
+                                                <div class="filter-value" ng-show="enrollment.operator === defaultOperators[0]">
+                                                    <input type="text" placeholder="{{'exact_date'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programExactDate"/>
+                                                </div>
+                                                <div class="filter-value" ng-show="enrollment.operator === defaultOperators[1]">
+                                                    <div class="container-1-2">
+                                                        <input type="text" placeholder="{{'start_date'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programStartDate"/>
+                                                    </div>
+                                                    <div class="container-1-2">
+                                                        <input type="text" placeholder="{{'end_date'| translate}}" class="form-control-select2" ng-date ng-model="enrollment.programEndDate"/>                
+                                                    </div>
+                                                </div>                    
+                                            </div>                
+                                        </td>
+                                    </tr>
+                                    <tr ng-repeat="attribute in attributes">
+                                        <td>
+                                            {{attribute.name}}
+                                        </td>
+                                        <td>
+                                            <div ng-switch="attribute.valueType">
+                                                <div ng-switch-when="number">
+                                                    <div class="dataelement-filter">                                                
+                                                        <div class="filter-operator">
+                                                            <select ng-model="attribute.operator" class="form-control-select2" ng-options="operator | translate for operator in defaultOperators">
+                                                            </select>
+                                                        </div>
+                                                        <div class="filter-value" ng-show="attribute.operator === defaultOperators[0]">
+                                                            <input type="number" placeholder="{{'exact_value'| translate}}" class="form-control-select2" ng-model="attribute.exactValue"/>
+                                                        </div>
+                                                        <div class="filter-value" ng-show="attribute.operator === defaultOperators[1]">
+                                                            <div class="container-1-2">
+                                                                <input type="number" placeholder="{{'from'| translate}}" class="form-control-select2" ng-model="attribute.startValue"/>
+                                                            </div>
+                                                            <div class="container-1-2">
+                                                                <input type="number" placeholder="{{'to'| translate}}" class="form-control-select2" ng-model="attribute.endValue"/>                
+                                                            </div>
+                                                        </div>                            
+                                                    </div>                        
+                                                </div>
+                                                <div ng-switch-when="date">
+                                                    <div class="dataelement-filter">
+                                                        <div class="filter-operator">
+                                                            <select ng-model="attribute.operator" class="form-control-select2" ng-options="operator | translate for operator in defaultOperators">
+                                                            </select>
+                                                        </div>
+                                                        <div class="filter-value" ng-show="attribute.operator === defaultOperators[0]">
+                                                            <input type="text" placeholder="{{'exact_date'| translate}}" class="form-control-select2" ng-date ng-model="attribute.exactValue"/>
+                                                        </div>
+                                                        <div class="filter-value" ng-show="attribute.operator === defaultOperators[1]">
+                                                            <div class="container-1-2">
+                                                                <input type="text" placeholder="{{'start_date'| translate}}" class="form-control-select2" ng-date ng-model="attribute.startValue"/>
+                                                            </div>
+                                                            <div class="container-1-2">
+                                                                <input type="text" placeholder="{{'end_date'| translate}}" class="form-control-select2" ng-date ng-model="attribute.endValue"/>                
+                                                            </div>
+                                                        </div>                            
+                                                    </div> 
+                                                </div>                        
+                                                <div ng-switch-when="optionSet">
+                                                    <select multiple ui-select2  ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
+                                                        <option ng-repeat="option in attribute.optionSet.options" value="{{option.code}}">{{option.name}}</option>
+                                                    </select>
+                                                </div>
+                                                <div ng-switch-when="bool">
+                                                    <select ui-select2  ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
+                                                        <option ng-repeat="option in boolOperators" value="{{option}}">{{option| translate}}</option>
+                                                    </select>
+                                                </div> 
+                                                <div ng-switch-default>
+                                                    <input type="text" class="form-control-select2" ng-model="attribute.value" /> 
+                                                </div>
+                                            </div>
+                                        </td>
+                                    </tr>         
+                                </table>
+                            </div>
+
+                            <div class="horizonal-spacing">
+                                <button type="submit"
+                                        class="btn btn-primary"
+                                        ng-click="search(searchMode.attributeBased)">
+                                    {{'search'| translate}}
+                                </button>
+                                <button type="button" 
+                                        class="btn btn-success small-horizonal-spacing" 
+                                        ng-click="search(searchMode.listAll)">
+                                    {{'list_all'| translate}}
+                                </button>        
+                            </div>
+                        </div>
+                    </form>
                 </div>
             </div>                
         </div>        
@@ -116,8 +228,8 @@
     <!-- report div ends -->
 
     <!-- entity grid begins -->
+    <img class="col-md-12" src="../images/ajax-loader-bar.gif" ng-if="!teiFetched"/>
     <div class="row" ng-if="showTrackedEntityDiv">
-        <img class="col-md-12" src="../images/ajax-loader-bar.gif" ng-if="!teiFetched"/>
         <div class="col-md-12" ng-include="'views/tei.html'"></div>  
     </div>
     <!-- entity grid ends -->

=== 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-08-08 14:59:22 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html	2014-08-12 14:48:01 +0000
@@ -96,7 +96,7 @@
     </div>
 
     <div class="horizonal-spacing">
-        <button type="button"
+        <button type="submit"
                 class="btn btn-primary"
                 ng-click="search(searchMode.attributeBased)">
             {{'search'| translate}}