← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2163: Replicated the function for ignoring zero values based on the general system setting and the data...

 

------------------------------------------------------------
revno: 2163
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2010-11-24 21:34:35 +0100
message:
  Replicated the function for ignoring zero values based on the general system setting and the dataelement property on the data entry client side. This should reduce the load on the server as no request will be made for such values.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm
  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
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm


--
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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2010-11-24 20:34:35 +0000
@@ -1286,42 +1286,29 @@
 	window.location.href = 'exportToPdf.action?type=' + type + activeIds;
 }
 
-
 function isNumber( value )
 {
-    var number = new Number( value );
-    
-    if ( isNaN(parseFloat(value) ) )
-    {
-        return false;
-    }
-    return true;
+	var regex = /^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;
+	return regex.test( value );
 }
 
 function isInt(value)
 {
-	if(((value) == parseInt(value)) && !isNaN(parseInt(value)))
-	{
-		return true;
-	} else {
-		  return false;
-	} 
-}
-
-function isPositiveNumber(value)
-{
-	if(parseFloat(value) > 0 ){
-		return true;
-	} else {
-		return false;
-	} 
-}
-
-function isNegativeNumber(value)
-{
-	if(parseFloat(value) < 0 ){
-		return true;
-	} else {
-		return false;
-	} 
-}
\ No newline at end of file
+	var regex = /^\d+$/;
+	return regex.test( value );
+}
+
+function isPositiveNumber( value )
+{
+	return isNumber( value ) && parseFloat( value ) > 0;
+}
+
+function isNegativeNumber( value )
+{
+	return isNumber( value ) && parseFloat( value ) < 0;
+}
+
+function isZeroNumber( value )
+{
+	return isNumber( value ) && parseFloat( value ) == 0;
+}

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2010-11-18 13:17:32 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2010-11-24 20:34:35 +0000
@@ -27,8 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.options.SystemSettingManager.KEY_ZERO_VALUE_SAVE_MODE;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -60,7 +58,6 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.minmax.MinMaxDataElement;
 import org.hisp.dhis.minmax.MinMaxDataElementService;
-import org.hisp.dhis.options.SystemSettingManager;
 import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
@@ -90,13 +87,6 @@
         this.customValueService = customValueService;
     }
 
-    private SystemSettingManager systemSettingManager;
-
-    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
-    {
-        this.systemSettingManager = systemSettingManager;
-    }
-
     private DataElementService dataElementService;
 
     public void setDataElementService( DataElementService dataElementService )
@@ -185,6 +175,7 @@
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
+    
     private List<CustomValue> customValues = new ArrayList<CustomValue>();
 
     public List<CustomValue> getCustomValues()
@@ -367,8 +358,6 @@
     public String execute()
         throws Exception
     {
-        zeroValueSaveMode = (Boolean) systemSettingManager.getSystemSetting( KEY_ZERO_VALUE_SAVE_MODE, false );
-
         OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
 
         DataSet dataSet = selectedStateManager.getSelectedDataSet();

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java	2010-11-21 15:52:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadPeriodsAction.java	2010-11-24 20:34:35 +0000
@@ -2,8 +2,10 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 
+import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.de.state.SelectedStateManager;
@@ -69,6 +71,13 @@
         return periodValid;
     }
     
+    private Collection<DataElement> significantZeros = new HashSet<DataElement>();
+
+    public Collection<DataElement> getSignificantZeros()
+    {
+        return significantZeros;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -108,6 +117,18 @@
             }
 
             // -----------------------------------------------------------------
+            // Load data elemements for which zero values are insignificant
+            // -----------------------------------------------------------------
+
+            for ( DataElement dataElement : selectedDataSet.getDataElements() )
+            {
+                if ( dataElement.isZeroIsSignificant() )
+                {
+                    significantZeros.add( dataElement );
+                }
+            }
+            
+            // -----------------------------------------------------------------
             // Clear display mode when loading new data set
             // -----------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-11-20 10:53:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2010-11-24 20:34:35 +0000
@@ -77,7 +77,6 @@
 		<property name="standardCommentsManager" ref="org.hisp.dhis.de.comments.StandardCommentsManager" />
 		<property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
 		<property name="selectedStateManager" ref="org.hisp.dhis.de.state.SelectedStateManager" />
-		<property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
 		<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 		<property name="customValueService" ref="org.hisp.dhis.customvalue.CustomValueService" />
 	</bean>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2010-11-22 21:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2010-11-24 20:34:35 +0000
@@ -122,7 +122,7 @@
 enter_digits                        = Enter digit only.
 value_must_number					= Value must be an number
 value_must_positive_number			= Value must be an positive number
