← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2386: Data Elements and Indicators - Managements - Improved the PDF exported functionality which is all...

 

------------------------------------------------------------
revno: 2386
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-10-19 17:12:54 +0700
message:
  Data Elements and Indicators - Managements - Improved the PDF exported functionality which is allow to export the list of data elements (indicators) after filtered
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/lists.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicator.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/i18n/translate.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm	2010-09-16 08:17:27 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm	2010-10-19 10:12:54 +0000
@@ -59,8 +59,8 @@
 	#end
 	<tr>
 		<td></td>
-		<td><input type="submit" value="$i18n.getString( "translation_save")" style="width:10em"/>
-		    <input type="button" value="$i18n.getString( "translation_cancel")" onclick="javascript:location.href='$returnUrl'" style="width:10em"/>
+		<td><input type="submit" value="$i18n.getString( 'translation_save' )" style="width:10em"/>
+		    <input type="button" value="$i18n.getString( 'translation_cancel' )" onclick="javascript:location.href='$returnUrl'" style="width:10em"/>
 	    </td>
 		<td></td>
 	</tr>
@@ -73,15 +73,15 @@
 	</tr>
 	<tr>
 		<td style="width:12em"><label for="language">$i18n.getString( "translation_languagecode" )</label></td>
-		<td><input type="text" id="language" name="language" size=2 style="width:20em"/></td>
+		<td><input type="text" id="language" name="language" size="2" style="width:20em"/></td>
 	</tr>
 	<tr>
 		<td><label for="country">$i18n.getString( "translation_countrycode" ) </label></td>
-		<td><input type="text" id="country" name="country" size=2 style="width:20em"/></td>
+		<td><input type="text" id="country" name="country" size="2" style="width:20em"/></td>
 	</tr>
 	<tr>
 		<td></td>
-		<td><input type="button" value="$i18n.getString( "translation_add")" onclick="addLocale()" style="width:10em"/></td>
+		<td><input type="button" value="$i18n.getString( 'translation_add' )" onclick="addLocale()" style="width:10em"/></td>
 		<td></td>
 	</tr>
 </table>
@@ -92,7 +92,7 @@
 
     var propNames = new Array()
     #set( $count = 0 )
-    #foreach ($propertyName in $propertyNames )
+    #foreach ( $propertyName in $propertyNames )
         propNames[$count] = "$propertyName";
         #set( $count = $count + 1 )
     #end

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2010-10-18 08:12:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2010-10-19 10:12:54 +0000
@@ -1276,3 +1276,13 @@
     var currentPage = jQuery("#jumpToPage").val();
     window.location.href = baseLink +"pageSize=" + pageSize +"&currentPage=" +currentPage;
 }
+
+/**
+ * Used to export PDF file by the given type and
+ * the active items in table
+ */
+function exportPdfByType( type )
+{
+	var activeIds = getArrayIdOfActiveRows();
+	window.location.href = 'exportToPdf.action?type=' + type + activeIds;
+}

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/lists.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/lists.js	2010-09-08 10:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/lists.js	2010-10-19 10:12:54 +0000
@@ -446,4 +446,20 @@
 	});
 	
 	return result;
