← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2052: Ajax-ified the data analysis gui + added wait-message

 

------------------------------------------------------------
revno: 2052
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Tue 2010-06-29 02:24:10 +0200
message:
  Ajax-ified the data analysis gui + added wait-message
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/ViewAnalysisFormAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.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-commons-resources/src/main/webapp/main.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js	2010-05-05 09:17:27 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js	2010-06-29 00:24:10 +0000
@@ -3,7 +3,9 @@
 // Page init
 // -----------------------------------------------------------------------------
 
-$( document ).ready( function()
+$( document ).ready( function() { pageInit(); } );
+
+function pageInit()
 {
 	// Zebra stripes in lists
 	
@@ -95,7 +97,7 @@
 		{
 			window.location.href = currentPath + 'about.action' + backURL;
 		});
-} );
+}
 
 // -----------------------------------------------------------------------------
 // Menu functions

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java	2010-04-12 03:47:20 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java	2010-06-29 00:24:10 +0000
@@ -28,24 +28,21 @@
  */
 
 import java.util.Collection;
-import java.util.Date;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.ServiceProvider;
 import org.hisp.dhis.dataanalysis.DataAnalysisService;
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DeflatedDataValue;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.system.util.ConversionUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -72,18 +69,11 @@
         this.serviceProvider = serviceProvider;
     }
 
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
-    private SelectionTreeManager selectionTreeManager;
-
-    public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
-    {
-        this.selectionTreeManager = selectionTreeManager;
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
     }
 
     private PeriodService periodService;
@@ -123,32 +113,32 @@
         this.key = key;
     }
 
-    private String toDateString;
+    private String toDate;
 
     public void setToDate( String toDate )
     {
-        this.toDateString = toDate.trim();
+        this.toDate = toDate.trim();
     }
 
-    private String fromDateString;
+    private String fromDate;
 
     public void setFromDate( String fromDate )
     {
-        this.fromDateString = fromDate.trim();
-    }
-
-    private String dataSetId;
-
-    public void setDataset( String dataSet )
-    {
-        this.dataSetId = dataSet;
-    }
-
-    private List<String> dataElementsById;
-
-    public void setDataElementsById( List<String> dataElementsById )
-    {
-        this.dataElementsById = dataElementsById;
+        this.fromDate = fromDate.trim();
+    }
+
+    private Collection<String> dataSets;
+    
+    public void setDataSets( Collection<String> dataSets )
+    {
+        this.dataSets = dataSets;
+    }
+
+    private Integer organisationUnit;
+    
+    public void setOrganisationUnit( Integer organisationUnit )
+    {
+        this.organisationUnit = organisationUnit;
     }
 
     private Double standardDeviation;
@@ -175,52 +165,28 @@
 
     public String execute()
     {
-        Collection<DataElement> dataElements = null;
-        Collection<Period> periods = null;
+        Set<DataElement> dataElements = new HashSet<DataElement>();
+        
+        if ( fromDate != null && toDate != null && dataSets != null && organisationUnit != null )
+        {
+            Collection<Period> periods = periodService.getPeriodsBetweenDates( format.parseDate( fromDate ), format.parseDate( toDate ) ); //TODO improve
 
-        OrganisationUnit organisationUnit = selectionTreeManager.getSelectedOrganisationUnit();
-        
-        if ( dataElementsById != null && dataSetId != null && organisationUnit != null )
-        {
-            dataElements = dataElementService.getDataElements( ConversionUtils.getIntegerCollection( dataElementsById ) ); 
-        
-            DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
-        
-            Date fromDate = null;
-            Date toDate = null;
-    
-            if ( fromDateString == null || fromDateString.trim().length() == 0 )
-            {
-                Date epoch = new Date( 0 );
-                fromDate = epoch;
-            }
-            else
-            {
-                fromDate = format.parseDate( fromDateString );
-            }
-    
-            if ( toDateString == null || toDateString.trim().length() == 0 )
-            {
-                toDate = new Date();
-            }
-            else
-            {
-                toDate = format.parseDate( toDateString );
-            }
-    
-            periods = periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), fromDate, toDate );
+            for ( String id : dataSets )
+            {
+                dataElements.addAll( dataSetService.getDataSet( Integer.parseInt( id ) ).getDataElements() );
+            }
+        
+            OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnit );
             
