← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13382: Data entry, fixed minor bug, indicator totals were not updated for values outside min-max ranges

 

------------------------------------------------------------
revno: 13382
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-12-22 10:34:24 +0100
message:
  Data entry, fixed minor bug, indicator totals were not updated for values outside min-max ranges
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.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/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-12-21 18:46:53 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-12-22 09:34:24 +0000
@@ -136,6 +136,8 @@
 		value = '';
 	}
 
+	var warning = undefined;
+	
     if ( value != '' )
     {
         if ( type == 'string' || type == 'int' || type == 'number' || type == 'positiveNumber' || type == 'negativeNumber' || type == 'zeroPositiveInt' )
@@ -186,33 +188,30 @@
 
                 if ( valueNo < min )
                 {
-                    var valueSaver = new ValueSaver( dataElementId, optionComboId, getCurrentOrganisationUnit(), periodId,
-                            value, fieldId, COLOR_ORANGE );
-                    valueSaver.save();
-
-                    window.alert( i18n_value_of_data_element_less + ': ' + min + '\n\n' + dataElementName );
-                    return;
+                    warning = i18n_value_of_data_element_less + ': ' + min + '\n\n' + dataElementName;
                 }
 
                 if ( valueNo > max )
                 {
-                    var valueSaver = new ValueSaver( dataElementId, optionComboId, getCurrentOrganisationUnit(), periodId,
-                            value, fieldId, COLOR_ORANGE );
-                    valueSaver.save();
-
-                    window.alert( i18n_value_of_data_element_greater + ': ' + max + '\n\n' + dataElementName );
-                    return;
+                    warning = i18n_value_of_data_element_greater + ': ' + max + '\n\n' + dataElementName;
                 }
             }
         }
     }
-
+    
+    var color = warning ? COLOR_ORANGE : COLOR_GREEN;
+    
     var valueSaver = new ValueSaver( dataElementId, optionComboId, 
-    	getCurrentOrganisationUnit(), periodId, value, fieldId, COLOR_GREEN );
+    	getCurrentOrganisationUnit(), periodId, value, fieldId, color );
     valueSaver.save();
 
     updateIndicators(); // Update indicators for custom form
     updateDataElementTotals(); // Update data element totals for custom forms
+    
+    if ( warning )
+    {
+    	window.alert( warning );
+    }
 }
 
 function saveBoolean( dataElementId, optionComboId, fieldId )