← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2719: Added pagination to operand list in validation rule editor

 

------------------------------------------------------------
revno: 2719
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-01-22 23:12:38 +0100
message:
  Added pagination to operand list in validation rule editor
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.ajax.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/expressionBuilderForm.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.ajax.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.ajax.js	2011-01-17 06:08:02 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.ajax.js	2011-01-22 22:12:38 +0000
@@ -194,14 +194,14 @@
 				jQuery.each( json.operands, function(i, item){					
 					target.append('<option value="[' + item.operandId + ']">' + item.operandName + '</option>');
 				});
-			if( params.usepaging ){
+			if( params.usePaging ){
 				var numberOfPages = json.paging.numberOfPages;
 				var currentPage = json.paging.currentPage;
 				var baseLink = json.paging.baseLink;
 				var pageSize = json.paging.pageSize;
-				var startPage = json.paging.startPage;			
+				var startPage = json.paging.startPage;
 				
-				var html = '<div id="abcd1234">';
+				var html = '<div id="operandPaging_div">';
 				if( numberOfPages > 1 ){
 					html += 'Page: <select onchange="dataDictionary.reloadOperands( this.value )">';
 					for(var i=1;i<=numberOfPages;i++){
@@ -209,14 +209,12 @@
 					}
 					html += '</select>';
 				}
-				html += 'Size: <input type="text" style="width:50px" onchange="dataDictionary.changeOperandsPageSize( this.value )" value="' + pageSize + '"/></div>';					
-				jQuery( '#abcd1234' ).remove();;
-				jQuery( html ).insertAfter( target );				
+				html += 'Size: <input type="text" style="width:50px" onchange="dataDictionary.changeOperandsPageSize( this.value )" value="' + pageSize + '"/></div>';
+				jQuery( '#operandPaging_div' ).remove();
+				jQuery( html ).insertAfter( target );
 			}
-		});	
-		
-	}
-	
+		});		
+	}	
 }
 
 var dataDictionary = new DataDictionary();
@@ -250,5 +248,3 @@
 	this.id = id_;
 	this.name = name_;	
 }
-
-

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm	2011-01-22 20:56:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicatorExpressionBuilderForm.vm	2011-01-22 22:12:38 +0000
@@ -76,11 +76,11 @@
 	jQuery(function(){
 		dialog = jQuery("#indicator-expression-container").dialog({
 			modal: true,
-			autoOpen:false,
+			autoOpen: false,
 			minWidth: 820,
 			minHeight: 500,
-			width:820,
-			height:500
+			width: 820,
+			height: 500
 		});
 		
 		getOperandsPage();
@@ -101,6 +101,7 @@
 		
 		checkAggregationOperator();
 		getExpressionText();
+		
 		dialog.dialog("option", "title", "$i18n.getString( 'edit_numerator' )");
 		dialog.dialog("open");		
 	}
@@ -129,11 +130,9 @@
 	{
 		var aggregationOperator = getRadioValue( 'aggregationOperator' );
 		
-		var id = getFieldValue( "indicator-expression-container select[id=dataElementGroupId]");	
-
 		var key = getFieldValue( "indicator-expression-container input[id=filter]");
 
-		dataDictionary.loadOperands( "#indicator-expression-container select[id=dataElementId]", {id: id, aggregationOperator: aggregationOperator, usePaging: true, key: key } );	
+		dataDictionary.loadOperands( "#indicator-expression-container select[id=dataElementId]", {aggregationOperator: aggregationOperator, usePaging: true, key: key} );	
 
 		checkAggregationOperator();
 	}	
@@ -217,5 +216,3 @@
 		validator = validation( 'indicator-expression-form', insertExpression );
 	});	
 </script>
-
-

=== 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-01-22 20:56:30 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/expressionBuilderForm.vm	2011-01-22 22:12:38 +0000
@@ -23,7 +23,7 @@
 	</tr>
 	<tr>
 		<td valign="top">
-		<textarea id="expression" name="expression" style="width:250px; height:150px" wrap="virtual" onchange="cleanExpression()" class="{validate:{required:true}}"></textarea><br/>
+		<textarea id="expression" name="expression" style="width:250px; height:150px" wrap="virtual" onchange="getExpressionText()" class="{validate:{required:true}}"></textarea><br/>
 		<a href="javascript:insertText( 'expression', '(', 'aggregationOperator' )"><img src="../images/left_parent.png" alt="$i18n.getString( 'left_brackets' )"/></a>
 		<a href="javascript:insertText( 'expression', ')', 'aggregationOperator' )"><img src="../images/right_parent.png" alt="$i18n.getString( 'right_brackets' )"/></a>
 		<a href="javascript:insertText( 'expression', '*', 'aggregationOperator' )"><img src="../images/multiply.png" alt="$i18n.getString( 'multiply' )"/></a>