-            log.info( "DataSet: " + dataSet + " Organisation unit: " + organisationUnit );
+            log.info( "From date: " + fromDate + ", To date: " + toDate + ", Organisation unit: " + unit + ", Std dev: " + standardDeviation + ", Key: " + key );
             log.info( "Nr of data elements: " + dataElements.size() + " Nr of periods: " + periods.size() );
-        }
-        
-        DataAnalysisService service = serviceProvider.provide( key );
-        
-        if ( service != null )
-        {
-            log.info( "Data analysis type: " + key );
+        
+            DataAnalysisService service = serviceProvider.provide( key );
             
-            dataValues = service.analyse( organisationUnit, dataElements, periods, standardDeviation );
+            if ( service != null )
+            {      
+                dataValues = service.analyse( unit, dataElements, periods, standardDeviation );
+            }
         }
         
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/MarkForFollowupAction.java	2010-06-29 00:24:10 +0000
@@ -145,15 +145,18 @@
         
         DataValue dataValue = dataValueService.getDataValue( source, dataElement, period, categoryOptionCombo ); 
 
-        boolean isMarked = dataValue.isFollowup();
-        
-        dataValue.setFollowup( !isMarked );
-        
-        dataValueService.updateDataValue( dataValue );
-        
-        message = !isMarked ? "marked" : "unmarked";
-        
-        log.info( !isMarked ? "Data value marked for follow-up" : "Data value unmarked for follow-up" );
+        if ( dataValue != null )
+        {
+            boolean isMarked = dataValue.isFollowup();
+            
+            dataValue.setFollowup( !isMarked );
+            
+            dataValueService.updateDataValue( dataValue );
+            
+            message = !isMarked ? "marked" : "unmarked";
+            
+            log.info( !isMarked ? "Data value marked for follow-up" : "Data value unmarked for follow-up" );
+        }
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/ViewAnalysisFormAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/ViewAnalysisFormAction.java	2009-12-24 14:47:25 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/ViewAnalysisFormAction.java	2010-06-29 00:24:10 +0000
@@ -78,12 +78,12 @@
     // -------------------------------------------------------------------------
     
     private List<DataSet> dataSets;
-        
+    
     public List<DataSet> getDataSets()
     {
         return dataSets;
     }
-    
+
     private String key;
 
     public String getKey()

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml	2010-05-26 15:58:31 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/META-INF/dhis/beans.xml	2010-06-29 00:24:10 +0000
@@ -279,10 +279,8 @@
     scope="prototype">
 	<property name="serviceProvider"
 	  ref="dataAnalysisServiceProvider"/>
-    <property name="dataElementService"
-      ref="org.hisp.dhis.dataelement.DataElementService" />
-    <property name="selectionTreeManager" 
-      ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
+    <property name="organisationUnitService"
+      ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="periodService" 
       ref="org.hisp.dhis.period.PeriodService" />
     <property name="dataSetService" 

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2010-06-19 15:32:24 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2010-06-29 00:24:10 +0000
@@ -165,3 +165,5 @@
 period_type = Period Type
 clear_expression = Clear expression
 periodtype = Periodtype
+available_data_sets = Available data sets
+selected_data_sets = Selected data sets

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2010-06-21 05:51:43 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2010-06-29 00:24:10 +0000
@@ -216,16 +216,14 @@
         ../dhis-web-commons/ouwt/ouwt.js,
         ../dhis-web-commons/oust/oust.js,       
         ../dhis-web-commons/lists/lists.js,
-        javascript/dataAnalysis.js
+        javascript/dataAnalysis.js,
+		javascript/editDataValue.js
       </param>
       <interceptor-ref name="organisationUnitTreeStack"/>
     </action>
     
     <action name="getAnalysis" class="org.hisp.dhis.validationrule.action.dataanalysis.GetAnalysisAction">
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-validationrule/searchResult.vm</param>
-      <param name="menu">/dhis-web-validationrule/menu.vm</param>
-      <param name="javascripts">javascript/editDataValue.js</param>
+      <result name="success" type="velocity">/dhis-web-validationrule/searchResult.vm</result>
     </action>
     
     <action name="editDataValue" class="org.hisp.dhis.validationrule.action.dataanalysis.EditDataValueAction">

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm	2010-05-18 06:05:52 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm	2010-06-29 00:24:10 +0000
@@ -1,12 +1,11 @@
 
 <h3>$i18n.getString( "${key}_analysis" ) #openHelp( "${key}Analysis" )</h3>
 
-<form id="analysisForm" method="post" action="getAnalysis.action">
+<div id="analysisInput">
 
 <input type="hidden" id="key" name="key" value="$!key">
 
 <table>
