← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3090: Using get report button in data completeness

 

------------------------------------------------------------
revno: 3090
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-03-19 23:30:32 +0100
message:
  Using get report button in data completeness
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/SearchOrganisationUnitsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.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-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/SearchOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/SearchOrganisationUnitsAction.java	2011-03-17 23:03:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/SearchOrganisationUnitsAction.java	2011-03-19 22:30:32 +0000
@@ -194,6 +194,12 @@
             selectedOrganisationUnit = selectionManager.getSelectedOrganisationUnit();
 
             log.debug( "Name: " + name + ", Orgunit: " + selectedOrganisationUnit + ", type: " + type );
+
+            // -----------------------------------------------------------------
+            // Set orgunit to null if root to avoid subquery and improve perf
+            // -----------------------------------------------------------------
+
+            selectedOrganisationUnit = selectedOrganisationUnit != null && selectedOrganisationUnit.getParent() == null ? null : selectedOrganisationUnit;
             
             Collection<OrganisationUnitGroup> groups = new HashSet<OrganisationUnitGroup>();
             

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-03-15 23:26:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-03-19 22:30:32 +0000
@@ -1,6 +1,7 @@
-please_select_an_orgUnit= Please select an OrganisationUnit.
-please_select_a_dataset= Please select a dataset.
-please_select_period= Please select a period.
+please_select_org_unit= Please select an organisation unit
+please_select_dataset= Please select a dataset
+please_select_period= Please select a period
+please_select_group_set = Please select a group set
 refresh_datamart= Refresh datamart
 error_in_input_parameters= Not all required parameters are selected!
 aggregation_mode= Aggregation mode
@@ -32,7 +33,6 @@
 selected_organisationunits= Selected organisation units
 available_periods= Available periods
 selected_periods= Selected periods
-select_period_type_all= Select period type / View all
 add_children= Add children
 create_and_save= Create and Save
 create= Create
@@ -292,8 +292,6 @@
 category_y_available_periods = Value (Y) - Available periods
 get_current_design = Get current design
 organisation_unit_report = Organisation Unit Report
-please_select_org_unit = Please select organisation unit
-please_select_group_set = Please select group set
 select_group_set = Select group set
 orgunit_distribution = Organisation unit distribution report
 get_report = Get report

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm	2011-03-18 14:45:12 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm	2011-03-19 22:30:32 +0000
@@ -34,7 +34,7 @@
 			<input type="button" style="width:50px" value="$i18n.getString( 'prev' )" onclick="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '-1' )"><input
 				   type="button" style="width:50px" value="$i18n.getString( 'next' )" onclick="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '1' )">
 			<select id="periodType" name="periodType" style="min-width:222px" onchange="getAvailablePeriods( 'periodType', 'periodId', 'periodId', '0' )">
-				<option value="">[ $i18n.getString( "select_period_type_all" ) ]</option>
+				<option value="">[ $i18n.getString( "select_period_type" ) ]</option>
 				#foreach ( $type in $periodTypes )
 					<option value="$type.name">$type.name</option>
 				#end

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js	2010-12-26 23:25:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js	2011-03-19 22:30:32 +0000
@@ -1,34 +1,56 @@
 