-value_must_negative_number			= Value must be an nagative number
+value_must_negative_number			= Value must be an negative number
 datavalue_history                   = Data value history
 max_must_be_greater_than_min		= Max must be greater than min
 remove								= Remove
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm	2010-11-20 12:43:57 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm	2010-11-24 20:34:35 +0000
@@ -14,3 +14,20 @@
 		datePicker( 'dateField' );
    });
 </script>
+
+<script type="text/javascript">
+    var calculatedDataElementMap = {
+		#set( $count = 1 )
+		#foreach( $cde in $calculatedDataElementMap.keySet() )
+		  #set( $innerCount = 1 )
+		  #set( $factorMap = $calculatedDataElementMap.get($cde) )
+		  $cde.id : {
+		  #foreach ( $de in $factorMap.keySet() )
+			$de.id : $factorMap.get($de) #if ( $innerCount < $factorMap.size() ),#end
+			#set( $innerCount = $innerCount + 1 )
+		  #end
+		  } #if ( $count < $calculatedDataElementMap.size() ),#end
+		  #set( $count = $count + 1 )
+		#end
+    }
+</script>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm	2010-11-17 18:26:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm	2010-11-24 20:34:35 +0000
@@ -5,3 +5,5 @@
 <td><span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span></td>       
 #end
 $customDataEntryFormCode
+
+#parse( "/dhis-web-dataentry/completeRegistration.vm" )
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2010-11-21 16:38:52 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2010-11-24 20:34:35 +0000
@@ -56,21 +56,27 @@
     #set( $dataValue = false )
     #set( $dataValue = $dataValueMap.get( "$dataElement.id:$optionCombo.id" ) )
     #set( $dataEntryId = "value[$dataElement.id].value:value[$optionCombo.id].value" )
+    #set( $minMaxError = false )
+    #if( $dataElement.type == "int" && $dataValue && $minMax )
+      #if( $integer.parseInt( $dataValue.value ) < $minMax.min || $integer.parseInt( $dataValue.value ) > $minMax.max )
+      #set( $minMaxError = true )
+      #end
+    #end
+    <span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span><span id="value[option$optionCombo.id].name" class="hidden">$optionCombo.name</span><span id="value[$dataElement.id].name" class="hidden">$encoder.htmlEncode( $dataElement.shortName )</span><div id="value[$dataElement.id:$optionCombo.id].min" class="hidden">$!minMax.min</div><div id="value[$dataElement.id:$optionCombo.id].max" class="hidden">$!minMax.max</div>
     <td>
-      #if( $dataElement.type == "bool" )
-      <span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span>
-      <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue" )) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )"  #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
-        <option value="">[$i18n.getString( "no_value" )]</option>
-        <option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
-        <option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
-      </select>
-      #else
-      #if( $dataElement.type == "string" )
-      #set( $coun = 0 )
+    #if( $dataElement.type == "bool" )
+    <span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span>
+    <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue" )) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )"  #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
+      <option value="">[$i18n.getString( "no_value" )]</option>
+      <option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
+      <option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
+    </select>
+    #elseif( $dataElement.type == "string" )
+    #set( $coun = 0 )
       #foreach($customValue in $customValues)
-        #if($dataElement.id == $customValue.dataElement.id && $optionCombo.id == $customValue.optionCombo.id)                                    
-        #set( $coun = $coun +1 )
-        #end
+      #if($dataElement.id == $customValue.dataElement.id && $optionCombo.id == $customValue.optionCombo.id)                                    
+      #set( $coun = $coun +1 )
+      #end
       #end
       #if( $coun > 0 )
       <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue" )) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )"  #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
@@ -81,21 +87,11 @@
       #end
       </select>
       #else
-      <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100%; #if( $minMaxError )background-color:#ffcccc#end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>                                
-      #end
-      #end
-      #end
-
-      #set( $minMaxError = false )
-      #if( $dataElement.type == "int" && $dataValue && $minMax )
-        #if( $integer.parseInt( $dataValue.value ) < $minMax.min || $integer.parseInt( $dataValue.value ) > $minMax.max )
-        #set( $minMaxError = true )
-        #end
-      #end
-      <span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span><span id="value[option$optionCombo.id].name" class="hidden">$optionCombo.name</span><span id="value[$dataElement.id].name" class="hidden">$encoder.htmlEncode( $dataElement.shortName )</span><div id="value[$dataElement.id:$optionCombo.id].min" class="hidden">$!minMax.min</div><div id="value[$dataElement.id:$optionCombo.id].max" class="hidden">$!minMax.max</div>
-      #if( $dataElement.type != "string")
-      <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100%; text-align:center; #if( $minMaxError )background-color:#ffcccc#end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
-      #end
+      <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100%; text-align:center; #if( $minMaxError )background-color:#ffcccc#end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>                                
+      #end
+    #else
+    <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100%; text-align:center; #if( $minMaxError )background-color:#ffcccc#end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
+    #end
     </td>
     #set( $tabIndex = $tabIndex + 1 )
     #end
