dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14659
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5057: Data entry, indicator fields are empty instead of displaying 0 when one of the data elements in t...
------------------------------------------------------------
revno: 5057
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-10-27 20:28:20 +0200
message:
Data entry, indicator fields are empty instead of displaying 0 when one of the data elements in the formula is not present in the form
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 2011-08-31 19:14:56 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-10-27 18:28:20 +0000
@@ -32,11 +32,14 @@
var expression = generateExpression( formula );
- var value = eval( expression );
-
- value = isNaN( value ) ? '-' : Math.round( value );
-
- $( this ).attr( 'value', value );
+ if ( expression )
+ {
+ var value = eval( expression );
+
+ value = isNaN( value ) ? '-' : Math.round( value );
+
+ $( this ).attr( 'value', value );
+ }
} );
}
@@ -61,9 +64,16 @@
var fieldId = '#' + dataElementId + '-' + categoryOptionComboId + '-val';
- var value = $( fieldId ) && $( fieldId ).val() ? $( fieldId ).val() : '0';
+ if ( $( fieldId ).length )
+ {
+ var value = $( fieldId ).val() ? $( fieldId ).val() : '0';
- expression = expression.replace( match, value );
+ expression = expression.replace( match, value );
+ }
+ else // Return null if data element / category option combo not in form
+ {
+ return null;
+ }
// TODO signed numbers
}