← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6083: Js fix

 

------------------------------------------------------------
revno: 6083
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-02-22 19:07:04 +0100
message:
  Js fix
modified:
  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/javascript/runValidation.js


--
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/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2012-02-22 17:43:09 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/struts.xml	2012-02-22 18:07:04 +0000
@@ -138,9 +138,8 @@
     </action>
 
     <action name="validateRunValidation" class="org.hisp.dhis.validationrule.action.ValidateRunValidationAction">
-      <result name="success" type="velocity-xml">/dhis-web-validationrule/responseSuccess.vm</result>
-      <result name="error" type="velocity-xml">/dhis-web-validationrule/responseError.vm</result>
-      <result name="input" type="velocity-xml">/dhis-web-validationrule/responseInput.vm</result>
+      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+      <result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
     </action>
 
     <action name="runValidationAction" class="org.hisp.dhis.validationrule.action.RunValidationAction">

=== 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	2012-01-22 06:34:56 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/runValidation.js	2012-02-22 18:07:04 +0000
@@ -1,7 +1,7 @@
 var startDate;
 var endDate;
+var aggregate;
 var validationRuleGroupId;
-var aggregate;
 var organisationUnitId;
 
 function organisationUnitSelected( ids )
@@ -11,49 +11,36 @@
 
 function validateRunValidation()
 {
-    var request = new Request();
-    request.setResponseTypeXML( 'message' );
-    request.setCallbackSuccess( runValidationCompleted );
-
-    request.send( 'validateRunValidation.action?startDate=' + getFieldValue( 'startDate' ) + '&endDate='
-            + getFieldValue( 'endDate' ) + '&aggregate=' + getFieldValue( 'aggregate' ) );
+	startDate = $( '#startDate' ).val();
+	endDate = $( '#endDate' ).val();
+	aggregate = $( '#aggregate' ).val();
+	validationRuleGroupId = $( '#validationRuleGroupId' ).val();
+
+	$.getJSON( 'validateRunValidation.action',
+	{ startDate:startDate, endDate:endDate, aggregate:aggregate }, function( json )
+	{
+		if ( json.response == 'success' )
+	    {
+	        setWaitMessage( i18n_analysing_please_wait );
+
+	        $.get( 'runValidationAction.action', 
+	        { organisationUnitId:organisationUnitId, startDate:startDate, endDate:endDate, validationRuleGroupId:validationRuleGroupId, aggregate:aggregate }, function( data )
+	        {
+	            $( 'div#analysisInput' ).hide();
+	            $( 'div#analysisResult' ).show();
+	            $( 'div#analysisResult' ).html( data );
+	            pageInit();
+	        } );
+	    }
+	    else if ( json.response == 'input' )
+	    {
+	        setMessage( json.message );
+	    }
+	} );
 
     return false;
 }
 
-function runValidationCompleted( messageElement )
-{
-    var type = messageElement.getAttribute( 'type' );
-    var message = messageElement.firstChild.nodeValue;
-
-    if ( type == 'success' )
-    {
-        setWaitMessage( "Analysing data, please wait" );
-
-        startDate = getFieldValue( 'startDate' );
-        endDate = getFieldValue( 'endDate' );
-        validationRuleGroupId = $( '#validationRuleGroupId' ).val();
-        aggregate = $( '#aggregate' ).val();
-
-        var url = 'runValidationAction.action?organisationUnitId=' + organisationUnitId + '&startDate=' + startDate
-                + '&endDate=' + endDate + '&validationRuleGroupId=' + validationRuleGroupId + '&aggregate=' + aggregate;
-
-        $.get( url, function( data )
-        {
-            $( "div#analysisInput" ).hide();
-            $( "div#analysisResult" ).show();
-            $( "div#analysisResult" ).html( data );
-            pageInit();
-        } );
-    } else if ( type == 'error' )
-    {
-        window.alert( i18n_validation_failed + ':' + '\n' + message );
-    } else if ( type == 'input' )
-    {
-        setMessage( message );
-    }
-}
-
 function drillDownValidation( orgUnitId )
 {
     setHeaderWaitMessage( i18n_analysing_please_wait );