← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14080: event capture - WIP, filtering event grid

 

------------------------------------------------------------
revno: 14080
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Thu 2014-02-20 14:58:38 +0100
message:
  event capture - WIP, filtering event grid
modified:
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/index.html
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/filters.js
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/styles/style.css


--
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-event-capture/src/main/webapp/dhis-web-event-capture/app/index.html'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/index.html	2014-02-20 11:41:24 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/index.html	2014-02-20 13:58:38 +0000
@@ -171,17 +171,26 @@
                             <!-- event grid begins -->
                             <form name="outerForm" novalidate>                              
 
-                                <table class="listTable dhis2-table-striped dhis2-table-hover">                    
+                                <table class="listTable dhis2-table-striped-border dhis2-table-hover">                    
                                     <thead>                        
                                         <tr>
                                             <th ng-show="!eventGridColumn.hide" 
-                                                class="max-column-width" 
-                                                ng-click="sortEventGrid(eventGridColumn)" 
+                                                class="max-column-width"                                                
                                                 ng-repeat="eventGridColumn in eventGridColumns">
                                                 
-                                                {{eventGridColumn.name}}
-                                                <i ng-show="sortHeader == eventGridColumn.id && !reverse" class="fa fa-sort-desc"></i>
-                                                <i ng-show="sortHeader == eventGridColumn.id && reverse" class="fa fa-sort-asc"></i>
+                                                <span ng-hide="eventGridColumn == filteringGrid" class="bold" ng-click="sortEventGrid(eventGridColumn)">
+                                                    <i ng-show="sortHeader == eventGridColumn.id && !reverse" class="fa fa-sort-desc"></i>
+                                                    <i ng-show="sortHeader == eventGridColumn.id && reverse" class="fa fa-sort-asc"></i>
+                                                    {{eventGridColumn.name}}
+                                                </span>
+                                                
+                                                <span class="pull-right">
+                                                    <a href ng-click="searchInGrid(eventGridColumn)" title="{{'search'| translate}}"><span class='black'><i class="fa fa-search"></i></span></a>                                                    
+                                                </span>                                               
+                                                
+                                                <div ng-show="eventGridColumn == filteringGrid">
+                                                    <input type="text" ng-model="filterText[eventGridColumn.id]" ng-blur="searchInGrid()">
+                                                </div>                                                
                                                 
                                             </th>
                                             <th ng-hide="editGridColumns">
@@ -190,7 +199,7 @@
                                         </tr>                        
                                     </thead>
                                     <tbody id="list">
-                                        <tr ng-repeat="dhis2Event in dhis2Events| paginate:rowsPerPage | orderBy:sortHeader:reverse" 
+                                        <tr ng-repeat="dhis2Event in dhis2Events | paginate:rowsPerPage | orderBy:sortHeader:reverse | filter:filterText" 
                                             ng-click="showContextMenu(dhis2Event)">
 
                                             <!-- Visible when event is not under editing -->
@@ -278,8 +287,7 @@
                                             </td>                            
                                             <td>                                
                                                 <span ng-show="currentEvent.event == dhis2Event.event">
-                                                    <!--<a href ng-click="updateEvent()" title="{{'update'| translate}}"><span class='black'><i class="fa fa-floppy-o fa-2x"></i></span></a>-->
-                                                    <a href ng-click="showEventList()" title="{{'close_editing'| translate}}"><i class="fa fa-times-circle-o fa-2x"></i></a>       
+                                                    <a href ng-click="showEventList()" title="{{'close_editing'| translate}}"><span class='black'><i class="fa fa-times-circle-o fa-2x"></i></span></a>                                                    
                                                 </span>
                                             </td>                            
                                         </tr>

=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js	2014-02-20 11:41:24 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js	2014-02-20 13:58:38 +0000
@@ -45,8 +45,7 @@
     
     $scope.sortHeader = '';
     $scope.reverse = false;
-    $scope.gridFilter = '';
-    
+    $scope.filterText = {};   
    
     //Get orgunits for the logged in user
     OrgUnitFactory.getMine().then(function(orgUnits) {
@@ -186,6 +185,10 @@
         }        
     };
     
+    $scope.searchInGrid = function(gridColumn){        
+        $scope.filteringGrid = gridColumn;    
+    };
+    
     $scope.showEventList = function(){
         $scope.eventRegistration = false;
         $scope.editingEventInFull = false;

=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/filters.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/filters.js	2014-02-14 10:59:22 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/filters.js	2014-02-20 13:58:38 +0000
@@ -4,6 +4,28 @@
 
 var eventCaptureFilters = angular.module('eventCaptureFilters', [])
 
+.filter('gridFilter', function(){
+    
+    /* array is first argument, each addiitonal argument is prefixed by a ":" in filter markup*/
+    return function(dataArray, searchTerm){
+        
+        if(!dataArray ) return;
+        
+        /* when term is cleared, return full array*/        
+        if( !searchTerm){
+            return dataArray;
+        }
+        else{
+            
+            /* otherwise filter the array */
+            var term = searchTerm.toLowerCase();
+            return dataArray.filter(function( item){
+                return item.id.toLowerCase().indexOf(term) > -1 || item.name.toLowerCase().indexOf(term) > -1;    
+            });
+        } 
+    };    
+})
+
 .filter('paginate', function(Paginator) {
     return function(input, rowsPerPage) {
         if (!input) {

=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/styles/style.css	2014-02-20 11:41:24 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/styles/style.css	2014-02-20 13:58:38 +0000
@@ -772,6 +772,17 @@
     background-color: #ebf0f6;
 }
 
+.dhis2-table-striped-border tr th {
+    border: 1px solid #cad5e5;
+}
+
+.dhis2-table-striped-border tr td {
+    border: 1px solid #cad5e5;
+}
+
+.dhis2-table-striped-border > tbody > tr:nth-child(odd)> td, .dhis2-table-striped > tbody > tr:nth-child(odd)> th {
+    background-color: #ebf0f6
+}
 
 .dhis2-table-striped>thead>tr, 
 .dhis2-table-striped>tbody>tr, 
@@ -815,6 +826,14 @@
     display:none;
 }
 
+.pull-right {
+    float: right !important
+}
+
+.bold {
+    font-weight: bold;
+}
+
 /*----------------------------------------------------------------------------*/
 /* Bootstrap modal style
 /*----------------------------------------------------------------------------*/