← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6638: (patient) Hide fixed attributes columns when exporting.

 

------------------------------------------------------------
revno: 6638
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-04-19 09:48:18 +0700
message:
  (patient) Hide fixed attributes columns when exporting.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.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-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-04-18 10:28:39 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-04-19 02:48:18 +0000
@@ -366,6 +366,9 @@
             // Headers
             // ---------------------------------------------------------------------
 
+            // Report-date
+            grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
+
             // Organisation units
             int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
 
@@ -390,15 +393,12 @@
                 }
             }
 
-            // Report-date
-            grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
-
             // Fixed Attributes
             if ( fixedAttributes != null && fixedAttributes.size() > 0 )
             {
                 for ( String fixedAttribute : fixedAttributes )
                 {
-                    grid.addHeader( new GridHeader( i18n.getString( fixedAttribute), false, true ) );
+                    grid.addHeader( new GridHeader( i18n.getString( fixedAttribute), hiddenCols.get( index ), true ) );
                 }
             }
 
@@ -441,6 +441,12 @@
                 grid.addRow();
 
                 // -------------------------------------------------------------
+                // Report-date
+                // -------------------------------------------------------------
+
+                grid.addValue( format.formatDate( programStageInstance.getExecutionDate() ) );
+
+                // -------------------------------------------------------------
                 // Add organisation units
                 // -------------------------------------------------------------
 
@@ -460,12 +466,6 @@
                 }
 
                 // -------------------------------------------------------------
-                // Report-date
-                // -------------------------------------------------------------
-
-                grid.addValue( format.formatDate( programStageInstance.getExecutionDate() ) );
-
-                // -------------------------------------------------------------
                 // Fixed Attributes
                 // -------------------------------------------------------------
 
@@ -474,7 +474,7 @@
                     Patient patient = programStageInstance.getProgramInstance().getPatient();
                     for ( String fixedAttribute : fixedAttributes )
                     {
-                        String value = getValueByFixedAttribute( patient, fixedAttribute ).toString();
+                        String value = getValueByFixedAttribute( patient, fixedAttribute, format );
                         grid.addValue( value );
                     }
                 }
@@ -568,13 +568,20 @@
         return hierarchyOrgunit;
     }
 
-    private Object getValueByFixedAttribute( Patient patient, String propertyName )
+    private String getValueByFixedAttribute( Patient patient, String propertyName, I18nFormat format )
     {
         propertyName = StringUtils.capitalize( propertyName );
 
         try
         {
-            return Patient.class.getMethod( "get" + propertyName ).invoke( patient );
+            Object object = Patient.class.getMethod( "get" + propertyName ).invoke( patient );
+            
+            if( object instanceof Date )
+            {
+                return format.formatDate( (Date) object );
+            }
+            
+            return object.toString();
         }
         catch ( Exception e )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-04-18 10:28:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-04-19 02:48:18 +0000
@@ -62,7 +62,7 @@
 public class GenerateTabularReportAction
     extends ActionPagingSupport<ProgramStageInstance>
 {
-    private String PREFIX_ORGANISTAION_UNIT = "org";
+    private String PREFIX_META_DATA = "meta";
 
     private String PREFIX_IDENTIFIER_TYPE = "iden";
 
@@ -376,7 +376,7 @@
             String objectType = infor[0];
             int objectId = Integer.parseInt( infor[1] );
 
-            if ( objectType.equals( PREFIX_ORGANISTAION_UNIT ) )
+            if ( objectType.equals( PREFIX_META_DATA ) )
             {
                 hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
             }
@@ -399,6 +399,7 @@
                 {
                     values.add( "" );
                 }
+                index++;
             }
             else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
             {
@@ -420,6 +421,7 @@
                 {
                     values.add( "" );
                 }
+                index++;
             }
             else if ( objectType.equals( PREFIX_DATA_ELEMENT ) )
             {
@@ -441,9 +443,9 @@
                 {
                     values.add( "" );
                 }
+                index++;
             }
 
-            index++;
         }
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-04-18 10:28:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-04-19 02:48:18 +0000
@@ -771,20 +771,31 @@
 				groupable: true
 			}
 			
