← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2469: Moved export to pdf, xls, csv buttons of report table to html view

 

------------------------------------------------------------
revno: 2469
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-01-06 13:40:57 +0100
message:
  Moved export to pdf,xls,csv buttons of report table to html view
added:
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.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/inputReportParamsForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js


--
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-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2011-01-06 09:53:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2011-01-06 12:40:57 +0000
@@ -31,7 +31,6 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java	2010-10-21 14:24:15 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/SessionUtils.java	2011-01-06 12:40:57 +0000
@@ -36,9 +36,9 @@
 public class SessionUtils
 {
     public static final String KEY_PREVIEW_TYPE = "previewType";
-    public static final String KEY_PREVIEW_STATUS = "previewStatus";
-    
+    public static final String KEY_PREVIEW_STATUS = "previewStatus";    
     public static final String KEY_CURRENT_YEAR = "currentYear";
+    public static final String KEY_REPORT_TABLE_GRID = "lastReportTableGrid";
     
     public static Object getSessionVar( String name )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java	2011-01-04 15:43:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/GetUserGroupListAction.java	2011-01-06 12:40:57 +0000
@@ -32,13 +32,10 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
 
-import com.opensymphony.xwork2.Action;
-
 public class GetUserGroupListAction
     extends ActionPagingSupport<UserGroup>
 {

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java	2011-01-06 12:40:57 +0000
@@ -30,6 +30,7 @@
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.reporttable.ReportTableService;
+import org.hisp.dhis.util.SessionUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -76,6 +77,13 @@
     {
         this.type = type;
     }
+    
+    private Boolean useLast = false;
+
+    public void setUseLast( boolean useLast )
+    {
+        this.useLast = useLast;
+    }
 
     // -------------------------------------------------------------------------
     // Output
@@ -96,7 +104,16 @@
     public String execute()
         throws Exception
     {
-        grid = reportTableService.getPrettyReportTableGrid( id, format );
+        if ( useLast )
+        {
+            grid = (Grid) SessionUtils.getSessionVar( SessionUtils.KEY_REPORT_TABLE_GRID );
+        }
+        else
+        {
+            grid = reportTableService.getPrettyReportTableGrid( id, format );            
+        }
+        
+        SessionUtils.setSessionVar( SessionUtils.KEY_REPORT_TABLE_GRID, grid );
         
         return type != null ? type : DEFAULT_TYPE;
     }    

=== 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	2010-12-26 23:25:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2011-01-06 12:40:57 +0000
@@ -246,14 +246,15 @@
       <result name="success" type="velocity">/dhis-web-commons/ajax/xmlDataElements.vm</result>
       <param name="onExceptionReturn">plainTextError</param>
     </action>
-    
+        
     <action name="exportTable" class="org.hisp.dhis.reporting.tablecreator.action.ExportTableAction">
       <result name="csv" type="gridCsvResult"/>
       <result name="xls" type="gridXlsResult"/>
       <result name="pdf" type="gridPdfResult"/>
       <result name="html" type="velocity">/main.vm</result>
-      <param name="page">/dhis-web-commons/ajax/htmlGrid.vm</param>
-      <param name="menu">/dhis-web-reporting/menu.vm</param>      
+      <param name="page">/dhis-web-reporting/reportTableGrid.vm</param>
+      <param name="menu">/dhis-web-reporting/menu.vm</param>   
+      <param name="javascripts">javascript/generateReport.js</param>   
     </action>
     
     <!-- PivotTable -->

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2010-12-26 23:25:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2011-01-06 12:40:57 +0000
@@ -53,15 +53,17 @@
 	<tr>
         <th>$i18n.getString( "organisation_unit" )</th>
     </tr>
-    <td>
-		<div id="selectionTree" style="width:325px; height:200px"></div>	            
-		<script type="text/javascript">
-			selectionTreeSelection.setMultipleSelectionAllowed( false );
-			selectionTreeSelection.setListenerFunction( paramOrganisationUnitSet );
-			selectionTree.clearSelectedOrganisationUnits();
-		    selectionTree.buildSelectionTree();
-		</script>
-    </td>
+    <tr>
+	    <td>
+			<div id="selectionTree" style="width:325px; height:200px"></div>	            
+			<script type="text/javascript">
+				selectionTreeSelection.setMultipleSelectionAllowed( false );
+				selectionTreeSelection.setListenerFunction( paramOrganisationUnitSet );
+				selectionTree.clearSelectedOrganisationUnits();
+			    selectionTree.buildSelectionTree();
+			</script>
+	    </td>
+	</tr>
     <tr>
         <td colspan="4" style="height:10px"></td>
     </tr>
@@ -69,20 +71,15 @@
     #end
     
     <!-- Submit -->    
-    
-    <tr>        
+        
+    <tr>
         <td>
-        #if ( $mode == "table" )
-            <input type="button" value="$i18n.getString( 'get_report' )" onclick="generateReport( 'html' )" style="width:140px">
-            <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayManageTableForm.action'" style="width:140px"><br><br>
-            <input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="generateReport( 'pdf' )" style="width:140px">
-            <input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="generateReport( 'xls' )" style="width:140px"><br>            
-            <input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="generateReport( 'csv' )" style="width:140px">
-        #end
-        #if ( $mode == "report" )
-            <input type="button" value="$i18n.getString( 'get_report' )" onclick="generateReport( '' )" style="width:120px">
-            <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayViewReportForm.action'" style="width:120px">
-        #end
+            <input type="button" value="$i18n.getString( 'get_report' )" onclick="generateReport()" style="width:140px">
+        	#if ( $mode == "table" )
+            <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayManageTableForm.action'" style="width:140px">
+        	#elseif ( $mode == "report" )
+            <input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href=''" style="width:140px">
+        	#end
         </td>
     </tr>
     

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2010-12-26 15:38:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2011-01-06 12:40:57 +0000
@@ -2,8 +2,6 @@
 var MODE_REPORT = "report";
 var MODE_TABLE = "table";
 
-var outputFormat = null;
-
 // -----------------------------------------------------------------------------
 // Report params
 // -----------------------------------------------------------------------------
@@ -34,10 +32,8 @@
 // Report
 // -----------------------------------------------------------------------------
 
-function generateReport( format )
+function generateReport()
 {
-	outputFormat = format;
-	
 	if ( validationError() )
 	{
 		return false;
@@ -93,7 +89,7 @@
         }
         else if ( $( "#mode" ).val() == MODE_TABLE )
         {
-        	window.location.href = "exportTable.action?id=" + $( "#id" ).val() + "&type=" + outputFormat;
+        	window.location.href = "exportTable.action?id=" + $( "#id" ).val() + "&type=html";
         }
     }
     else if ( statusMessage == null )
@@ -114,3 +110,8 @@
 {
     setTimeout( "getReportStatus();", millis );
 }
+
+function exportReport( type )
+{
+	window.location.href = "exportTable.action?id=" + $( "#id" ).val() + "&type=" + type + "&useLast=true";
+}

=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm	2011-01-06 12:40:57 +0000
@@ -0,0 +1,9 @@
+
+<div>
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportReport( 'xls' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="exportReport( 'csv' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportReport( 'pdf' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayManageTableForm.action'" style="width:140px">
+</div>
+
+#parse( "dhis-web-commons/ajax/htmlGrid.vm" )
\ No newline at end of file