← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3683: implemented free text filtering in dataElements/indicators ajax-json

 

------------------------------------------------------------
revno: 3683
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-05-20 11:56:37 +0200
message:
  implemented free text filtering in dataElements/indicators ajax-json
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java


--
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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js	2011-05-19 12:30:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js	2011-05-20 09:56:37 +0000
@@ -226,7 +226,7 @@
       });
 
       $filter_button.click(function() {
-         params.key = $filter_input.val();
+         params.key = escape( $filter_input.val() );
 
          if(params.key.length === 0) {
              delete params.key;

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java	2011-05-19 11:57:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java	2011-05-20 09:56:37 +0000
@@ -27,11 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.util.ListIterator;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -142,6 +144,13 @@
         this.periodTypeName = periodTypeName;
     }
 
+    private String key;
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+    
     private List<Integer> removeDataSets = new ArrayList<Integer>();
 
     public void setRemoveDataSets( String removeDataSets )
@@ -258,6 +267,22 @@
             }
         }
 
+        if( key != null )
+        {
+            ListIterator<DataElement> iterator = dataElements.listIterator();
+            key = URLDecoder.decode( key, "UTF-8" ).toLowerCase();
+            
+            while( iterator.hasNext() )
+            {
+                DataElement dataElement = iterator.next();
+                
+                if ( dataElement.getName().toLowerCase().indexOf( key ) == -1)
+                {
+                    iterator.remove();
+                }
+            }
+        }
+        
         Collections.sort( dataElements, dataElementComparator );
 
         if ( aggregate )

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java	2011-05-19 11:57:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java	2011-05-20 09:56:37 +0000
@@ -27,13 +27,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.util.ListIterator;
 
-import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.indicator.Indicator;
@@ -205,7 +206,23 @@
                 indicators.remove( indicator );
             }
         }
-        
+
+        if ( key != null )
+        {
+            ListIterator<Indicator> iterator = indicators.listIterator();
+            key = URLDecoder.decode( key, "UTF-8" ).toLowerCase();
+
+            while ( iterator.hasNext() )
+            {
+                Indicator indicator = iterator.next();
+
+                if ( indicator.getName().toLowerCase().indexOf( key ) == -1)
+                {
+                    iterator.remove();
+                }
+            }
+        }
+
         Collections.sort( indicators, indicatorComparator );
 
         if ( usePaging )