← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7035: Compacted tabular report json

 

------------------------------------------------------------
revno: 7035
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-24 16:30:38 +0200
message:
  Compacted tabular report json
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.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-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-05-24 10:58:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-05-24 14:30:38 +0000
@@ -698,7 +698,7 @@
 			class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonTabularReportResult.vm</result>
 			<result name="xls" type="gridXlsResult" />
-		    		<result name="pdf" type="gridPdfResult" />
+		    <result name="pdf" type="gridPdfResult" />
 			<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
 		</action>
 			

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm	2012-05-15 02:36:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm	2012-05-24 14:30:38 +0000
@@ -1,100 +1,89 @@
-{
-#if( $grid && $grid.getRows().size() > 0)
-	#set( $noHeader = $grid.getHeaders().size() )
-	#set ( $metaData = $noHeader - $valueTypes.size())
-	'total': "$total",
-	'valueTypes':[
-		#foreach( $col in $grid.getHeaders() )
-			#if ($velocityCount <= $metaData + 1)
-				{
-					"valueType": "textfield",
-					"suggestedValues": []
-				},
-			#end
-		#end
-		
-		#set($index = 0)
-		#foreach( $valueType in $valueTypes )
-			{
-				"valueType": 
-					#if( $valueType == 'number' || $valueType == 'NUMBER' )
-						"textfield"
-					#elseif( $valueType == 'bool' || $valueType == 'YES/NO' ||  $valueType =='optionSet' )
-						"combobox"
-					#elseif( $valueType == 'date' || $valueType == 'DATE' )
-						"textfield"
-					#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
-			#set( $index = $index + 1 )
-		#end
-	],
-	'columns':[
-		"id",
-		#foreach( $colName in $grid.getHeaders() )
-			"$colName.name"
-			#if( $velocityCount < $noHeader ),#end
-		#end
-	],
-	'fields':[
-		"id",
-		#foreach( $col in $grid.getHeaders() )
-			"col$velocityCount"
-			#if( $velocityCount < $noHeader ),#end
-		#end
-	],
-	'hidden':[
-		#set( $index = 2 )
-		#set($col="col" + $index )
-		#foreach( $header in $grid.getHeaders() )
-			{"$col":"$header.hidden"}
-			#if( $velocityCount < $noHeader ),#end
-			#set( $index = $index + 1 )
-		#end
-	],
-	'items':[
-		{
-			"id":"$i18n.getString( 'filter' )",
-			#foreach( $col in $grid.getHeaders() )
-				#if ($velocityCount <= $metaData )
-					"col$velocityCount": "",
-				#end
-			#end
-			
-			#set( $index = $metaData + 1 )
-			#foreach( $value in $values )
-				"col$index": "$value"
-				#if( $velocityCount < $values.size() ),#end
-				#set( $index = $index + 1 )
-			#end
-		},
-		#foreach( $row in $grid.getRows() )
-			{
-				#set( $nr = ( ( $paging.getCurrentPage() - 1  ) * $paging.pageSize ) + $velocityCount )
-				"id":$nr,
-				#foreach( $col in $row )
-					"col$velocityCount": "$!encoder.htmlEncode( $col )"
-					#if( $velocityCount < $noHeader ),#end
-				#end
-			},
-		#end
-		]	
+#set( $noRows = $grid.getRows().size() )
+{
+#if( $grid && $noRows > 0)
+#set( $noHeader = $grid.getHeaders().size() )
+#set( $metaData = $noHeader - $valueTypes.size() )
+"total": "$total",
+"valueTypes":[
+#foreach( $col in $grid.getHeaders() )
+#if ($velocityCount <= $metaData + 1)
+{
+  "valueType": "textfield",
+  "suggestedValues": []
+},
+#end
+#end
+#set($index = 0)
+#foreach( $valueType in $valueTypes )
+{
+  "valueType": 
+  #if( $valueType == 'number' || $valueType == 'NUMBER' )
+  "textfield"
+  #elseif( $valueType == 'bool' || $valueType == 'YES/NO' ||  $valueType =='optionSet' )
+  "combobox"
+  #elseif( $valueType == 'date' || $valueType == 'DATE' )
+  "textfield"
+  #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
+  #set( $index = $index + 1 )
+  #end
+  ],
+  "columns":[
+    "id",
+    #foreach( $colName in $grid.getHeaders() )
+    "$colName.name"#if( $velocityCount < $noHeader ),#end
+    #end
+  ],
+  "fields":[
+    "id",
+    #foreach( $col in $grid.getHeaders() )
+    "col${velocityCount}"#if( $velocityCount < $noHeader ),#end
+    #end
+  ],
+  "hidden":[
+  #set( $index = 2 )
+  #set($col="col" + $index )
+  #foreach( $header in $grid.getHeaders() )
+    {"$col":"$header.hidden"}#if( $velocityCount < $noHeader ),#end
+    #set( $index = $index + 1 )
+  #end
+  ],
+  "items":[
+  {
+    "id":"$i18n.getString( 'filter' )",
+    #foreach( $col in $grid.getHeaders() )
+    #if ($velocityCount <= $metaData )
+    "col${velocityCount}": "",
+    #end
+    #end
+    #set( $index = $metaData + 1 )
+    #foreach( $value in $values )
+    "col${index}": "${value}"#if( $velocityCount < $values.size() ),#end
+    #set( $index = $index + 1 )
+    #end
+  },
+  #foreach( $row in $grid.getRows() )
+  {
+    #set( $nr = ( ( $paging.getCurrentPage() - 1  ) * $paging.pageSize ) + $velocityCount )
+    "id": ${nr},
+    #foreach( $col in $row )
+    "col${velocityCount}": "$!encoder.htmlEncode( $col )"#if( $velocityCount < $noHeader ),#end
+    #end
+  }#if( $velocityCount < $noRows ),#end
+  #end ]	
 #else
-	'total': 0,
-	'valueTypes':[],
-	'columns':[],
-	'fields':[],
-	'hidden':[],
-	'items':[]
+  "total": 0,
+  "valueTypes":[],
+  "columns":[],
+  "fields":[],
+  "hidden":[],
+  "items":[]
 #end
 }
\ No newline at end of file