← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3375: Jquerified parts of dataentry

 

------------------------------------------------------------
revno: 3375
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-04-12 21:30:34 +0200
message:
  Jquerified parts of dataentry
removed:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseNone.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseSuccess.vm
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
  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/history.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-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2011-04-08 12:10:37 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2011-04-12 19:30:34 +0000
@@ -238,6 +238,6 @@
             }
         }
         
-        return dataValues.size() == 0 && results.size() == 0 ? NONE : SUCCESS;
+        return dataValues.size() == 0 && results.size() == 0 ? SUCCESS : INPUT;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2011-01-25 14:49:09 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2011-04-12 19:30:34 +0000
@@ -97,28 +97,27 @@
 		</action>
 
 		<action name="registerCompleteDataSet" class="org.hisp.dhis.de.action.RegisterCompleteDataSetAction">
-			<result name="success" type="velocity">/dhis-web-dataentry/responseVoid.vm</result>
-			<result name="input" type="velocity-xml">/dhis-web-dataentry/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="undoCompleteDataSet" class="org.hisp.dhis.de.action.UndoCompleteDataSetAction">
-			<result name="success" type="velocity">/dhis-web-dataentry/responseVoid.vm</result>
+			<result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+		</action>
+
+		<action name="getValidationViolations" class="org.hisp.dhis.de.action.ValidationAction">
+			<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="validate" class="org.hisp.dhis.de.action.ValidationAction">
 			<result name="success" type="velocity">/popup.vm</result>
-			<result name="none" type="velocity">/popup.vm</result>
+			<result name="input" type="velocity">/popup.vm</result>
 			<param name="page">/dhis-web-dataentry/validationResult.vm</param>
 		</action>
 
-		<action name="getValidationViolations" class="org.hisp.dhis.de.action.ValidationAction">
-			<result name="success" type="velocity-xml">/dhis-web-dataentry/responseSuccess.vm</result>
-			<result name="none" type="velocity-xml">/dhis-web-dataentry/responseNone.vm
-			</result>
-		</action>
-
 		<action name="markValueForFollowup" class="org.hisp.dhis.de.action.MarkForFollowupAction">
-			<result name="success" type="velocity-xml">/dhis-web-dataentry/responseSuccess.vm</result>
+			<result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 		</action>
 
 		<action name="getHistoryChart" class="org.hisp.dhis.de.action.GetHistoryChartAction">

=== 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	2011-04-11 16:43:51 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-04-12 19:30:34 +0000
@@ -1,26 +1,15 @@
 
 var significantZeros = []; // Identifiers for which zero values are insignificant, also used in entry.js
 
-function addEventListeners() 
+function addEventListeners()
 {
-	var inputs = document.getElementsByName( "entryfield" ) 
-
-	for ( var i = 0, input; input = inputs[i]; i++ )
-	{
-		input.addEventListener('focus', valueFocus, false);
-	}
-
-    var selects = document.getElementsByName( "entryselect" );
-
-	for ( var i = 0, select; select = selects[i]; i++ )
-	{
-		select.addEventListener('focus', valueFocus, false);
-	}
+	$( '[name="entryfield"]' ).focus( valueFocus );
+	$( '[name="entryselect"]' ).focus( valueFocus );
 }
 
 function clearPeriod()
 {	
-	clearList( document.getElementById( 'selectedPeriodIndex' ) );	
+	clearListById( 'selectedPeriodIndex' );	
 	clearEntryForm();
 }
 
@@ -283,8 +272,7 @@
 	}
 	
 	if( minContainer )
