← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2059: Ajax-ified run validation screen

 

------------------------------------------------------------
revno: 2059
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Wed 2010-06-30 18:52:11 +0200
message:
  Ajax-ified run validation screen
modified:
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java
  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/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/runValidation.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.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-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java	2010-05-26 15:58:31 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/RunValidationAction.java	2010-06-30 16:52:11 +0000
@@ -130,13 +130,6 @@
         this.validationRuleGroupId = validationRuleGroupId;
     }
 
-    private Boolean includeChildren;
-
-    public void setIncludeChildren( Boolean includeChildren )
-    {
-        this.includeChildren = includeChildren;
-    }
-
     private Map<String, List<ValidationResult>> mapValidationResults;
 
     public Map<String, List<ValidationResult>> getMapValidationResults()
@@ -152,18 +145,15 @@
     {
         Collection<? extends Source> sources = selectionTreeManager.getReloadedSelectedOrganisationUnits();
 
-        if ( includeChildren )
+        Collection<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
+
+        for ( Source source : sources )
         {
-            Collection<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
-
-            for ( Source source : sources )
-            {
-                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( source.getId() ) );
-            }
-
-            sources = organisationUnits;
+            organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( source.getId() ) );
         }
 
+        sources = organisationUnits;
+
         List<ValidationResult> validationResults = null;
 
         if ( validationRuleGroupId == -1 )
@@ -189,7 +179,6 @@
 
         for ( ValidationResult validationResult : validationResults )
         {
-
             PeriodType periodType = validationResult.getPeriod().getPeriodType();
 
             if ( periodType != null )

=== 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-06-29 00:24:10 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/dataanalysis/GetAnalysisAction.java	2010-06-30 16:52:11 +0000
@@ -180,7 +180,7 @@
             
             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 )

=== 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-29 00:24:10 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2010-06-30 16:52:11 +0000
@@ -166,6 +166,7 @@
       <param name="page">/dhis-web-validationrule/runValidationForm.vm</param>
       <param name="menu">/dhis-web-validationrule/menu.vm</param>
       <param name="javascripts">../dhis-web-commons/oust/oust.js,../dhis-web-commons/ouwt/ouwt.js,javascript/general.js,javascript/runValidation.js</param>
+      <param name="stylesheets">style/validationStyle.css</param>
     </action>
             
     <action name="validateRunValidation" class="org.hisp.dhis.validationrule.action.ValidateRunValidationAction" >
@@ -175,10 +176,7 @@
     </action>
     
     <action name="runValidationAction" class="org.hisp.dhis.validationrule.action.RunValidationAction" >
-      <result name="success" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-validationrule/viewValidationResultForm.vm</param>
-      <param name="javascripts">javascript/runValidation.js</param>
-      <param name="stylesheets">style/validationStyle.css</param>
+      <result name="success" type="velocity">/dhis-web-validationrule/viewValidationResultForm.vm</result>
     </action>
     
     <action name="viewValidationResultDetails" class="org.hisp.dhis.validationrule.action.GetValidationResultDetailsAction">

=== 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-06-29 00:24:10 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/dataAnalysisForm.vm	2010-06-30 16:52:11 +0000
@@ -60,7 +60,7 @@
 	</tr>
 	<tr>
 		<td colspan="2">
-			<div id="selectionTree" style="width:40em;height:15em;overflow:auto;"></div>
+			<div id="selectionTree" style="width:400px;height:350px;overflow:auto;"></div>
 			<script type="text/javascript">
 
           		selectionTreeSelection.setMultipleSelectionAllowed( false );

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js	2010-06-30 16:52:11 +0000
@@ -18,9 +18,16 @@
     
     if ( type == 'success' )
     {
-        var form = document.getElementById( 'runValidationForm' );
-        
-        form.submit();
+    	setWaitMessage( "Analysing data, please wait..." );
+    	
+        var url = 'runValidationAction.action?startDate=' + getFieldValue( 'startDate' ) +
+        	'&endDate=' + getFieldValue( 'endDate' ) + '&validationRuleGroupId=' + $( "#validationRuleGroupId" ).val();
+        	        
+		$.get( url, function( data ) {
+			$( "div#analysisInput" ).hide();
+			$( "div#analysisResult" ).show();
+			$( "div#analysisResult" ).html( data );
+		} );
     }
     else if ( type == 'error' )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm	2010-05-18 06:05:52 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm	2010-06-30 16:52:11 +0000
@@ -1,7 +1,7 @@
 
 <h3>$encoder.htmlEncode( $i18n.getString( "run_validation" ) ) #openHelp( "validationRuleAnalysis" )</h3>
 
-<form id="runValidationForm" class="form" action="runValidationAction.action" method="post" onsubmit="return validateRunValidation()">
+<div id="analysisInput">
 
 <table>
     <tr>
@@ -37,29 +37,18 @@
     	<td style="height:10px" colspan="2"></td>
     </tr>
     <tr>
-        <td>$i18n.getString( 'select_organisation_unit' ):</td>
-        <td>
-    	    <select id="includeChildren" name="includeChildren" style="width:20em">
-                <option value="true" selected="selected">$i18n.getString( "organisation_unit_with_children" )</option>
-                <option value="false">$i18n.getString( "organisation_unit_only" )</option>
-            </select>
-        </td>
-    </tr>
-    <tr>
         <td colspan="2">
     		<div id="selectionTree" style="width:35em;height:350px;overflow:auto;border:1px solid #cccccc"></div>
     	</td>
     </tr>
     <tr>
     	<td>
-    		<input type="submit" value="$i18n.getString( 'validate' )" style="width:10em">
+    		<input type="button" value="$i18n.getString( 'validate' )" style="width:10em" onclick="validateRunValidation()">
     	</td>
     	<td></td>
     </tr>
 </table>
 	
-</form>
-
 <span id="message"></span>
 
 <script type="text/javascript">
@@ -71,3 +60,7 @@
 		datePickerInRange( 'startDate' , 'endDate' );	
 	});
 </script>
+
+</div>
+
+<div id="analysisResult"></div>