← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4376: Loading data set report with ajax, which implies a progress indicator and the selected params to ...

 

------------------------------------------------------------
revno: 4376
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-08-19 14:08:26 +0200
message:
  Loading data set report with ajax, which implies a progress indicator and the selected params to remain.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/version/hibernate/Version.hbm.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  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/dataSetReport.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.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-services/dhis-service-core/src/main/resources/org/hisp/dhis/version/hibernate/Version.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/version/hibernate/Version.hbm.xml	2011-08-19 10:30:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/version/hibernate/Version.hbm.xml	2011-08-19 12:08:26 +0000
@@ -4,7 +4,7 @@
   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";>
 
 <hibernate-mapping>
-  <class name="org.hisp.dhis.version.Version" table="Version">
+  <class name="org.hisp.dhis.version.Version" table="version">
 
     <cache usage="read-write" />
 
@@ -12,7 +12,7 @@
       <generator class="native" />
     </id>
 
-    <property name="key" column="versionkey" not-null="true" length="230"/>
+    <property name="key" column="versionkey" length="230"/>
 
     <property name="value" column="versionvalue"/>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java	2011-05-31 11:18:52 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java	2011-08-19 12:08:26 +0000
@@ -27,10 +27,13 @@
 
 package org.hisp.dhis.reporting.dataset.action;
 
+import static org.hisp.dhis.dataset.DataSet.TYPE_CUSTOM;
+import static org.hisp.dhis.dataset.DataSet.TYPE_SECTION;
+import static org.hisp.dhis.util.SessionUtils.KEY_DATASET_REPORT_GRID;
+import static org.hisp.dhis.util.SessionUtils.getSessionVar;
+
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.dataset.DataSet;
@@ -45,10 +48,6 @@
 import org.hisp.dhis.util.SessionUtils;
 
 import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionContext;
-
-import static org.hisp.dhis.dataset.DataSet.*;
-import static org.hisp.dhis.util.SessionUtils.*;
 
 /**
  * @author Chau Thu Tran
@@ -57,14 +56,6 @@
 public class GenerateDataSetReportAction
     implements Action
 {
-    private static final String PARAM_PAGE = "page";
-    
-    private static final Map<String, String> VIEW_MAP = new HashMap<String, String>() { {
-        put( TYPE_CUSTOM, "/dhis-web-reporting/renderCustomDataSetReportForm.vm" );
-        put( TYPE_SECTION, "/dhis-web-reporting/renderSectionDataSetReportForm.vm" );
-        put( TYPE_DEFAULT, "/dhis-web-reporting/renderDefaultDataSetReportForm.vm" );
-    } };
-    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -234,9 +225,7 @@
             
             SessionUtils.setSessionVar( SessionUtils.KEY_DATASET_REPORT_GRID, grid );
         }
-                
-        ActionContext.getContext().getActionInvocation().getStack().setValue( PARAM_PAGE, VIEW_MAP.get( dataSetType ) );
         
-        return useLast ? type : SUCCESS;
+        return useLast ? type : dataSetType;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-08-19 08:01:56 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-08-19 12:08:26 +0000
@@ -463,11 +463,11 @@
     </action>
 
     <action name="generateDataSetReport" class="org.hisp.dhis.reporting.dataset.action.GenerateDataSetReportAction">
+	  <result name="default" type="velocity">/dhis-web-reporting/renderDefaultDataSetReportForm.vm</result>
+	  <result name="section" type="velocity">/dhis-web-reporting/renderSectionDataSetReportForm.vm</result>
+	  <result name="custom" type="velocity">/dhis-web-reporting/renderCustomDataSetReportForm.vm</result>
       <result name="xls" type="gridXlsResult" />
       <result name="pdf" type="gridPdfResult" />
-      <result name="success" type="velocity">/main.vm</result> <!-- Page param set in action -->
-      <param name="menu">/dhis-web-reporting/menu.vm</param>
-      <param name="javascripts">javascript/dataSetReport.js</param>
     </action>
 	
     <!-- Tally Sheet Forms Generator -->

=== 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-07-01 08:11:03 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm	2011-08-19 12:08:26 +0000
@@ -11,77 +11,82 @@
     var i18n_generating_report = '$encoder.jsEscape( $i18n.getString( "generating_report" ), "'")';    
 </script>
 
+<style type="text/css">
+div#control
+{
+  margin-bottom: 15px;
+}
+
+div#criteria
+{
+  position: relative;
+  left: 2px;
+  width: 372px;
+  height: 434px;
+  border: 1px solid #b0b0b0;
+  background-color: #d9ece1;
+  padding-top: 5px;
+  padding-bottom: 5px;
+  padding-left: 20px;
+  margin-bottom: 6px;
+  border-radius: 3px;
+  -moz-border-radius: 3px; /* Firefox */
+}
+
+div.inputSection
+{
+  padding-top: 7px;
+  padding-bottom: 5px;
+}
+</style>
 <h3>$i18n.getString( "dataset_report" )</h3>
 