+var isOrganisationUnit = false;
+
+function organisationUnitSelected( units )
+{
+	isOrganisationUnit = units && units.length > 0;
+}
+
 function getPeriods( periodTypeList, availableList, selectedList, timespan )
 {
+	$( "#periodId" ).removeAttr( "disabled" );
+	
 	getAvailablePeriods( periodTypeList, availableList, selectedList, timespan );
 }
 
 function displayCompleteness()
 {
     var criteria = $( "input[name='criteria']:checked" ).val();
-    var dataSetList = byId( "dataSetId" ); //TODO simplify
-    var dataSetId = dataSetList.options[ dataSetList.selectedIndex ].value;    
-    var periodList = byId( "periodId" );
-    var periodId = null;
-    
-    if ( !periodList.disabled && (periodList.options.length > 0) )
-    {
-        periodId = periodList.options[ periodList.selectedIndex ].value;
-    }
-    
-    if ( periodId != null )
-    {
-        showLoader();
-        
-        var url = "getDataCompleteness.action" + "?periodId=" + periodId + "&criteria=" + criteria + 
-        	"&dataSetId=" + dataSetId + "&type=html";
-        
-        $( "#contentDiv" ).load( url, function() {
-        	hideLoader();
-        	pageInit();
-        } );
-    }
+    var dataSetId = $( "#dataSetId" ).val();
+    var periodList = byId( "periodId" );    
+    var periodId = periodList.options.length > 0 ? $( "#periodId" ).val() : null;
+    
+	if ( !completenessIsValid( periodId ) )
+	{
+		return false;
+	}
+	
+    showLoader();
+        
+    var url = "getDataCompleteness.action" + "?periodId=" + periodId + "&criteria=" + criteria + 
+    	"&dataSetId=" + dataSetId + "&type=html";
+        
+    $( "#contentDiv" ).load( url, function() {
+    	hideLoader();
+        pageInit();
+    } );
+}
+
+function completenessIsValid( periodId )
+{
+	if ( !isOrganisationUnit )
+	{
+		setHeaderDelayMessage( i18n_please_select_org_unit );
+		return false;
+	}
+	
+	if ( periodId == null )
+	{
+		setHeaderDelayMessage( i18n_please_select_period );
+		return false;
+	}
+	
+	return true;
 }
 
 function getCompleteness( type )

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm	2011-03-18 14:45:12 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm	2011-03-19 22:30:32 +0000
@@ -1,49 +1,38 @@
 <script type="text/javascript">
 	jQuery(document).ready(function() {
-		selectionTreeSelection.setListenerFunction( displayCompleteness );
+		selectionTreeSelection.setListenerFunction( organisationUnitSelected );
 		selectionTreeSelection.setMultipleSelectionAllowed( false );
 		selectionTree.clearSelectedOrganisationUnits();
 		selectionTree.buildSelectionTree();
 	});
 
-	var i18n_processing = '$encoder.jsEscape( $i18n.getString( "processing" ) , "'")';
-    var i18n_dataset = '$encoder.jsEscape( $i18n.getString( "dataset" ) , "'")';
-    var i18n_organisation_unit = '$encoder.jsEscape( $i18n.getString( "organisation_unit" ) , "'")';
-    var i18n_actual = '$encoder.jsEscape( $i18n.getString( "actual" ) , "'")';
-    var i18n_target = '$encoder.jsEscape( $i18n.getString( "target" ) , "'")';
-    var i18n_percent = '$encoder.jsEscape( $i18n.getString( "percent" ) , "'")';
-    var i18n_on_time = '$encoder.jsEscape( $i18n.getString( "on_time" ) , "'")';
+	var i18n_please_select_org_unit = '$encoder.jsEscape( $i18n.getString( "please_select_org_unit" ) , "'")';
+    var i18n_please_select_period = '$encoder.jsEscape( $i18n.getString( "please_select_period" ) , "'")';
 </script>
 
 <h3>$i18n.getString( "data_completeness_report" )</h3>
 
 <table>
-    <col width="330"/>
-    <col width="5"/>
-    <col width="330"/>
+    <col width="330">
+    <col>
     <tr>
     	<th>$i18n.getString( "select_org_unit" )</th>
     	<td></td>
-    	<td></td>
     </tr>
     <tr>
-	    <td><div id="selectionTree" style="width:325px; height:240px"></div></td>
-        <td></td>
+	    <td><div id="selectionTree" style="width:325px; height:270px"></div></td>
         <td valign="bottom">
-        	<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" style="width:140px" onclick="getCompleteness( 'pdf' )"/>
-            <input type="button" value="$i18n.getString( 'get_report_as_xls' )" style="width:140px" onclick="getCompleteness( 'xls' )"/><br>
-        	<input type="button" value="$i18n.getString( 'get_report_as_csv' )" style="width:140px" onclick="getCompleteness( 'csv' )"/><br><br>        	
                 	