-	## Date
 	<tr>
 		<th>$i18n.getString( "from_date" )</th>
 		<th>$i18n.getString( "to_date" )</th>
@@ -22,47 +21,30 @@
     <tr>
         <td colspan="2" style="height:10px"></td>
     </tr>
-    
-	## DATA SET CHOOSER
-	<tr>
-		<th colspan="2" style="min-width:325px;">$i18n.getString( "select_data_set" )</th>
-	</tr>
-	<tr>
-		<td colspan="2">
-			<select name="dataset" id="dataset" style="min-width:325px" onChange="fetchDataElements()">
-				<option value="-1">[ $i18n.getString( "select_data_set" ) ]</option>
-				#foreach ( $dataSet in $dataSets )
-				<option value="$dataSet.id">$dataSet.name</option>
-				#end
-			</select>
-		</td>
-	</tr>
-	<tr>
-        <td colspan="2" style="height:10px">
-        </td>
-    </tr>
  </table>
  
- <table>    
-	## DATA ELEMENTS CHOOSER
+ <table>
 	<tr>
-		<th style="min-width:325px;">$i18n.getString( "available_data_elements" )</th>
+		<th style="min-width:325px;">$i18n.getString( "available_data_sets" )</th>
 		<td></td>
-		<th style="min-width:325px;">$i18n.getString( "selected_data_elements" )</th>
+		<th style="min-width:325px;">$i18n.getString( "selected_data_sets" )</th>
 	</tr>
 	<tr>
 		<td>
-			<select id="unselectedDataElements" name="unselectedDataElements" multiple="multiple" style="min-width:325px;height:20em" ondblclick="moveSelectedById( 'unselectedDataElements', 'dataElementsById' )" disabled="true">
+			<select id="availableDataSets" name="availableDataSets" multiple="multiple" style="min-width:325px" size="8" ondblclick="moveSelectedById( 'availableDataSets', 'dataSets' )">
+			#foreach ( $dataSet in $dataSets )
+				<option value="$dataSet.id">$encoder.htmlEncode( "$dataSet.name" )</option>
+			#end
 			</select>
 		</td>
 		<td align="center">
-			<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:40px" onclick="moveSelectedById( 'unselectedDataElements', 'dataElementsById' )"><br>
-			<input type="button" value="&lt;" title="$i18n.getString( 'move_all' )" style="width:40px" onclick="moveSelectedById( 'dataElementsById', 'unselectedDataElements' )"><br>		
-			<input type="button" value="&gt;&gt;" title="$i18n.getString( 'remove_selected' )" style="width:40px" onclick="moveAllById( 'unselectedDataElements', 'dataElementsById' )"><br>
-			<input type="button" value="&lt;&lt;" title="$i18n.getString( 'remove_all' )" style="width:40px" onclick="moveAllById( 'dataElementsById', 'unselectedDataElements' )">
+			<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:40px" onclick="moveSelectedById( 'availableDataSets', 'dataSets' )"><br>
+			<input type="button" value="&lt;" title="$i18n.getString( 'move_all' )" style="width:40px" onclick="moveSelectedById( 'dataSets', 'availableDataSets' )"><br>		
+			<input type="button" value="&gt;&gt;" title="$i18n.getString( 'remove_selected' )" style="width:40px" onclick="moveAllById( 'availableDataSets', 'dataSets' )"><br>
+			<input type="button" value="&lt;&lt;" title="$i18n.getString( 'remove_all' )" style="width:40px" onclick="moveAllById( 'dataSets', 'availableDataSets' )">
 		</td>
 		<td>
-			<select id="dataElementsById" name="dataElementsById" multiple="multiple" style="min-width:325px;height:20em" ondblclick="moveSelectedById( 'dataElementsById', 'unselectedDataElements' )" disabled="true">
+			<select id="dataSets" name="dataSets" multiple="multiple" style="min-width:325px" size="8" ondblclick="moveSelectedById( 'dataSets', 'availableDataSets' )">
 			</select>
 		</td>
 	</tr>
@@ -73,18 +55,16 @@
 </table>
 
 <table>
-	## ORG. UNIT CHOOSER
 	<tr>
 		<th colspan="2" style="min-width:325px">$i18n.getString( "select_parent_organisation_unit" )</th>
 	</tr>
 	<tr>
 		<td colspan="2">
