← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8805: local vn - Fixed bug in generating the Org-unit listing report and minor fixed GUI.

 

------------------------------------------------------------
revno: 8805
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-11-01 09:12:05 +0700
message:
  local vn - Fixed bug in generating the Org-unit listing report and minor fixed GUI.
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm
  local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.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 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java	2012-10-29 10:31:16 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java	2012-11-01 02:12:05 +0000
@@ -59,6 +59,8 @@
 {
     private static final String PREFIX_FORMULA_SUM = "SUM(";
 
+    private static final int SHIFT_NUMBER_OF_ROWS = 5;
+
     private Map<Integer, List<OrganisationUnit>> childrenGroupMap = new HashMap<Integer, List<OrganisationUnit>>();
 
     // -------------------------------------------------------------------------
@@ -182,6 +184,9 @@
     {
         List<OrganisationUnit> organisationUnits = null;
 
+        boolean isFirst = true;
+        boolean isTitleSetup = isTitleSetup( exportReportItems );
+
         for ( ExportItem reportItem : exportReportItems )
         {
             int run = 0;
@@ -198,6 +203,13 @@
 
                 organisationUnits = childrenGroupMap.get( unitGroup.getId() );
 
+                // Shift the number of rows - From start-row To end-row
+
+                if ( isTitleSetup && isFirst )
+                {
+                    sheet.shiftRows( rowBegin, rowBegin + SHIFT_NUMBER_OF_ROWS, organisationUnits.size() + 1 );
+                }
+
                 if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) )
                 {
                     ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT,
@@ -211,7 +223,7 @@
                 else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) )
                 {
                     ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils.generateExcelFormula(
-                        reportItem.getExpression(), run, run ), sheet, this.csFormula, evaluatorFormula );
+                        reportItem.getExpression(), run + 1, run + 1 ), sheet, this.csFormula, evaluatorFormula );
                 }
 
                 run++;
@@ -305,6 +317,8 @@
                 ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula,
                     evaluatorFormula );
             }
+
+            isFirst = false;
         }
 
         organisationUnits = null;
@@ -315,6 +329,9 @@
     {
         List<OrganisationUnit> organisationUnits = null;
 
+        boolean isFirst = true;
+        boolean isTitleSetup = isTitleSetup( exportReportItems );
+
         for ( ExportItem reportItem : exportReportItems )
         {
             int chapperNo = 0;
@@ -327,6 +344,13 @@
             {
                 organisationUnits = childrenGroupMap.get( unitGroup.getId() );
 
+                // Shift the number of rows - From start-row To end-row
+
+                if ( isTitleSetup && isFirst )
+                {
+                    sheet.shiftRows( rowBegin, rowBegin + SHIFT_NUMBER_OF_ROWS, organisationUnits.size() + 1 );
+                }
+
                 if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) )
                 {
                     ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), unitGroup.getName(), ExcelUtils.TEXT,
@@ -374,9 +398,24 @@
                 ExcelUtils.writeValueByPOI( firstRow, reportItem.getColumn(), totalValue + "", ExcelUtils.NUMBER,
                     sheet, this.csNumber );
             }
+
+            isFirst = false;
         }
 
         organisationUnits = null;
     }
 
+    private boolean isTitleSetup( Collection<ExportItem> exportReportItems )
+    {
+        for ( ExportItem item : exportReportItems )
+        {
+            if ( item.getItemType().equalsIgnoreCase( ExportItem.TYPE.ORGANISATION ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
 }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js	2012-04-28 16:58:08 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js	2012-11-01 02:12:05 +0000
@@ -75,7 +75,11 @@
 		disable( 'expression-button' );
 		setFieldValue( 'exportItem input[id=expression]', value );
 		removeValidatorRulesById( 'exportItem input[id=expression]' );
-		removeValidatorRulesById( 'dataelement textarea[id=formula]' );
+
+		if ( !attribute && !categoryVertical )
+		{
+			removeValidatorRulesById( 'dataelement textarea[id=formula]' );
+		}
 	}
 }
 
@@ -98,15 +102,15 @@
 		setFieldValue( 'attributevalue [id=formula]', getFieldValue( 'attributevalue [id=formula]' ) + expression );
 	}
 	else if ( category ) {
-		expression = "[*." + getFieldValue( "dataelement [id=elementSelect]" ) + "]";
+		expression = "[*." + getFieldValue( "dataelement-elementSelect" ) + "]";
 		setFieldValue( 'dataelement [id=formula]', getFieldValue( 'dataelement [id=formula]' ) + expression );
 	}
 	else if ( categoryVertical ) {
-		expression = "[" + getFieldValue( "categoryoption [id=elementSelect]" ) + ".*]";
+		expression = "[" + getFieldValue( "categoryoption-elementSelect" ) + ".*]";
 		setFieldValue( 'categoryoption [id=formula]', getFieldValue( 'categoryoption [id=formula]' ) + expression );
 	}
 	else {
-		expression = getFieldValue('dataelement [id=elementSelect]');
+		expression = getFieldValue( 'dataelement-elementSelect' );
 		setFieldValue( 'dataelement [id=formula]', getFieldValue( 'dataelement [id=formula]' ) + expression );
 	}
 

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-10-02 04:32:52 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js	2012-11-01 02:12:05 +0000
@@ -141,7 +141,7 @@
 					var _sData		= getElementValue( _cols[j], 'data' );
 					var _align		= getElementAttribute( _cols[j], 'format', 'align' );
 					var _border		= getElementAttribute( _cols[j], 'format', 'border' );
