← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3580: Made calculations in custom forms more robust

 

------------------------------------------------------------
revno: 3580
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-05-11 19:01:54 +0200
message:
  Made calculations in custom forms more robust
modified:
  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/responsePeriods.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-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	2011-05-10 08:58:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2011-05-11 17:01:54 +0000
@@ -27,10 +27,9 @@
 		
 		var value = eval( expression );
 		
-		if ( value )
-		{
-			$( this ).attr( 'value', value );
-		}
+		value = isNaN( value ) ? '-' : Math.round( value );
+		
+		$( this ).attr( 'value', value );
 	} );
 }
 

=== 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	2011-05-10 08:58:10 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responsePeriods.vm	2011-05-11 17:01:54 +0000
@@ -17,7 +17,7 @@
 #set( $size3 = $indicators.size() )
   "indicatorFormulas": {
 #foreach( $indicator in $indicators )
-  "${indicator.id}": "$!{indicator.explodedNumerator}/$!{indicator.explodedDenominator}"#if( $velocityCount < $size3 ),#end
+  "${indicator.id}": "($!{indicator.explodedNumerator})/($!{indicator.explodedDenominator})"#if( $velocityCount < $size3 ),#end
 #end },
   "periodValid": ${periodValid}
 }