-	{
-	    	    
+	{	    	    
 	    if( minContainer.firstChild )
 	    {        
 	        optionName += " - "+minContainer.firstChild.nodeValue; 
@@ -357,48 +345,22 @@
 {
 	var confirmed = confirm( i18n_confirm_complete );
 	
-	if ( confirmed )
-	{
-	    var url = "getValidationViolations.action";
-    
-        var request = new Request();
-        request.setResponseTypeXML( 'message' );
-        request.setCallbackSuccess( registerCompleteDataSet );
-        request.send( url );        
-	}
-}
-
-function registerCompleteDataSet( messageElement )
-{
-    var type = messageElement.getAttribute( 'type' );
-    
-    if ( type == "none" )
-    {    
-        var url = "registerCompleteDataSet.action";
-    
-        var request = new Request();
-		request.setResponseTypeXML( 'message' );
-        request.setCallbackSuccess( registerReceived );
-        request.send( url );
-    }
-    else
-    {
-        window.open( 'validate.action', '_blank', 'width=800, height=400, scrollbars=yes, resizable=yes' );
-    }
-}
-
-function registerReceived( messageElement )
-{
-	var type = messageElement.getAttribute( 'type' );
-	
-    if ( type=='input' )
-    {
-		setHeaderDelayMessage( messageElement.firstChild.nodeValue );
-		return;
-	}
-	
-	document.getElementById( "completeButton" ).disabled = true;
-	document.getElementById( "undoButton" ).disabled = false;
+	if ( confirmed ) {
+		$.getJSON( 'getValidationViolations.action', registerCompleteDataSet );
+	}
+}
+
+function registerCompleteDataSet( json )
+{
+	if ( json.response == 'success' ) {
+		$.getJSON( 'registerCompleteDataSet.action', function() {
+			$( '#completeButton' ).attr( 'disabled', 'disabled' );
+			$( '#undoButton' ).removeAttr( 'disabled' );
+		} );
+	}
+	else {
+		window.open( 'validate.action', '_blank', 'width=800, height=400, scrollbars=yes, resizable=yes' );
+	}
 }
 
 function undoCompleteDataSet()
@@ -407,20 +369,13 @@
 	
 	if ( confirmed )
 	{
-        var url = "undoCompleteDataSet.action";
-    
-        var request = new Request();
-        request.setCallbackSuccess( undoReceived );
-        request.send( url );
+		$.getJSON( 'undoCompleteDataSet.action', function() {
+			$( '#completeButton' ).removeAttr( 'disabled' );
+			$( '#undoButton' ).attr( 'disabled', 'disabled' );
+		} );
 	}
 }
 
-function undoReceived( messageElement )
-{
-    document.getElementById( "completeButton" ).disabled = false;
-    document.getElementById( "undoButton" ).disabled = true;
-}
-
 // -----------------------------------------------------------------------------
 // Validation
 // -----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2011-02-15 02:41:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2011-04-12 19:30:34 +0000
@@ -182,28 +182,18 @@
 
 function markValueForFollowup( dataElementId, periodId, sourceId, categoryOptionComboId )
 {
-    var url = "markValueForFollowup.action?dataElementId=" + dataElementId + "&periodId=" + periodId +
-        "&sourceId=" + sourceId + "&categoryOptionComboId=" + categoryOptionComboId;
+    var url = 'markValueForFollowup.action?dataElementId=' + dataElementId + '&periodId=' + periodId +
+        '&sourceId=' + sourceId + '&categoryOptionComboId=' + categoryOptionComboId;
     
-    var request = new Request();
-    request.setResponseTypeXML( "message" );
-    request.setCallbackSuccess( markValueForFollowupReceived );    
-    request.send( url );
+    $.getJSON( url, function( json ) {
+    	
+    	if ( json.message == 'marked' ) {
+    		$( '#followup' ).attr( 'src', '../images/marked_large.png' );
+    		$( '#followup' ).attr( 'alt', i18n_unmark_value_for_followup );
+    	}
+    	else if ( json.message == 'unmarked' ) {
+    		$( '#followup' ).attr( 'src', '../images/unmarked_large.png' );
+    		$( '#followup' ).attr( 'alt', i18n_mark_value_for_followup );
+    	}
+    } );
 }
-
-function markValueForFollowupReceived( messageElement )
-{	
-    var message = messageElement.firstChild.nodeValue;
-    var image = document.getElementById( "followup" );
-    
-    if ( message == "marked" )
-    {
-    	image.src = "../images/marked_large.png";
-        image.alt = i18n_unmark_value_for_followup;
-    }
-    else if ( message = "unmarked" )
-    {
-        image.src = "../images/unmarked_large.png";
-        image.alt = i18n_mark_value_for_followup;  	
-    }
-}
\ No newline at end of file

=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseNone.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseNone.vm	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseNone.vm	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<message type="none">$!encoder.xmlEncode( $!message )</message>

=== removed file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseSuccess.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseSuccess.vm	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseSuccess.vm	1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<message type="success">$!encoder.xmlEncode( $!message )</message>