-					var _width		= getElementAttribute( _cols[j], 'format', 'width' );
+					//var _width		= getElementAttribute( _cols[j], 'format', 'width' );
 
 					// If this cell is merged - Key's form: Sheet#Row#Col
 					_sPattern 		=  _orderSheet + "#" + i + "#" + _number;
@@ -151,7 +151,8 @@
 					j 		= Number(j) + Number(_colspan);
 					_index 	= Number(_index) + Number(_colspan);
 
-					_sHTML.push( "<td align='", _align, "' width='", _width, "px' colspan='", _colspan, "'" );
+					//_sHTML.push( "<td align='", _align, "' width='", _width, "px' colspan='", _colspan, "'" );
+					_sHTML.push( "<td align='", _align, "' colspan='", _colspan, "'" );
 					_sHTML.push( " class='printclass" );
 					_sHTML.push( _border > 0 ? " ui-widget-content" : "" );
 

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm	2012-04-25 09:59:24 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm	2012-11-01 02:12:05 +0000
@@ -15,7 +15,7 @@
 	var avExpressionValidator = null;
 	var avExpressionDialog = null;
 	var i18n_no_attribute = '$encoder.jsEscape( $i18n.getString( "no_attribute" ) , "'")';;
-	var i18n_label = '$encoder.jsEscape($i18n.getString( 'select_attribute' ) , "'")';
+	var i18n_label = '$encoder.jsEscape($i18n.getString( "select_attribute" ) , "'")';
 </script>
 
 <div id="attributevalue" style="display:none">

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm	2012-04-28 16:58:08 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/categoryVerticalExpressionBuilderForm.vm	2012-11-01 02:12:05 +0000
@@ -8,8 +8,9 @@
 		coExpressionDialog = setUpDialog( 'categoryoption', i18n_expression, 800, 430 );
 		
 		//remoteValidate( jQuery( "#categoryoption textarea[id=formula]" ), 'checkAttributeValueValid.action' );
-		
+
 		changeItemType();
+		jQuery( '#elementSelect_loader' ).hide();
 	});
 
 	var coExpressionValidator = null;
@@ -30,12 +31,14 @@
 				<textarea id="formula" name="expression" cols="40" rows="5" class="{validate:{required:true}}"></textarea><br/>
 			</td>
 			<td>
-				<select id="groupSelect" style="width:500px" onchange="dataDictionary.loadDataElementsByGroup( this.value, '#categoryoption select[id=elementSelect]' )"></select>												
-				<select id="elementSelect" size="15" style="width:500px;" ondblclick="insertExpression()"></select>	
+				<select id="groupSelect" style="width:500px" onchange="dataDictionary.loadDataElementsByGroup( this.value, '#categoryoption-elementSelect' )"></select>
+				<input type="text" style="width:500px" placeholder="$i18n.getString( 'filter' )" onkeyup="filterList( this.value, 'categoryoption-elementSelect');" />
+				<select id="categoryoption-elementSelect" size="15" style="width:500px;" ondblclick="insertExpression()"></select>
+				<img src="../images/ajax-loader-bar.gif" id="elementSelect_loader" />
 			</td>			
 		</tr>
 		<tr>
-			<th colspan="2">$i18n.getString( "description" )</th>
+			<th>$i18n.getString( "description" )</th>
 		<tr>	
 		<tr>
 			<td colspan="2">
@@ -57,6 +60,7 @@
 	function coExpressionBuilderForm()
 	{
 		dataDictionary.loadDataElementGroups( "#categoryoption select[id=groupSelect]" );
+		dataDictionary.loadDataElementsByGroup( 'all', "#categoryoption-elementSelect" );
 
 		setFieldValue( 'categoryoption textarea[id=formula]', getFieldValue( 'expression' ) );
 		getExpression();

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm	2012-04-28 16:58:08 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm	2012-11-01 02:12:05 +0000
@@ -5,13 +5,14 @@
 			updateDeExpression();
 		});
 		
-		deExpressionDialog = setUpDialog( 'dataelement', i18n_expression, 800, 430 );
+		deExpressionDialog = setUpDialog( 'dataelement', i18n_expression, 820, 450 );
 		
 		#if( !$exportReport.isCategory() )
 		remoteValidate( jQuery( "#dataelement textarea[id=formula]" ), '../dhis-web-commons-ajax-json/getExpressionText.action' );
 		#end
 		
 		changeItemType();
