=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/expressionBuilderForm.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/expressionBuilderForm.vm 2011-06-16 01:47:10 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/expressionBuilderForm.vm 2011-07-01 04:04:24 +0000 @@ -12,12 +12,13 @@ height:500, title: "$i18n.getString( 'expression' )" }); + + getConstantsPage(); + getOperandsPage(); }); function editLeftExpression() { - getOperandsPage(); - left = true; var leftSideDescription = getFieldValue( 'leftSideDescription' ); @@ -33,8 +34,6 @@ function editRightExpression() { - getOperandsPage(); - left = false; var rightSideDescription = getFieldValue( 'rightSideDescription' ); @@ -48,6 +47,25 @@ dialog.dialog("open"); } + function getConstantsPage() + { + var target = jQuery( "#expression-container select[id=constantId]" ); + target.children().remove(); + + jQuery.postJSON( '../dhis-web-maintenance-dataadmin/getConstants.action', {}, + function( json ) { + if ( json.constants.length == 0 ) + { + setInnerHTML( 'constantHeader', ""+i18n_no_constant_to_select+"" ); + return; + } + + jQuery.each( json.constants, function(i, item) { + target.append( '' ); + }); + }); + } + function getOperandsPage() { var key = getFieldValue( "expression-container input[id=filter]" ); @@ -69,10 +87,11 @@ jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', { expression: getFieldValue('expression') }, function( json ){ - if( json.response == 'success') + if( json.response == 'success' || json.response == 'error' ) { jQuery( "#formulaText").html( json.message ); - }else{ + } + else { jQuery( "#formulaText").html( '' ); } }); @@ -120,6 +139,7 @@ var i18n_description_not_null = '$encoder.jsEscape( $i18n.getString( "description_not_null" ) , "'")'; var i18n_expression_not_null = '$encoder.jsEscape( $i18n.getString( "expression_not_null" ) , "'")'; + var i18n_no_constant_to_select = '$encoder.jsEscape( $i18n.getString( "no_constant_to_select" ) , "'")';
@@ -131,12 +151,17 @@ - $i18n.getString( "description" ) + $i18n.getString( "description" ) + $i18n.getString( "constants" ) - + - + + + +