-			<div id="selectionTree" style="width:40em;height:20em;overflow:auto;/*border:1px solid #cccccc*/"></div>
+			<div id="selectionTree" style="width:40em;height:15em;overflow:auto;"></div>
 			<script type="text/javascript">
 
           		selectionTreeSelection.setMultipleSelectionAllowed( false );
-          		// selectionTreeSelection.setOnSelectFunction( treeClicked );
-          		// selectionTreeSelection.setListenerFunction( selectCompleted );
+          		selectionTreeSelection.setListenerFunction( organisationUnitSelected );
 				selectionTree.clearSelectedOrganisationUnits();
           		selectionTree.buildSelectionTree();
 
@@ -95,8 +75,7 @@
 
 #if( $key == "stddevoutlier" )
 <div id="stddevform">
-<table>
-	## STANDARD DEVIATION INPUT FIELD	
+<table>	
     <tr>
         <td colspan="2" style="height:20px"></td>
     </tr>
@@ -128,7 +107,7 @@
     </tr>
 	<tr>
 		<td>
-			<input type="button" onclick="validateAndSubmit()" value="$i18n.getString( 'start' )" style="width:120px" />
+			<input type="button" onclick="analyseData()" value="$i18n.getString( 'start' )" style="width:120px" />
 		</td>
 	</tr>
 </table>
@@ -141,4 +120,6 @@
 	});
 </script>
 
