← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6629: (patient) Add function to hide orgnunits column in tabular report

 

------------------------------------------------------------
revno: 6629
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-18 14:44:54 +0700
message:
  (patient) Add function to hide orgnunits column in tabular report
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/resources/org/hisp/dhis/caseentry/i18n_module.properties
  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/i18n.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 04:03:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-04-18 07:44:54 +0000
@@ -279,9 +279,10 @@
         {
             Grid grid = new ListGrid();
 
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
             // Title
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
+
             Date executionDate = programStageInstance.getExecutionDate();
             String executionDateValue = (executionDate != null) ? format.formatDate( programStageInstance
                 .getExecutionDate() ) : "[" + i18n.getString( "none" ) + "]";
@@ -291,16 +292,17 @@
                 + format.formatDate( programStageInstance.getDueDate() ) + " - " + i18n.getString( "report_date" )
                 + ": " + executionDateValue );
 
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
             // Headers
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
 
             grid.addHeader( new GridHeader( i18n.getString( "name" ), false, true ) );
             grid.addHeader( new GridHeader( i18n.getString( "value" ), false, true ) );
 
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
             // Values
-            // ---------------------------------------------------------------------
+            // -----------------------------------------------------------------
+
             Collection<PatientDataValue> patientDataValues = patientDataValueService
                 .getPatientDataValues( programStageInstance );
 
@@ -366,17 +368,31 @@
             // Organisation units
             int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
 
-            for ( int i = level; i < maxLevel; i++ )
-            {
-                grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i ).getName(),
-                    false, true ) );
+            boolean hasHiddenOrgunits = !(hiddenCols.size() == idens.size() + attributes.size() + dataElements.size());
+            int index = 0;
+
+            if ( !hasHiddenOrgunits )
+            {
+                for ( int i = level; i < maxLevel; i++ )
+                {
+                    grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i )
+                        .getName(), false, true ) );
+                }
+            }
+            else
+            {
+                for ( int i = level; i < maxLevel; i++ )
+                {
+                    grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i )
+                        .getName(), hiddenCols.get( index ), true ) );
+                    index++;
+                }
             }
 
             // Report-date
             grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
 
             // Identifier types
-            int index = 0;
             if ( idens != null && idens.size() > 0 )
             {
                 for ( PatientIdentifierType identifierType : idens )
@@ -429,7 +445,7 @@
                     }
                     else
                     {
-                        grid.addValue("");
+                        grid.addValue( "" );
                     }
                 }
 