@@ -108,20 +104,3 @@
 #end
 
 #parse( "/dhis-web-dataentry/completeRegistration.vm" )
-
-<script type="text/javascript">
-    var calculatedDataElementMap = {
-		#set( $count = 1 )
-		#foreach( $cde in $calculatedDataElementMap.keySet() )
-		  #set( $innerCount = 1 )
-		  #set( $factorMap = $calculatedDataElementMap.get($cde) )
-		  $cde.id : {
-		  #foreach ( $de in $factorMap.keySet() )
-			$de.id : $factorMap.get($de) #if ( $innerCount < $factorMap.size() ),#end
-			#set( $innerCount = $innerCount + 1 )
-		  #end
-		  } #if ( $count < $calculatedDataElementMap.size() ),#end
-		  #set( $count = $count + 1 )
-		#end
-    }
-</script>

=== 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	2010-11-17 18:26:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2010-11-24 20:34:35 +0000
@@ -11,48 +11,37 @@
     
     field.style.backgroundColor = '#ffffcc';
     
-    if ( field.value != '' )
+    if ( field.value && field.value != '' )
     {
         if ( type == 'int' || type == 'number' || type == 'positiveNumber' || type == 'negativeNumber' )
         {
-            var value = new Number( field.value );       	
-        	
-            if (  type == 'int' && !isInt( field.value ))
+            if ( type == 'int' && !isInt( field.value ) )
             {
-                field.style.backgroundColor = '#ffcc00';
-                window.alert( i18n_value_must_integer + '\n\n' + dataElementName );
-                field.select();
-                field.focus();
-
-                return;
+            	window.alert( i18n_value_must_integer + '\n\n' + dataElementName );
+                return alertField( field );
             }  
-            else if (  type == 'number' && !isNumber( field.value ))
+            else if ( type == 'number' && !isNumber( field.value ) )
             {
-                field.style.backgroundColor = '#ffcc00';
                 window.alert( i18n_value_must_number + '\n\n' + dataElementName );
-                field.select();
-                field.focus();
-
-                return;
+                return alertField( field );
             } 
-			else if (  type == 'positiveNumber' && !isPositiveNumber( field.value ))
+			else if ( type == 'positiveNumber' && !isPositiveNumber( field.value ) )
             {
-                field.style.backgroundColor = '#ffcc00';
                 window.alert( i18n_value_must_positive_number + '\n\n' + dataElementName );
-                field.select();
-                field.focus();
-
-                return;
+                return alertField( field );
             } 
-			else if (  type == 'negativeNumber' && !isNegativeNumber( field.value ))
+			else if ( type == 'negativeNumber' && !isNegativeNumber( field.value ) )
             {
-                field.style.backgroundColor = '#ffcc00';
                 window.alert( i18n_value_must_negative_number + '\n\n' + dataElementName );
-                field.select();
-                field.focus();
-
+                return alertField( field );
+            }
+            else if ( isZeroNumber( field.value ) && zeroValueSaveMode == false && significantZeros.indexOf( dataElementId ) == -1 )
+            {
+                // If value is 0, and zeroValueSaveMode is false, and zero is not significant for data element, then skip value
+                
+                field.style.backgroundColor = '#ccffcc';
                 return;
-            } 
+            }
             else
             {
                 var minString = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].min' ).innerHTML;
@@ -133,6 +122,17 @@
     commentSaver.save();
 }
 
+/**
+ * Supportive method.
+ */
+function alertField( field )
+{
+	field.style.backgroundColor = '#ffcc00';
+    field.select();
+    field.focus();
+    return false;
+}
+
 // -----------------------------------------------------------------------------
 // Saver objects
 // -----------------------------------------------------------------------------
@@ -190,11 +190,11 @@
         {
             element = document.getElementById( 'value[' + dataElementId + '].boolean' );
         }
-        else if( type == 'date' )
+        else if ( type == 'date' )
         {
         	element = document.getElementById( 'value[' + dataElementId + '].date' );
         }
-        else if( selectedOption )
+        else if ( selectedOption )
         {
         	element = selectedOption;    
         }

=== 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	2010-11-24 10:34:01 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2010-11-24 20:34:35 +0000
@@ -1,4 +1,6 @@
 