-<form id="reportForm" name="reportForm" action="generateDataSetReport.action" method="post">	
-
-<table>
-	<tr>
-	  	<th>$i18n.getString( "dataset" )</th>
-	</tr>
-	<tr>
-		<td>
-			<select id="dataSetId" name="dataSetId" style="width:325px">
-			<option value="">[ $i18n.getString( "select" ) ]</option>
-				#foreach( $dataSet in $dataSets )
-				<option value="$dataSet.id">$encoder.htmlEncode( $dataSet.name )</option>
-				#end
-			</select>
-		</td>
-	</tr>
-    <tr>
-        <td style="height:10px"></td>
-    </tr>
-	<tr>
-		<th>$i18n.getString( "report_period" )</th>
-	</tr>
-	<tr>
-		<td>
-			<select id="periodType" name="periodType" style="min-width:222px" onchange="getPeriods( 'periodType', 'periodId', 'periodId', '0' )">
-				<option value="">[ $i18n.getString( "select_period_type" ) ]</option>
-				#foreach ( $type in $periodTypes )
-					<option value="$type.name">$i18n.getString( $type.name )</option>
-				#end
-			</select>
-
-			<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' )" /><br>
-
-	        <select id="periodId" name="periodId" style="width:325px" disabled="disabled">
-	        </select>
-		</td>
-    </tr>
-    <tr>
-        <td style="height:10px"></td>
-    </tr>    
-	<tr>
-		<th>$i18n.getString( "report_parameters" )</th>
-	</tr>
-  <tr>  	
-      <td><label>$i18n.getString( "use_data_for_selected_unit_only" )</label><input type="checkbox" id="selectedUnitOnly" name="selectedUnitOnly" value="true"></td>
-  </tr>
-  <tr>
-        <td style="height:10px"></td>
-  </tr>
-</table>
-  
-<table>	
-  <tr>	
-    <th>$i18n.getString( "report_organisation_unit" )</th>	
-  </tr>  
-  <tr>
-	<td>
-        <div id="selectionTree" style="width:350px;height:200px;overflow:auto;border:1px solid #cccccc"></div>		
-    </td>
-  </tr>  
-  <tr>  
-	<td>
-		<input type="button" value="$i18n.getString( "get_report" )" style="width:115px" onclick="validateDataSetReport()">
-	</td>
-	<td></td>		
-  </tr>  
-</table>
- 
-</form>
-
-<span id="message">$!message</span>
+<div id="control">
+<input type="button" value='$i18n.getString( "data" )' style="width:80px" onclick="showCriteria()" />
+</div>
+
+<div id="criteria">
+<div class="inputSection">
+<label>$i18n.getString( "dataset" )</label><br>
+<select id="dataSetId" name="dataSetId" style="width:325px">
+  <option value="">[ $i18n.getString( "select" ) ]</option>
+  #foreach( $dataSet in $dataSets )
+  <option value="$dataSet.id">$encoder.htmlEncode( $dataSet.name )</option>
+  #end
+</select>
+</div>
+
+<div class="inputSection">
+<label>$i18n.getString( "report_period" )</label><br>
+<select id="periodType" name="periodType" style="min-width:222px" onchange="getPeriods( 'periodType', 'periodId', 'periodId', '0' )">
+  <option value="">[ $i18n.getString( "select_period_type" ) ]</option>
+  #foreach ( $type in $periodTypes )
+  <option value="$type.name">$i18n.getString( $type.name )</option>
+  #end
+</select>
+<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' )" /><br>
+
+<select id="periodId" name="periodId" style="width:325px" disabled="disabled">
+</select>
+</div>
+
+<div class="inputSection">
+<label>$i18n.getString( "use_data_for_selected_unit_only" )</label>
+<input type="checkbox" id="selectedUnitOnly" name="selectedUnitOnly" value="true">
+</div>
+
+<div class="inputSection">
+<label>$i18n.getString( "report_organisation_unit" )</label><br>
+<div id="selectionTree" style="width:350px;height:200px;overflow:auto;border:1px solid #cccccc"></div>
+</div>
+
+<div class="inputSection">
+<input type="button" value='$i18n.getString( "get_report" )' style="width:115px" onclick="validateDataSetReport()">
+<input type="button" value='$i18n.getString( "cancel" )' style="width:80px" onclick="hideCriteria()">
+</div>
+</div>
+
+#parse( "dhis-web-commons/loader/loader.vm" )
+
+<div id="content"></div>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js	2011-06-23 14:38:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js	2011-08-19 12:08:26 +0000
@@ -23,27 +23,60 @@
 
 function validateDataSetReport()
 {
-    if ( !getListValue( "dataSetId" ) )
-    {
-        setMessage( i18n_select_data_set );
-        return false;
-    }
-    if ( !getListValue( "periodId" ) )
-    {
-        setMessage( i18n_select_period );
-        return false;
-    }
-    if ( selectedOrganisationUnitIds == null || selectedOrganisationUnitIds.length == 0 )
-    {
-        setMessage( i18n_select_organisation_unit );
-        return false;
-    }
-
-    document.getElementById( "reportForm" ).submit();
+    if ( !$( "#dataSetId" ).val() )
+    {
+        setHeaderMessage( i18n_select_data_set );
+        return false;
+    }
+    if ( !$( "#periodId" ).val() )
+    {
+        setHeaderMessage( i18n_select_period );
+        return false;
+    }
+    if ( !selectedOrganisationUnitIds || !selectedOrganisationUnitIds.length )
+    {
+        setHeaderMessage( i18n_select_organisation_unit );
+        return false;
+    }
+    
+    hideHeaderMessage();
+    hideCriteria();
+	$( "#content" ).hide();
+	hideContent();
+	showLoader();
+	
+    var dataSetId = $( "#dataSetId" ).val();
+    var periodId = $( "#periodId" ).val();
+    
+    $( '#content' ).load( 'generateDataSetReport.action', { dataSetId: dataSetId, periodId: periodId }, function() {
+    	hideLoader();
+    	showContent();
+    	pageInit();
+    } );
 }
 
 function exportDataSetReport( type )
 {
     var url = "generateDataSetReport.action?useLast=true&dataSetId=" + $( "#dataSetId" ).val() + "&type=" + type;
     window.location.href = url;
-}
\ No newline at end of file
+}
+
+function showCriteria()
+{
+	$( "#criteria" ).show( "fast" );
+}
+
+function hideCriteria()
+{
+	$( "#criteria" ).hide( "fast" );
+}
+
+function showContent()
+{
+	$( "#content" ).show( "fast" );
+}
+
+function hideContent()
+{
+	$( "#content" ).hide( "fast" );
+}

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm	2011-08-19 08:01:56 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm	2011-08-19 12:08:26 +0000
@@ -2,7 +2,6 @@
    jQuery(document).ready(function(){
 		
 		$( "#pivotTable" ).click( setPosition );
-		showCriteria();
 
 		selectionTreeSelection.setMultipleSelectionAllowed( false );
 		selectionTreeSelection.setListenerFunction( organisationUnitSelected );
@@ -30,6 +29,11 @@
   padding-right: 10px;
 }
 
+div#control
+{
+  margin-bottom: 15px;
+}
+
 div#criteria
 {
   position: relative;
@@ -91,16 +95,19 @@
 
 </style>
 
+<h3>$i18n.getString( "pivot_table" )</h3>
+
 <!-- Control panel -->
 
+<div id="control">
 <input type="button" value='$i18n.getString( "data" )' style="width:80px" onclick="showCriteria()" />
 <input type="button" value='$i18n.getString( "pivot" )' style="width:80px" onclick="showPivot()" />&nbsp;
 <label id="dataLabel" style="color:#606060"></label>
-<hr style="height:1px; color:#d9ece1">
+</div>
 
 <!-- Criteria -->
 
-<div id="criteria" style="display:none">
+<div id="criteria">
 
 <div class="inputSection">
 <label>$i18n.getString( "data_type" )</label>