+			cols[1] = { 
+				header: TR.i18n.report_date, 
+				dataIndex: 'col' + index,
+				name:"reportdate_1" + "_",
+				sortable: true,
+				draggable: false,
+				groupable: true,
+				sortAscText: TR.i18n.asc,
+				sortDescText: TR.i18n.desc
+			};
+			
 			var paramsLen = TR.cmp.params.identifierType.selected.store.data.length
 						+ TR.cmp.params.patientAttribute.selected.store.data.length
 						+ TR.cmp.params.dataelement.selected.store.data.length;
 			
-			var orgunitColsLen = TR.value.columns.length - paramsLen ;
-			var index = 1;
+			var metaDatatColsLen = TR.value.columns.length - paramsLen ;
+			var index = 2;
 			
-			for( index=1; index < orgunitColsLen ; index++ )
+			for( index=2; index < metaDatatColsLen; index++ )
 			{
 				cols[index] = {
 					header: TR.value.columns[index], 
 					dataIndex: 'col' + index,
 					height: TR.conf.layout.east_gridcolumn_height,
-					name:"org_" + index + "_",
+					name:"meta_" + index + "_",
 					sortable: false,
 					draggable: false,
 					groupable: true,
@@ -793,18 +804,6 @@
 				}
 			}
 			
-			
-			cols[index] = { 
-				header: TR.i18n.report_date, 
-				dataIndex: 'col' + index,
-				name:"reportdate_" + index + "_",
-				sortable: true,
-				draggable: false,
-				groupable: true,
-				sortAscText: TR.i18n.asc,
-				sortDescText: TR.i18n.desc
-			};
-			
 			TR.cmp.params.identifierType.selected.store.each( function(r) {
 				var dataIndex = "col" + index;
 				cols[index] = { 
@@ -891,7 +890,7 @@
 				viewConfig: {
 					getRowClass: function(record, rowIndex, rp, ds){ 
 						if(rowIndex == 0){
-							return 'green-row';
+							return 'blue-row';
 						} else {
 						   return '';
 						}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css	2012-04-18 07:44:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css	2012-04-19 02:48:18 +0000
@@ -670,8 +670,8 @@
 	padding: 4px 0 0;
 }
 
-.green-row {
-    color: green;
+.blue-row {
+    color: blue;
     font-style: italic;
 	font-weight: weight;
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2012-04-18 10:28:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2012-04-19 02:48:18 +0000
@@ -1,18 +1,19 @@
 {
 #if( $grid.getRows().size() > 0)
 	#set( $noHeader = $grid.getHeaders().size() )
-	#set ( $noOrgunit = $noHeader - $valueTypes.size())
+	#set ( $metaData = $noHeader - $valueTypes.size())
 	'total': "$total",
 	'valueTypes':[
 		#foreach( $col in $grid.getVisibleHeaders() )
-			#if ($velocityCount <= $noOrgunit + 1)
+			#if ($velocityCount <= $metaData + 1)
 				{
 					"valueType": "textfield",
 					"suggestedValues": []
 				},
 			#end
 		#end
-			
+		
+		#set($index = 0)
 		#foreach( $valueType in $valueTypes )
 			{
 				"valueType": 
@@ -25,13 +26,13 @@
 					#else
 						"textfield"
 					#end,
-					
 				#set( $suggestedValues = $mapSuggestedValues.get($index) )
 				"suggestedValues":[
 					#foreach( $suggestedValue in $suggestedValues )
 						["$!encoder.jsonEncode( ${suggestedValue} )"]
 						#if( $velocityCount < $suggestedValues.size() ),#end
 					#end
+				
 				]
 			}
 			#if( $velocityCount < $valueTypes.size() ),#end
@@ -56,12 +57,12 @@
 		{
 			"id":"$i18n.getString( 'filter' )",
 			#foreach( $col in $grid.getVisibleHeaders() )
-				#if ($velocityCount <= $noOrgunit )
+				#if ($velocityCount <= $metaData )
 					"col$velocityCount": "",
 				#end
 			#end
 			
-			#set( $index = $noOrgunit + 1 )
+			#set( $index = $metaData + 1 )
 			#foreach( $value in $values )
 				"col$index": "$value"
 				#if( $velocityCount < $values.size() ),#end