-            <input type="radio" name="criteria" id="registrationRadio" value="registration" checked="checked" onclick="displayCompleteness()"/>
+            <input type="radio" name="criteria" id="registrationRadio" value="registration" checked="checked"/>
             <label for="registrationRadio">$i18n.getString( 'based_on_registration' )</label><br/>
-            <input type="radio" name="criteria" id="compulsoryRadio" value="compulsory" onclick="displayCompleteness()"/>
+            <input type="radio" name="criteria" id="compulsoryRadio" value="compulsory"/>
             <label for="compulsoryRadio">$i18n.getString( 'based_on_compulsory' )</label><br/>
-            <input type="radio" name="criteria" id="ratioRadio" value="ratio" onclick="displayCompleteness()"/>
+            <input type="radio" name="criteria" id="ratioRadio" value="ratio"/>
             <label for="ratioRadio">$i18n.getString( 'based_on_ratio' )</label><br/><br/>
             
             <!-- DataSet -->
             
-        	<select id="dataSetId" name="dataSetId" style="width:325px" onchange="displayCompleteness()">
+        	<select id="dataSetId" name="dataSetId" style="width:348px">
 			<option value="0">[ $i18n.getString( "select_dataset_all" ) ]</option>
 			#foreach( $dataSet in $dataSets )
 				<option value="$dataSet.id">$dataSet.name</option>
@@ -52,23 +41,32 @@
             
             <!-- PeriodType -->
             
-            <input type="button" style="width:50px" value="$i18n.getString( 'prev' )" onclick="getPeriods( 'periodType', 'periodId', 'periodId', '-1' )"/>
-			<input type="button" style="width:50px" value="$i18n.getString( 'next' )" onclick="getPeriods( 'periodType', 'periodId', 'periodId', '1' )"/>
-			<select id="periodType" name="periodType" style="min-width:222px" onchange="getPeriods( 'periodType', 'periodId', 'periodId', '0' )">
-				<option value="">[ $i18n.getString( "select_period_type_all" ) ]</option>
+            
+			<select id="periodTypeId" style="min-width:223px" onchange="getPeriods( 'periodType', 'periodId', 'periodId', '0' )">
+				<option value="0">[ $i18n.getString( "select_period_type" ) ]</option>
 				#foreach ( $type in $periodTypes )
 					<option value="$type.name">$type.name</option>
 				#end
-			</select><br><br>
+			</select>
+			<input type="button" style="width:60px" value="$i18n.getString( 'prev' )" onclick="getPeriods( 'periodType', 'periodId', 'periodId', '-1' )"/><input 
+			       type="button" style="width:60px" value="$i18n.getString( 'next' )" onclick="getPeriods( 'periodType', 'periodId', 'periodId', '1' )"/><br><br>
 			
 			<!-- Period -->
 			
-            <select id="periodId" name="periodId" style="width:325px" onchange="displayCompleteness()">
-            </select>
+            <select id="periodId" name="periodId" style="width:348px" disabled="disabled">
+            </select><br><br>
+            
+            <input type="button" value="$i18n.getString( 'get_report' )" style="width:140px" onclick="displayCompleteness()"/><br><br>
+            
+            <!-- Export -->
+            
+        	<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" style="width:140px" onclick="getCompleteness( 'pdf' )"/>
+            <input type="button" value="$i18n.getString( 'get_report_as_xls' )" style="width:140px" onclick="getCompleteness( 'xls' )"/><br>
+        	<input type="button" value="$i18n.getString( 'get_report_as_csv' )" style="width:140px" onclick="getCompleteness( 'csv' )"/>
         </td>
     </tr>
     <tr>
-    	<td colspan="3" height="20px"></td>
+    	<td colspan="2" height="20px"></td>
     </tr>
 </table>