← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2160: Fix bug: Validation of Expression is not correct.

 

------------------------------------------------------------
revno: 2160
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Sat 2010-09-18 17:34:29 +0700
message:
  Fix bug: Validation of Expression is not correct.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.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-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2010-09-01 09:34:51 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2010-09-18 10:34:29 +0000
@@ -305,7 +305,7 @@
             // that the formula is mathematically valid
             // -----------------------------------------------------------------
 
-            matcher.appendReplacement( buffer, "1" );
+            matcher.appendReplacement( buffer, "1.0" );
         }
         
         matcher.appendTail( buffer );

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js	2010-09-18 09:50:09 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/expression.js	2010-09-18 10:34:29 +0000
@@ -82,18 +82,10 @@
 	jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', 
 			{expression: expression},
 			function( json ){
-				if( json.response == 'error') markInvalid( 'indicator-expression-container textarea[id=expression]' , json.message );
-				else {								
-					byId( "textualExpression" ).innerHTML = json.message;					
-				}
+				byId( "textualExpression" ).innerHTML = json.message;
 			});		
 }
 
-function updateTextualExpressionReceived( messageElement )
-{
-	document.getElementById( "textualExpression" ).innerHTML = messageElement;
-}
-
 function checkNotEmpty( field, message ){
 		
 	if( field.value.length == 0 ){
@@ -121,19 +113,14 @@
 	jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', 
 			{expression: expression},
 			function( json ){
-				if( json.response == 'error') {
-					markInvalid( 'indicator-expression-container textarea[id=expression]' , json.message );
-					return false;
-				}
-				else {								
-					var description = byId( "expDescription" ).value;
-					var expression = byId( "expression" ).value;
-					var textualDescription = byId( "textualExpression" ).innerHTML;
-					var side = byId( "side" ).value;
-					saveExpression( side, description, expression, textualDescription);
-					disable('periodTypeName');
-					return true;					
-				}
+				byId( "textualExpression" ).innerHTML = json.message;
+				var description = byId( "expDescription" ).value;
+				var expression = byId( "expression" ).value;
+				var textualDescription = byId( "textualExpression" ).innerHTML;
+				var side = byId( "side" ).value;
+				saveExpression( side, description, expression, textualDescription);
+				disable('periodTypeName');
+				return true;					
 			});		
 }