← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13224: Data entry, using web api to save values

 

------------------------------------------------------------
revno: 13224
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-13 16:09:46 +0100
message:
  Data entry, using web api to save values
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-11-07 11:52:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-12-13 15:09:46 +0000
@@ -153,7 +153,7 @@
         }
     }
 
-    public static void okResponse( HttpServletResponse response, String message )
+    public static void okResponse( HttpServletResponse response, String message ) //TODO remove message
     {
         setResponse( response, HttpServletResponse.SC_OK, message );
     }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css	2013-12-11 20:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/login.css	2013-12-13 15:09:46 +0000
@@ -94,7 +94,7 @@
   padding: 6px 6px;
   margin: 4px 0;
   border-radius: 3px;
-  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.18);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.15);
 }
 
 #loginMessage

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-09-20 15:13:05 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-12-13 15:09:46 +0000
@@ -275,10 +275,10 @@
 function ValueSaver( dataElementId, optionComboId, organisationUnitId, periodId, value, fieldId, resultColor )
 {
     var dataValue = {
-        'dataElementId' : dataElementId,
-        'optionComboId' : optionComboId,
-        'organisationUnitId' : organisationUnitId,
-        'periodId' : periodId,
+        'de' : dataElementId,
+        'cc' : optionComboId,
+        'ou' : organisationUnitId,
+        'pe' : periodId,
         'value' : value
     };
 
@@ -287,7 +287,7 @@
         storageManager.saveDataValue( dataValue );
 
         $.ajax( {
-            url: 'saveValue.action',
+            url: '../api/dataValues',
             data: dataValue,
             dataType: 'json',
             success: handleSuccess,
@@ -295,33 +295,25 @@
         } );
     };
 
-    function handleSuccess( json )
+    function handleSuccess()
     {
-        var code = json.c;
-
-        if ( code == 0 ) // Value successfully saved on server
-        {
-        	storageManager.clearDataValueJSON( dataValue );
-            markValue( fieldId, resultColor );
-        }
-        else if ( code == 2 )
-        {
-            markValue( fieldId, COLOR_RED );
-            window.alert( i18n_saving_value_failed_dataset_is_locked );
-        }
-        else // Server error during save
-        {
-            markValue( fieldId, COLOR_RED );
-            window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
-        }
-        
+    	storageManager.clearDataValueJSON( dataValue );
+        markValue( fieldId, resultColor );
         $( 'body' ).trigger( EVENT_VALUE_SAVED, dataValue );
     }
 
-    function handleError( jqXHR, textStatus, errorThrown )
+    function handleError( xhr, textStatus, errorThrown )
     {
-        setHeaderMessage( i18n_offline_notification );
-        markValue( fieldId, resultColor );
+    	if ( 409 == xhr.status ) // Invalid value or locked
+    	{
+    		markValue( fieldId, COLOR_RED );
+    		setHeaderMessage( xhr.responseText );
+    	}
+    	else // Offline
+    	{
+    		setHeaderMessage( i18n_offline_notification );
+    		markValue( fieldId, resultColor );
+    	}
     }
 
     function markValue( fieldId, color )

=== 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	2013-11-21 11:27:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-12-13 15:09:46 +0000
@@ -222,12 +222,12 @@
 	    {
 	        var metaData = JSON.parse( sessionStorage[KEY_METADATA] );
 
-          emptyOrganisationUnits = metaData.emptyOrganisationUnits;
+            emptyOrganisationUnits = metaData.emptyOrganisationUnits;
 	        significantZeros = metaData.significantZeros;
 	        dataElements = metaData.dataElements;
 	        indicatorFormulas = metaData.indicatorFormulas;
 	        dataSets = metaData.dataSets;
-          optionSets = metaData.optionSets;
+            optionSets = metaData.optionSets;
 	        dataSetAssociationSets = metaData.dataSetAssociationSets;
 	        organisationUnitAssociationSetMap = metaData.organisationUnitAssociationSetMap;