=== 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 04:03:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-04-18 07:44:54 +0000
@@ -62,6 +62,8 @@
 public class GenerateTabularReportAction
     extends ActionPagingSupport<ProgramStageInstance>
 {
+    private String PREFIX_ORGANISTAION_UNIT = "org";
+    
     private String PREFIX_IDENTIFIER_TYPE = "iden";
 
     private String PREFIX_PATIENT_ATTRIBUTE = "attr";
@@ -367,7 +369,11 @@
             String objectType = infor[0];
             int objectId = Integer.parseInt( infor[1] );
 
-            if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
+            if( objectType.equals( PREFIX_ORGANISTAION_UNIT ))
+            {
+                hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
+            }
+            else if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
             {
                 PatientIdentifierType identifierType = identifierTypeService.getPatientIdentifierType( objectId );
                 identifierTypes.add( identifierType );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-04-18 04:03:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-04-18 07:44:54 +0000
@@ -315,4 +315,5 @@
 et_no_dataelement = Please select at least one data element.
 em_no_orgunits = Please select an organisation unit.
 reset = Reset
-no = No.
\ No newline at end of file
+no = No.
+options = Options
\ No newline at end of file

=== 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 04:03:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-04-18 07:44:54 +0000
@@ -507,6 +507,8 @@
 			this.datatable = Ext.create('Ext.data.Store', {
 				fields: TR.value.fields,
 				data: TR.value.values,
+				remoteSort:true,
+				autoLoad: false,
 				proxy: {
 					type: 'memory',
 					reader: {
@@ -522,6 +524,8 @@
     TR.state = {
         currentPage: 1,
 		total: 1,
+		orderByOrgunitAsc: true,
+		orderByExecutionDateByAsc: true,
 		generateReport: function( type ) {
 			// Validation
 			if( !this.validation.objects() )
@@ -576,9 +580,11 @@
             p.endDate = TR.cmp.settings.endDate.rawValue;
 			p.facilityLB = TR.cmp.settings.facilityLB.getValue();
 			p.level = TR.cmp.settings.level.getValue();
+			// organisation unit
 			p.orgunitId = TR.cmp.params.organisationunit.treepanel.getSelectionModel().getSelection()[0].data.id
-			p.orderByOrgunitAsc = 'true';
-			p.orderByExecutionDateByAsc= 'true';
+			p.orderByOrgunitAsc = this.orderByOrgunitAsc;
+			p.orderByExecutionDateByAsc= this.orderByExecutionDateByAsc;
+			
 			p.programStageId = TR.cmp.params.programStage.getValue();
 			p.currentPage = this.currentPage;
 			
@@ -759,18 +765,24 @@
 					header: TR.value.columns[index], 
 					dataIndex: 'col' + index,
 					height: TR.conf.layout.east_gridcolumn_height,
+					name:"org_" + index + "_",
 					sortable: false,
 					draggable: false,
-					groupable: true
+					groupable: true,
+					sortAscText: TR.i18n.asc,
+					sortDescText: TR.i18n.desc
 				}
 			}
 			
 			cols[index] = { 
 				header: TR.i18n.report_date, 
 				dataIndex: 'col' + index,
-				sortable: false,
+				name:"reportdate_" + index + "_",
+				sortable: true,
 				draggable: false,
-				groupable: true
+				groupable: true,
+				sortAscText: TR.i18n.asc,
+				sortDescText: TR.i18n.desc
 			};
 			
 			index++;
@@ -806,6 +818,7 @@
 					sortable: false,
 					draggable: false,
 					groupable: true,
+					emptyText: TR.i18n.et_no_data,
 					editor: {
 							xtype: TR.value.valueTypes[index - orgunitColsLen - 2].valueType,
 							queryMode: 'local',
@@ -856,6 +869,15 @@
                 height: TR.util.viewport.getSize().y - 68,
 				columns: cols,
 				scroll: 'both',
+				viewConfig: {
+					getRowClass: function(record, rowIndex, rp, ds){ 
+						if(rowIndex == 0){
+							return 'green-row';
+						} else {
+						   return '';
+						}
+					}
+				},
 				bbar: [
 					{
 						xtype: 'button',
@@ -970,9 +992,24 @@
 						{
 							grid.getView().focusRow(this.rowIndex);
 						}
+					},
+					sortchange: function( ct, column, direction, eOpts )
+					{
+						var sortedStatus = (direction == "DESC") ? false: true;
+						if( column.name.match("^org")=='org' && TR.state.orderByOrgunitAsc != sortedStatus )
+						{
+							TR.state.orderByOrgunitAsc = sortedStatus;
+							TR.exe.execute();
+						}
+						else if ( TR.state.orderByExecutionDateByAsc != sortedStatus )
+						{
+							TR.state.orderByExecutionDateByAsc = (direction == "DESC") ? false: true;
+							TR.exe.execute();
+						}
 					}
 				},
-				sortAscText: TR.i18n.asc
+				sortAscText: TR.i18n.asc,
+				sortDescText: TR.i18n.desc
 			});
 			
 			if (Ext.grid.RowEditor) {

=== 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-17 15:28:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css	2012-04-18 07:44:54 +0000
@@ -668,4 +668,10 @@
 }
 .tr-accordion .tr-combo .x-form-item-label { /* accordion combo box label */
 	padding: 4px 0 0;
+}
+
+.green-row {
+    color: green;
+    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/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-04-18 04:03:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-04-18 07:44:54 +0000
@@ -15,6 +15,7 @@
 use_data_from_level:'$encoder.jsEscape($i18n.getString( 'use_data_from_level' ) , "'")',
 all: '$encoder.jsEscape($i18n.getString( 'all' ) , "'")',
 children_only: '$encoder.jsEscape($i18n.getString( 'children_only' ) , "'")',
+available: '$encoder.jsEscape($i18n.getString( 'available' ) , "'")',
 selected: '$encoder.jsEscape($i18n.getString( 'selected' ) , "'")',
 show_hierachy_from_level: '$encoder.jsEscape($i18n.getString( 'show_hierachy_from_level' ) , "'")',
 report_unit: '$encoder.jsEscape($i18n.getString( 'report_unit' ) , "'")',
@@ -39,5 +40,7 @@
 asc:'$encoder.jsEscape($i18n.getString( 'asc' ) , "'")',
 options:'$encoder.jsEscape($i18n.getString( 'options' ) , "'")',
 reset:'$encoder.jsEscape($i18n.getString( 'reset' ) , "'")',
-no:'$encoder.jsEscape($i18n.getString( 'no' ) , "'")'
+no:'$encoder.jsEscape($i18n.getString( 'no' ) , "'")',
+asc:'$encoder.jsEscape($i18n.getString( 'asc' ) , "'")',
+desc:'$encoder.jsEscape($i18n.getString( 'desc' ) , "'")'
 };
\ No newline at end of file