@@ -34,12 +34,11 @@
 		<td></td>
 		<td valign="top">
 			<label>$encoder.htmlEncode( $i18n.getString( "filter_by_name" ) )</label><br/>
-			<input type="text" id="filter" name="filter" style="width:450px" onkeyup="filterList( this.value, 'dataElementId' )"/><br/>
-
-			<select id="dataSetId" name="dataSetId" style="width:450px" onchange="loadDataElements(this.value)"/><br/>
-
-			<select id="dataElementId" name="dataElementId" size="7" style="min-width:450px" ondblclick="insertText( 'expression', this.value, 'aggregationOperator' )"/>
-			
+			<input type="text" id="filter" name="filter" style="width:380px">
+			<input type="button" value="$i18n.getString( 'filter' )" onclick="getOperandsPage()" style="width:60px"><br/>
+
+			<select id="dataElementId" name="dataElementId" size="7" style="min-width:450px" ondblclick="insertText( 'expression', this.value )">
+			</select>
 		</td>
 	</tr>
 	<tr>
@@ -62,142 +61,117 @@
 </div>
 
 <script>
-
-var left = true;
-
-function loadDataElements( dataSetId )
-{
-	var dataElements = jQuery("#dataElementId");
-	dataDictionary.loadOperands( dataElements, {dataSetId: dataSetId});
-}
-
-function loadDataSets()
-{	
-	var dataSets = jQuery("#dataSetId");
-	dataSets.empty();
-	jQuery.postJSON("../dhis-web-commons-ajax-json/getDataSets.action",{
-		name: getFieldValue( "periodTypeName" )
-	}, function( json ){
-		dataSets.append( '<option value="">[ $i18n.getString( "view_all" ) ]</option>' );		
-		jQuery.each( json.dataSets, function(i, item){
-			dataSets.append( '<option value="' + item.id + '">' + item.name + '</option>' );
+	var left = true;
+	var dialog = null;
+	
+	jQuery(function(){
+		
+		dialog = jQuery( "#expression-container" ).dialog({
+			modal: true,
+			autoOpen:false,
+			minWidth: 820,
+			minHeight: 500,
+			width:820,
+			height:500,
+			title: "$i18n.getString( 'expression' )"
 		});
 		
-		loadDataElements( dataSets.val() );
+		getOperandsPage();
 	});
-}
-
-function getExpressionText()
-{
-	if( hasText('expression') ){
-		jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', {
-			expression: getFieldValue('expression')
-		}, function( json ){
-			if( json.response == 'success')
-			{
-				jQuery( "#formulaText").html( json.message );
-			}else{
-				jQuery( "#formulaText").html( '' );
-			}
-		});
-	}else{
-		jQuery( "#formulaText").html( '' );
-	}
-}
-
-function insertText( inputAreaName, inputText, radioGroupName )
-{
-	insertTextCommon( inputAreaName, inputText );
-	
-	getExpressionText();
-}
-
-function cleanExpression()
-{
-	checAggregationOperator();
-	
-	getExpressionText();
-}
-
-function insertExpression()
-{
-	var expression = getFieldValue( 'expression-container textarea[id=expression]' );
-	var description = getFieldValue( 'expression-container input[id=description]' );
-	
-	jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', 
-		{expression: expression},
-		function( json ){
-			if( json.response == 'error') markInvalid( 'expression-container textarea[id=expression]' , json.message );
-			else {								
-				if( left ){								
-					setFieldValue( 'leftSideExpression', expression );
-					setFieldValue( 'leftSideDescription', description );
-					setFieldValue( 'leftSideTextualExpression', getInnerHTML('formulaText') );			
+	
+	function editLeftExpression()
+	{
+		left = true;
+		
+		var leftSideDescription = getFieldValue( 'leftSideDescription' );
+		var leftSideExpression = getFieldValue( 'leftSideExpression' );
+		var leftSideTextualExpression = getFieldValue( 'leftSideTextualExpression' );
+		
+		setFieldValue( 'expression', leftSideExpression );
+		setFieldValue( 'description', leftSideDescription );
+		setInnerHTML( 'formulaText', leftSideTextualExpression );
+		
+		dialog.dialog("open");
+	}
+	
+	function editRightExpression()
+	{
+		left = false;
+		
+		var rightSideDescription = getFieldValue( 'rightSideDescription' );
+		var rightSideExpression = getFieldValue( 'rightSideExpression' );
+		var rightSideTextualExpression = getFieldValue( 'rightSideTextualExpression' );
+		
+		setFieldValue( 'expression', rightSideExpression );
+		setFieldValue( 'description', rightSideDescription );
+		setInnerHTML( 'formulaText', rightSideTextualExpression );
+		
+		dialog.dialog("open");
+	}
+	
+	function getOperandsPage()
+	{
+		var key = getFieldValue( "expression-container input[id=filter]");
+	
+		dataDictionary.loadOperands( "#expression-container select[id=dataElementId]", {usePaging: true, key: key} );	
+	}
+	
+	function getExpressionText()
+	{
+		if( hasText('expression') ){
+			jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', {
+				expression: getFieldValue('expression')
+			}, function( json ){
+				if( json.response == 'success')
+				{
+					jQuery( "#formulaText").html( json.message );
 				}else{
-					setFieldValue( 'rightSideExpression', expression );
-					setFieldValue( 'rightSideDescription', description );
-					setFieldValue( 'rightSideTextualExpression', getInnerHTML('formulaText') );									
-				}
-				
-				dialog.dialog( "close" );
-			}
-		});
-}
-	
-jQuery( function(){
-	validation( 'expression-form', insertExpression );
-});
-	
-</script>
-
-<script>
-var dialog = null; 
-jQuery(function(){
-	
-	dialog = jQuery( "#expression-container" ).dialog({
-		modal: true,
-		autoOpen:false,
-		width:800,
-		title:'$encoder.jsEscape( $i18n.getString( "expression" ) , "'")'
+					jQuery( "#formulaText").html( '' );
+				}
+			});
+		}else{
+			jQuery( "#formulaText").html( '' );
+		}
+	}
+	
+	function insertText( inputAreaName, inputText )
+	{
+		insertTextCommon( inputAreaName, inputText );
+		
+		getExpressionText();
+	}
+	
+	function insertExpression()
+	{
+		var expression = getFieldValue( 'expression-container textarea[id=expression]' );
+		var description = getFieldValue( 'expression-container input[id=description]' );
+		
+		jQuery.postJSON( '../dhis-web-commons-ajax-json/getExpressionText.action', 
+			{expression: expression},
+			function( json ){
+				if( json.response == 'error') markInvalid( 'expression-container textarea[id=expression]' , json.message );
+				else {								
+					if( left ){								
+						setFieldValue( 'leftSideExpression', expression );
+						setFieldValue( 'leftSideDescription', description );
+						setFieldValue( 'leftSideTextualExpression', getInnerHTML('formulaText') );			
+					}else{
+						setFieldValue( 'rightSideExpression', expression );
+						setFieldValue( 'rightSideDescription', description );
+						setFieldValue( 'rightSideTextualExpression', getInnerHTML('formulaText') );									
+					}
+					
+					dialog.dialog( "close" );
+				}
+			});
+	}
+		
+	jQuery( function()
+	{
+		validation( 'expression-form', insertExpression );
 	});
 	
-});
-
-var i18n_description_not_null = '$encoder.jsEscape( $i18n.getString( "description_not_null" ) , "'")';
-var i18n_expression_not_null = '$encoder.jsEscape( $i18n.getString( "expression_not_null" ) , "'")';
-
-function editLeftExpression()
-{
-	left = true;
-	
-	loadDataSets();
-	
-	var leftSideDescription = getFieldValue( 'leftSideDescription' );
-	var leftSideExpression = getFieldValue( 'leftSideExpression' );
-	var leftSideTextualExpression = getFieldValue( 'leftSideTextualExpression' );
-	
-	setFieldValue( 'expression', leftSideExpression );
-	setFieldValue( 'description', leftSideDescription );
-	setInnerHTML( 'formulaText', leftSideTextualExpression );
-	
-	dialog.dialog("open");
-}
-
-function editRightExpression()
-{
-	left = false;
-	
-	loadDataSets();
-	
-	var rightSideDescription = getFieldValue( 'rightSideDescription' );
-	var rightSideExpression = getFieldValue( 'rightSideExpression' );
-	var rightSideTextualExpression = getFieldValue( 'rightSideTextualExpression' );
-	
-	setFieldValue( 'expression', rightSideExpression );
-	setFieldValue( 'description', rightSideDescription );
-	setInnerHTML( 'formulaText', rightSideTextualExpression );
-	
-	dialog.dialog("open");
-}
-
+	var i18n_description_not_null = '$encoder.jsEscape( $i18n.getString( "description_not_null" ) , "'")';
+	var i18n_expression_not_null = '$encoder.jsEscape( $i18n.getString( "expression_not_null" ) , "'")';
+	
 </script>