← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8064: live filtering on sections, wip (works, but needs polish)

 

------------------------------------------------------------
revno: 8064
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-09-13 13:40:05 +0700
message:
  live filtering on sections, wip (works, but needs polish)
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm


--
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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2012-09-13 04:01:07 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2012-09-13 06:40:05 +0000
@@ -452,6 +452,23 @@
     }
 }
 
+function filterInSection($this)
+{
+    var $tbody = $this.parent().parent().parent();
+
+    if($this.val() == '')
+    {
+        $tbody.find("tr:not([colspan])").show();
+    }
+    else
+    {
+        var $not_matched = $tbody.find('tr:not([colspan])').find('td:first-child(:not(:contains("' + $this.val() + '"))')
+        $not_matched.parent().parent(). hide();
+    }
+
+    console.log($this)
+}
+
 function getDataElementType( dataElementId )
 {
 	if ( dataElements[dataElementId] != null )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2011-09-08 15:28:20 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2012-09-13 06:40:05 +0000
@@ -25,12 +25,13 @@
     #set( $categories = $orderedCategories.get( $categoryComboId ) )
     #set( $optionsMap = $orderedOptionsMap.get( $categoryComboId ) )
     #set( $colRepeat = $catColRepeat.get( $categoryComboId ) )
-	
+    #set( $hasFilterInSection = false )
+
     #foreach( $category in $categories )
     #set( $categoryOptions = $optionsMap.get( $category.id ) )
     #set( $colCount = $colCount / $categoryOptions.size() )
     <tr colspan="$colCount">
-    <td></td>
+    <td>#if( $hasFilterInSection == false )<input type="text" placeholder="Filter in section.." class="reg" onkeyup="filterInSection($(this));">#set( $hasFilterInSection = true )#end</td>
     #set( $cols = $colRepeat.get( $category.id ) )
     #foreach( $col in $cols )
     #foreach( $categoryOption in $categoryOptions )