+}
+
+/**
+ * Return the list of Id from the active rows in table name 'listTable'
+ */
+function getArrayIdOfActiveRows()
+{
+	var params = "";
+	var rows = jQuery( "table.listTable tbody tr" );
+    
+    for ( var i = 0; i < rows.length; i++ )
+    {
+        params += "&activeIds=" + rows[i].id.split("tr")[1];
+    }
+    
+    return params;
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/pdf/ExportToPdfAction.java	2010-10-19 10:12:54 +0000
@@ -28,6 +28,8 @@
  */
 
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -48,15 +50,15 @@
     implements Action
 {
     private static final Log log = LogFactory.getLog( ExportToPdfAction.class );
-    
+
     private static final String EXPORT_FORMAT_PDF = "PDF";
-    
+
     private static final String TYPE_DATAELEMENT = "dataelement";
     private static final String TYPE_INDICATOR = "indicator";
-    
+
     private static final String FILENAME_DATAELEMENT = "DataElements.zip";
     private static final String FILENAME_INDICATOR = "Indicators.zip";
-    
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -81,7 +83,7 @@
     {
         this.format = format;
     }
-    
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -92,7 +94,7 @@
     {
         return inputStream;
     }
-    
+
     private String fileName;
 
     public String getFileName()
@@ -110,14 +112,21 @@
     {
         this.dataDictionaryMode = dataDictionaryMode;
     }
-    
+
     private String type;
 
     public void setType( String type )
     {
         this.type = type;
     }
-    
+
+    private List<Integer> activeIds = new ArrayList<Integer>();
+
+    public void setActiveIds( List<Integer> activeIds )
+    {
+        this.activeIds = activeIds;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -128,34 +137,50 @@
         if ( type != null )
         {
             ExportParams params = new ExportParams();
-    
+
             if ( type.equals( TYPE_DATAELEMENT ) )
             {
-                params.setDataElements( null );
+                if ( (activeIds != null) && !activeIds.isEmpty() )
+                {
+                    params.setDataElements( activeIds );
+                }
+                else
+                {
+                    params.setDataElements( null );
+                }
                 
                 fileName = FILENAME_DATAELEMENT;
-                
+
                 log.info( "Exporting to PDF for object type: " + TYPE_DATAELEMENT );
-            }  
+            }
             else if ( type.equals( TYPE_INDICATOR ) )
             {
-                params.setIndicators( null );
-                
+                if ( (activeIds != null) && !activeIds.isEmpty() )
+                {
+                    params.setIndicators( activeIds );
+                }
+                else
+                {
+                    params.setIndicators( null );
+                }
+
                 fileName = FILENAME_INDICATOR;
-                
+
                 log.info( "Exporting to PDF for object type: " + TYPE_INDICATOR );
             }
-            
-            params.setExtendedMode( dataDictionaryMode != null && dataDictionaryMode.equals( DataDictionaryModeManager.DATADICTIONARY_MODE_EXTENDED ) );
-            params.setIncludeDataValues( false );        
+
+            params.setExtendedMode( dataDictionaryMode != null
+                && dataDictionaryMode.equals( DataDictionaryModeManager.DATADICTIONARY_MODE_EXTENDED ) );
+            params.setIncludeDataValues( false );
             params.setI18n( i18n );
             params.setFormat( format );
-            
+
             ExportService exportService = serviceProvider.provide( EXPORT_FORMAT_PDF );
-            
+
             inputStream = exportService.exportData( params );
         }
-            
+
         return SUCCESS;
     }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-09-23 15:16:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-10-19 10:12:54 +0000
@@ -35,7 +35,7 @@
 						</div>
 					</td>
 					<td style="text-align:right">
-						<input type="button" value="$i18n.getString( 'get_pdf' )" onclick="window.location.href='exportToPdf.action?type=dataelement'" style="width:80px"/>
+						<input type="button" value="$i18n.getString( 'get_pdf' )" onclick="exportPdfByType( 'dataelement' );" style="width:80px"/>
                         <input type="button" value="$i18n.getString( 'sort' )" onclick="window.location.href='showSortDataElementForm.action'" style="width:80px"/>
                         #if ( $dataDictionaryMode == "extended" )
 							<input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddExtendedDataElementForm.action'" style="width:80px">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicator.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicator.vm	2010-10-13 07:27:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/indicator.vm	2010-10-19 10:12:54 +0000
@@ -28,7 +28,7 @@
                         </div>
                     </td>					
 					<td colspan="4" style="text-align:right">
-                        <input type="button" value="$i18n.getString( 'get_pdf' )" onclick="window.location.href='exportToPdf.action?type=indicator'" style="width:80px"/>
+                        <input type="button" value="$i18n.getString( 'get_pdf' )" onclick="exportPdfByType( 'indicator' );" style="width:80px"/>
 						<input type="button" value="$i18n.getString( 'sort' )" onclick="window.location.href='showSortIndicatorForm.action'" style="width:80px"/>
 					    #if ( $dataDictionaryMode == "extended" )
 							<input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddExtendedIndicatorForm.action'" style="width:80px"/>