-</form>
+</div>
+
+<div id="analysisResult"></div>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js	2009-12-24 14:47:25 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/dataAnalysis.js	2010-06-29 00:24:10 +0000
@@ -1,165 +1,52 @@
-/**
- * @author Jon Moen Drange
- *
- * Javascript file for outlier analysis web UI. Includes validation
- * of forms and some other functions to fetch choices for the form.
- *
- */
-
-/******************************************************************
- * Validates the form before posting.
- *
- * (Saves the user for extra waiting time and the
- *  server for extra processing.)
- *
- ******************************************************************/
- 
-function validateAndSubmit()
-{
-	// validating date (copied from dataBrowser.js)
-	
-	var fromDate = document.getElementById( "fromDate" ).value.split('-');
-    var toDate = document.getElementById( "toDate" ).value.split('-');
-    
-    if ( fromDate[0] != "" && fromDate.length != 3 )
-    {
-        setMessage( "Please enter valid from date" );
-        return false;
-    }
-    
-    if ( toDate[0] != "" && toDate.length != 3 )
-    {
-        setMessage( "Please enter valid to date" );
-        return false;
-    }
-    
-    if ( fromDate[0] != "" && toDate[0] != "" )
-    {
-		if ( fromDate[0] > toDate[0] )
-		{
-			setMessage( "From date is later than to date" );
-			return false;
-		}
-
-		if ( fromDate[0] == toDate[0] && fromDate[1] > toDate[1] )
-		{
-			setMessage( "From date is later than to date" );
-			return false;
-		}
-
-		if ( fromDate[0] == toDate[0] && fromDate[1] == toDate[1] && fromDate[2] > toDate[2] ) 
-		{
-			setMessage( "From date is later than to date" );
-			return false;
-		}
-	}
-
-	// validating data set / data elements selection
-
-	var dataElements = document.getElementById( "dataElementsById" );
-	
-	if ( dataElements.options.length == 0 )
-	{
-		setMessage( "No data elements are selected." );
-		return false;
-	}
-	
-	// client side validation OK
-	
-	selectAllById( "dataElementsById" ); // setting data elements to "selected" before posting
-	
-	document.getElementById( "analysisForm" ).submit();
-}
-
-
-/******************************************************************
- * AJAX.
- * 
- * Fetching data elements of a given data set from the server.
- * Clearing both boxes first, then adding the fetched data elements
- * in the left (the one with id="unselectedDataElements").
- * 
- ******************************************************************/
-
- 
-function getAndClearSelectBox()
-{
-	var unselect = document.getElementById('unselectedDataElements');
-	var select   = document.getElementById('dataElementsById');
-	 
-	while (select.childNodes.length > 0)
-	{
-		select.removeChild( select.firstChild );
-	}
-	
-	while (unselect.childNodes.length > 0)
-	{
-		unselect.removeChild( unselect.firstChild );
-	}
-	
-	unselect.disabled = false;
-	select.disabled = false;
-	
-	return unselect;	
-}
-
- 
-function fetchDataElementsSuccess( response )
-{
-	var root = response;
-	
-	var select = getAndClearSelectBox();
-
-	var n = 0;
-	
-	for (i = 0; i < root.childNodes.length; i++)
-	{
-		if (root.childNodes[i].nodeName != 'dataElement') continue;
-		
-		id   = root.childNodes[i].getElementsByTagName('id')[0].childNodes[0].nodeValue;
-		name = root.childNodes[i].getElementsByTagName('name')[0].childNodes[0].nodeValue;
-
-		select.options[ n++ ] = new Option( ''+name, ''+id );
-	}
-
-	if ( n == 0 )
-	{
-		// No data elements in given data set. Disable the boxes
-		
-		select.options[ 0 ] = new Option('[ no data elements ]', '-1');
-		
-		document.getElementById('dataElementsById').disabled = true;
-		select.disabled = true;
-	}	
-}
-
-function FetchDataElementsError( httpStatusCode )
-{
-	// error fetching data: set to "error" and disable the box
-	
-	var select = getAndClearSelectBox();
-	
-	select.options[ 0 ] = new Option('[ error fetching data elements ]', '-1');
-	
-	select.disabled = true;
-	
-	setMessage( 'An error occured while fetching data elements.' +
-				' (HTTP status code: ' + httpStatusCode + ')' );
-}
-
-function fetchDataElements()
-{
-	// new data set selected. fetch a data elements for that data set
-	
-	var dataset = document.getElementById('dataset').value;
-	
-	var request = new Request();
-	
-	request.setResponseTypeXML( 'dataElements' );
-	request.setCallbackSuccess( fetchDataElementsSuccess );
-	request.setCallbackError( FetchDataElementsError );
-	
-	request.send('../dhis-web-commons-ajax/getDataElements.action?dataSetId=' + dataset);
-}
-
- 
\ No newline at end of file
+
+var selectedOrganisationUnit = null;
+
+function organisationUnitSelected( organisationUnits )
+{
+	selectedOrganisationUnit = organisationUnits[0];
+}
+
+function analyseData()
+{
+	if ( analysisFormIsValid() == true )
+	{
+		setWaitMessage( "Analysing data, please wait..." );
+		
+		var url = "getAnalysis.action" +
+			"?key=" + $( "#key" ).val() +
+			"&toDate=" + $( "#toDate" ).val() + 
+			"&fromDate=" + $( "#fromDate" ).val() +
+			"&organisationUnit=" + selectedOrganisationUnit +
+			"&" + getParamString( "dataSets" );
+			
+		if ( $( "#standardDeviation" ) )
+		{
+			url += "&standardDeviation=" + $( "#standardDeviation" ).val();
+		}
+		
+		$.get( url, function( data ) {
+			$( "div#analysisInput" ).hide();
+			$( "div#analysisResult" ).show();
+			$( "div#analysisResult" ).html( data );
+		} );
+	}
+}
+
+function analysisFormIsValid()
+{	
+	var dataSets = document.getElementById( "dataSets" );
+	
+	if ( dataSets.options.length == 0 )
+	{
+		setMessage( "Please select at least one data set" );
+		return false;
+	}
+	
+	if ( selectedOrganisationUnit == null )
+	{
+		setMessage( "Please select an organisation unit" );
+		return false;
+	}
+	
+	return true;
+}

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm	2010-02-15 18:55:09 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/searchResult.vm	2010-06-29 00:24:10 +0000
@@ -1,14 +1,16 @@
 
-<h3>$i18n.getString( "${key}_analysis" ) $i18n.getString( "result" )</h3>
-
 #if ( $dataValues.size() == 0 )
 
 <span id="info">$i18n.getString( "no_values_found" )</span>
+
+<input type="button" onclick="window.location.href='viewAnalysisForm.action?key=$!{key}'" value="Back" style="width:120px">
 	
 #else
 
 <span id="info">$dataValues.size() $i18n.getString( "values_found" )</span>
 
+<input type="button" onclick="window.location.href='viewAnalysisForm.action?key=$!{key}'" value="Back" style="width:120px"><br><br>
+
 <table class="listTable" style="width:100%">
 	<thead>
 	<tr>
@@ -67,4 +69,6 @@
     var i18n_value_is_higher_than_max_value = '$encoder.jsEscape( $i18n.getString( "value_is_higher_than_max_value" ) , "'")';
     var i18n_mark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "mark_value_for_followup" ) , "'")';
     var i18n_unmark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "unmark_value_for_followup" ) , "'")';
+    
+    $( document ).ready( function() { pageInit(); } );
 </script>