+		jQuery( '#elementSelect_loader' ).hide();
 	});
 
 	var deExpressionValidator = null;
@@ -37,15 +38,17 @@
 				<a href="#" onclick="insertOperation( '-' )"><img src="images/minus.png" alt="$i18n.getString( 'minus' )"/></a>
 			</td>
 			<td>
-				#if(!$exportReport.isCategory()) 
-				<select id="groupSelect" style="width:500px" onchange="getDataElements(this.value, '#dataelement select[id=elementSelect]')"></select>												
+				#if( !$exportReport.isCategory() ) 
+				<select id="groupSelect" style="width:500px" onchange="getDataElements( this.value, '#dataelement-elementSelect' );"></select>
 				#end
-				<select id="elementSelect" size="15" style="width:500px;" ondblclick="insertExpression()"></select>	
-			</td>			
+				<input type="text" style="width:500px" placeholder="$i18n.getString( 'filter' )" onkeyup="filterList( this.value, 'dataelement-elementSelect');" />
+				<select id="dataelement-elementSelect" size="15" style="width:500px;" ondblclick="insertExpression()"></select>
+				<img src="../images/ajax-loader-bar.gif" id="elementSelect_loader" />
+			</td>		
 		</tr>
 		#if(!$exportReport.isCategory()) 
 		<tr>
-			<th colspan="2">$i18n.getString( "description" )</th>
+			<th>$i18n.getString( "description" )</th>
 		<tr>	
 		<tr>
 			<td colspan="2">
@@ -78,8 +81,9 @@
 		getDataElementCategoryOptionCombos();
 		#else
 		dataDictionary.loadDataElementGroups("#dataelement select[id=groupSelect]") ;
+		dataDictionary.loadOperands( '#dataelement-elementSelect', {id:getFieldValue( 'groupSelect' )} );
 		#end
-		
+
 		setFieldValue( 'dataelement textarea[id=formula]', getFieldValue('expression') );
 		getExpression();
 
@@ -106,7 +110,7 @@
 		, { id:$exportReport.id }
 		, function( json )
 		{
-			var select = jQuery("#dataelement select[id=elementSelect]");
+			var select = jQuery( "#dataelement-elementSelect" );
 			select.empty();
 			
 			if ( json.dataElementCategoryOptionCombos.length == 0 )

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm	2012-04-28 16:58:08 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/excelFormulaExpressionBuilderForm.vm	2012-11-01 02:12:05 +0000
@@ -1,7 +1,7 @@
 <script>
 
 	jQuery(document).ready(function(){
-		excelFormulaDialog = setUpDialog( 'excelformula', i18n_expression, 600, 350 );
+		excelFormulaDialog = setUpDialog( 'excelformula', i18n_expression, 630, 400 );
 	});
 	
 	var excelFormulaDialog = null;

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm	2012-04-28 16:58:08 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm	2012-11-01 02:12:05 +0000
@@ -1,7 +1,8 @@
 <script>
 
 	jQuery(document).ready(function(){
-		inExpressionDialog = setUpDialog( 'indicator', i18n_expression, 550, 350 );
+		inExpressionDialog = setUpDialog( 'indicator', i18n_expression, 600, 370 );
+		jQuery( '#elementSelect_loader' ).hide();
 	});
 	
 	var inExpressionDialog = null;
@@ -14,8 +15,10 @@
 		<tr>
 		<tr valign="top">			
 			<td>	
-				<select id="groupSelect" style="width:500px"onchange="getIndicators(this.value, '#indicator select[id=elementSelect]')"></select>								
-				<select id="elementSelect" size="15" style="width:500px;"></select>					
+				<select id="groupSelect" style="width:500px" onchange="getIndicators(this.value, '#indicator-elementSelect]')"></select>
+				<input type="text" placeholder="$i18n.getString( 'filter' )" style="width:500px" onkeyup="filterList( this.value, 'indicator-elementSelect' );"/>
+				<select id="indicator-elementSelect" size="15" style="width:500px;"></select>
+				<img src="../images/ajax-loader-bar.gif" id="elementSelect_loader" />
 			</td>			
 		</tr>	
 	</table>
@@ -31,13 +34,14 @@
 	
 	function inExpressionBuilderForm()
 	{
-		dataDictionary.loadIndicatorGroups( "#indicator select[id=groupSelect]");
+		dataDictionary.loadIndicatorGroups( "#indicator select[id=groupSelect]" );
+		dataDictionary.loadAllIndicators( "#indicator-elementSelect" );
 		openDialog( inExpressionDialog );
 	}
 	
 	function updateInExpression()
 	{
-		expression = jQuery( '#indicator select[id=elementSelect]' ).val();
+		expression = jQuery( '#indicator-elementSelect' ).val();
 		setFieldValue( 'expression', '[' + expression + ']');
 		closeDialog( inExpressionDialog );
 	}