← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4897: Jquerification

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4897 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-10-11 16:17:49 +0200
message:
  Jquerification
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.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-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-09-19 13:34:58 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-10-11 14:15:32 +0000
@@ -66,6 +66,8 @@
 cannot_crosstab_all_dimensions= You cannot crosstabulate all dimensions
 cannot_crosstab_no_dimensions= Please select at least one dimension
 must_select_at_least_one_indictor_data_element_data_set = Please select at least one indicator, data element or data set
+must_select_at_least_one_indicator = Please select at least one indicator
+must_select_at_least_one_dataelement = Please select at least one data element
 must_select_at_least_one_unit= Please select at least one organisation unit
 must_select_at_least_one_period= Please select at least one period
 target_line_value_must_be_provided = Target line value must be provided when target lines are enabled.

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-09-29 06:40:09 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-10-11 14:17:16 +0000
@@ -57,7 +57,7 @@
     </action>
 
     <action name="addDocumentToDashboard" class="org.hisp.dhis.reporting.document.action.AddDocumentToDashboardAction">
-      <result name="success" type="velocity-xml">/dhis-web-reporting/responseSuccess.vm</result>
+      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
     
@@ -109,8 +109,8 @@
     </action>
 	
     <action name="validateChart" class="org.hisp.dhis.reporting.chart.action.ValidateChartAction">
-      <result name="success" type="velocity-xml">/dhis-web-reporting/responseSuccess.vm</result>
-      <result name="input" type="velocity-xml">/dhis-web-reporting/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>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
     
@@ -212,7 +212,7 @@
     </action>
 	
     <action name="addReportToDashboard" class="org.hisp.dhis.reporting.reportviewer.action.AddReportToDashboardAction">
-      <result name="success" type="velocity-xml">/dhis-web-reporting/responseSuccess.vm</result>
+      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
 
@@ -337,13 +337,13 @@
     </action>
 
     <action name="validateTable" class="org.hisp.dhis.reporting.tablecreator.action.ValidateTableAction">
-      <result name="success" type="velocity-xml">/dhis-web-reporting/responseSuccess.vm</result>
-      <result name="input" type="velocity-xml">/dhis-web-reporting/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>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
 
     <action name="addReportTableToDashboard" class="org.hisp.dhis.reporting.tablecreator.action.AddReportTableToDashboardAction">
-      <result name="success" type="velocity-xml">/dhis-web-reporting/responseSuccess.vm</result>
+      <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js	2011-09-29 06:40:09 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/chart.js	2011-10-11 14:15:32 +0000
@@ -65,53 +65,43 @@
 // Validate and save
 // -----------------------------------------------------------------------------
 
+
 function saveChart()
 {
     if ( validateTargetLine() && validateCollections() )
     {
-        var url = "validateChart.action?id=" + getFieldValue( "id" ) + "&title=" + getFieldValue( "title" );
-
-        var request = new Request();
-        request.setResponseTypeXML( 'message' );
-        request.setCallbackSuccess( saveChartReceived );
-        request.send( url );
-    }
-}
-
-function saveChartReceived( messageElement )
-{
-    var type = messageElement.getAttribute( 'type' );
-    var message = messageElement.firstChild.nodeValue;
-    var dimension = document.getElementById( "dimension" ).value;
-
-    if ( type == "input" )
-    {
-        setMessage( message );
-
-        return false;
-    } else if ( type == "success" )
-    {
-        if ( $( "#selectedIndicators" ).attr( 'multiple' ) !== undefined )
-        {
-            $( "#selectedIndicators" ).children().attr( "selected", true );
-        }
-
-        if ( $( "#selectedDataElements" ).attr( 'multiple' ) !== undefined )
-        {
-            $( "#selectedDataElements" ).children().attr( "selected", true );
-        }
-
-        if ( $( "#selectedPeriods" ).attr( 'multiple' ) !== undefined )
-        {
-            $( "#selectedPeriods" ).children().attr( "selected", true );
-        }
-
-        if ( $( "#selectedOrganisationUnits" ).attr( 'multiple' ) !== undefined )
-        {
-            $( "#selectedOrganisationUnits" ).children().attr( "selected", true );
-        }
-
-        $( '#chartForm' ).submit();
+    	$.postJSON( "validateChart.action", { id:getFieldValue( "id" ), title:getFieldValue( "title" ) }, function( json )
+    	{
+    		if ( json.response == "input" )
+    		{
+    			setMessage( json.message );
+    			return false;
+    		}
+    		else if ( json.response == "success" )
+    		{
+    			if ( $( "#selectedIndicators" ).attr( 'multiple' ) !== undefined )
+		        {
+		            $( "#selectedIndicators" ).children().attr( "selected", true );
+		        }
+		
+		        if ( $( "#selectedDataElements" ).attr( 'multiple' ) !== undefined )
+		        {
+		            $( "#selectedDataElements" ).children().attr( "selected", true );
+		        }
+		
+		        if ( $( "#selectedPeriods" ).attr( 'multiple' ) !== undefined )
+		        {
+		            $( "#selectedPeriods" ).children().attr( "selected", true );
+		        }
+		
+		        if ( $( "#selectedOrganisationUnits" ).attr( 'multiple' ) !== undefined )
+		        {
+		            $( "#selectedOrganisationUnits" ).children().attr( "selected", true );
+		        }
+		
+		        $( "#chartForm" ).submit();
+		    }
+    	} );
     }
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2011-09-29 12:57:18 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2011-10-11 14:15:32 +0000
@@ -4,33 +4,22 @@
 
 function saveTable()
 {
-    if ( validateCollections() )
-    {
-        var url = "validateTable.action?id=" + getFieldValue( "tableId" ) + "&name=" + getFieldValue( "tableName" );
-
-        var request = new Request();
-        request.setResponseTypeXML( 'message' );
-        request.setCallbackSuccess( saveTableReceived );
-        request.send( url );
-    }
-}
-
-function saveTableReceived( messageElement )
-{
-    var type = messageElement.getAttribute( 'type' );
-    var message = messageElement.firstChild.nodeValue;
-
-    if ( type == "input" )
-    {
-        setMessage( message );
-
-        return false;
-    } else if ( type == "success" )
-    {
-        selectTableForm();
-
-        document.getElementById( "tableForm" ).submit();
-    }
+	if ( validateCollections() )
+	{
+		$.postJSON( "validateTable.action", { id:getFieldValue( "tableId" ), "name":getFieldValue( "tableName" ) }, function( json )
+		{
+			if ( json.response == "input" )
+			{
+				setMessage( json.message );
+				return false;
+			}
+			else if ( json.response == "success" )
+			{
+				selectTableForm();
+	        	$( "#tableForm" ).submit();
+			}
+		} );
+	}
 }
 
 function selectTableForm()