+var significantZeros = []; // Identifiers for which zero values are insignificant, also used in entry.js
+
 function addEventListeners() 
 {
 	var inputs = document.getElementsByName( "entryfield" ) 
@@ -118,6 +120,8 @@
 	    addOptionToList( list, '-1', '[ Select ]' );
 		
 	    $.getJSON( url, function( json ) {
+	    	significantZeros = json.significantZeros;
+	    	
 	    	for ( i in json.periods ) {
 	    		addOptionToList( list, i, json.periods[i].name );
 	    	}

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm	2010-11-18 12:28:04 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm	2010-11-24 20:34:35 +0000
@@ -1,4 +1,4 @@
-#set( $size = $periods.size() )
+#set( $size1 = $periods.size() )
 { "periods": [
 #foreach( $period in $periods )
   {
@@ -7,7 +7,12 @@
     "endDate": "$!format.formatDate( ${period.endDate} )",
     "name": "$!format.formatPeriod( ${period} )",
     "externalId": "$!{period.externalId}"
-  }#if( $velocityCount < $size ),#end    
+  }#if( $velocityCount < $size1 ),#end
+#end ],
+#set( $size2 = $significantZeros.size() )
+  "significantZeros": [
+#foreach( $dataElement in $significantZeros )
+  ${dataElement.id}#if( $velocityCount < $size2 ),#end
 #end ],
   "periodValid": ${periodValid}
 }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2010-11-21 16:38:52 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2010-11-24 20:34:35 +0000
@@ -73,9 +73,16 @@
         #set( $dataValue = false )
         #set( $dataValue = $dataValueMap.get( "$dataElement.id:$optionCombo.id" ) )
         #set( $dataEntryId = "value[$dataElement.id].value:value[$optionCombo.id].value" )
+        #set( $greyedField = false )
+        #set( $greyedField = $greyedFields.get( "$dataElement.id:$optionCombo.id" ) )        
+        #set( $minMaxError = false )
+        #if( $dataElement.type == "int" && $dataValue && $minMax )
+          #if( $integer.parseInt( $dataValue.value ) < $minMax.min || $integer.parseInt( $dataValue.value ) > $minMax.max )
+          #set( $minMaxError = true )
+          #end
+        #end
+        <span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span><span id="value[option$optionCombo.id].name"  class="hidden">$optionCombo.name</span><span id="value[$dataElement.id].name" class="hidden">$encoder.htmlEncode( $dataElement.shortName )</span><div id="value[$dataElement.id:$optionCombo.id].min" class="hidden">$!minMax.min</div><div id="value[$dataElement.id:$optionCombo.id].max" class="hidden">$!minMax.max</div>
         <td>
-        #set( $greyedField = false )
-        #set( $greyedField = $greyedFields.get( "$dataElement.id:$optionCombo.id" ) )
         #if( $dataElement.type == "bool" )
         <span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span>
         <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue" )) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )"  #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end #if( $greyedField )class="gray" disabled="disabled"#end>
@@ -83,8 +90,7 @@
           <option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
           <option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>
         </select>
-        #else
-        #if( $dataElement.type == "string" )
+        #elseif( $dataElement.type == "string" )
         #set( $coun = 0 )
           #foreach($customValue in $customValues)
           #if($dataElement.id == $customValue.dataElement.id && $optionCombo.id == $customValue.optionCombo.id)
@@ -103,16 +109,7 @@
 	      #else
           <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100%; #if( $minMaxError )background-color:#ffcccc;#end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end #if( $greyedField )class="gray" disabled="disabled"#end>
           #end
-        #end
-        #end
-        #set( $minMaxError = false )
-        #if( $dataElement.type == "int" && $dataValue && $minMax )
-          #if( $integer.parseInt( $dataValue.value ) < $minMax.min || $integer.parseInt( $dataValue.value ) > $minMax.max )
-          #set( $minMaxError = true )
-          #end
-        #end
-        <span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span><span id="value[option$optionCombo.id].name"  class="hidden">$optionCombo.name</span><span id="value[$dataElement.id].name" class="hidden">$encoder.htmlEncode( $dataElement.shortName )</span><div id="value[$dataElement.id:$optionCombo.id].min" class="hidden">$!minMax.min</div><div id="value[$dataElement.id:$optionCombo.id].max" class="hidden">$!minMax.max</div>
-        #if( $dataElement.type != "string")
+        #else
         <input name="entryfield" id="$dataEntryId" type="text" value="$!encoder.htmlEncode( $dataValue.value )" #if( $auth.hasAccess( "dhis-web-dataentry", "saveMultiDimensionalValue") ) onchange="saveValue( $dataElement.id, $optionCombo.id, '$encoder.jsEncode( $dataElement.name )', $zeroValueSaveMode )" ondblclick="viewHistory( $dataElement.id, $optionCombo.id, true  )" #else disabled="disabled" #end onkeypress="return keyPress(event, this)" style="width:100%; text-align:center; #if( $minMaxError )background-color:#ffcccc;#end" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end #if( $greyedField )class="gray" disabled="disabled" #end>
         #end
       </td>