← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16971: PT separate options for col/row sub-totals implemented.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16971 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-06 20:48:11 +0200
message:
  PT separate options for col/row sub-totals implemented.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/i18n/en.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.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	2014-09-08 14:31:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2014-10-06 18:46:34 +0000
@@ -151,19 +151,24 @@
     private ReportParams reportParams;
 
     /**
-     * Indicates rendering of sub-totals for the table.
+     * Indicates rendering of row totals for the table.
      */
     private boolean rowTotals;
 
     /**
-     * Indicates rendering of sub-totals for the table.
+     * Indicates rendering of column totals for the table.
      */
     private boolean colTotals;
 
     /**
-     * Indicates rendering of sub-totals for the table.
-     */
-    private boolean subtotals;
+     * Indicates rendering of row sub-totals for the table.
+     */
+    private boolean rowSubtotals;
+
+    /**
+     * Indicates rendering of column sub-totals for the table.
+     */
+    private boolean colSubtotals;
 
     /**
      * Indicates rendering of empty rows for the table.
@@ -907,14 +912,27 @@
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
-    public boolean isSubtotals()
-    {
-        return subtotals;
-    }
-
-    public void setSubtotals( boolean subtotals )
-    {
-        this.subtotals = subtotals;
+    public boolean isRowSubtotals()
+    {
+        return rowSubtotals;
+    }
+
+    public void setRowSubtotals( boolean rowSubtotals )
+    {
+        this.rowSubtotals = rowSubtotals;
+    }    
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class, DimensionalView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public boolean isColSubtotals()
+    {
+        return colSubtotals;
+    }
+
+    public void setColSubtotals( boolean colSubtotals )
+    {
+        this.colSubtotals = colSubtotals;
     }
 
     @JsonProperty
@@ -925,6 +943,7 @@
         return hideEmptyRows;
     }
 
+
     public void setHideEmptyRows( boolean hideEmptyRows )
     {
         this.hideEmptyRows = hideEmptyRows;
@@ -1074,7 +1093,8 @@
             topLimit = reportTable.getTopLimit();
             rowTotals = reportTable.isRowTotals();
             colTotals = reportTable.isColTotals();
-            subtotals = reportTable.isSubtotals();
+            rowSubtotals = reportTable.isRowSubtotals();
+            colSubtotals = reportTable.isColSubtotals();
             hideEmptyRows = reportTable.isHideEmptyRows();
             showHierarchy = reportTable.isShowHierarchy();
             aggregationType = reportTable.getAggregationType();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-10-03 08:50:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-10-06 18:46:34 +0000
@@ -467,7 +467,7 @@
         executeSql( "update reporttable set showhierarchy = false where showhierarchy is null" );
         executeSql( "update reporttable set aggregationtype = 'default' where aggregationtype is null" );
 
-        // reporttable col/rowtotals = keep existing || copy from totals || true
+        // reporttable col/row totals = keep existing || copy from totals || true
         executeSql( "update reporttable set totals = true where totals is null" );
         executeSql( "update reporttable set coltotals = totals where coltotals is null" );
         executeSql( "update reporttable set coltotals = true where coltotals is null" );
@@ -475,6 +475,10 @@
         executeSql( "update reporttable set rowtotals = true where rowtotals is null" );        
         executeSql( "alter table reporttable drop column totals" );
 
+        // reporttable col/row subtotals
+        executeSql( "update reporttable set colsubtotals = subtotals where colsubtotals is null" );
+        executeSql( "update reporttable set rowsubtotals = subtotals where rowsubtotals is null" );
+
         executeSql( "update chart set reportingmonth = false where reportingmonth is null" );
         executeSql( "update chart set reportingbimonth = false where reportingbimonth is null" );
         executeSql( "update chart set reportingquarter = false where reportingquarter is null" );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2014-09-08 14:31:53 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2014-10-06 18:46:34 +0000
@@ -155,7 +155,9 @@
 	  
 	<property name="colTotals" />
 
-    <property name="subtotals" />
+    <property name="rowSubtotals" />
+	  
+	<property name="colSubtotals" />
 
     <property name="hideEmptyRows" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/i18n/en.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/i18n/en.properties	2014-10-06 17:09:53 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/i18n/en.properties	2014-10-06 18:46:34 +0000
@@ -167,3 +167,5 @@
 select_sub_units=Select sub-units
 you_do_not_have_access_to_all_items_in_this_favorite=You do not have access to all items in this favorite
 show=Show
+show_col_subtotals=Show column sub-totals
+show_row_subtotals=Show row sub-totals

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2014-10-06 17:09:53 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2014-10-06 18:46:34 +0000
@@ -436,9 +436,10 @@
 	};
 
 	OptionsWindow = function() {
-		var showRowTotals,
-            showColTotals,
-			showSubTotals,
+		var showColTotals,
+            showRowTotals,
+			showColSubTotals,
+            showRowSubTotals,
 			showDimensionLabels,
 			hideEmptyRows,
             aggregationType,
@@ -457,6 +458,7 @@
 			comboboxWidth = 262,
             comboBottomMargin = 1,
             checkboxBottomMargin = 2,
+            separatorTopMargin = 6,
 			window;
 
         showColTotals = Ext.create('Ext.form.field.Checkbox', {
@@ -471,25 +473,32 @@
 			checked: true
 		});
 
-		showSubTotals = Ext.create('Ext.form.field.Checkbox', {
-			boxLabel: NS.i18n.show_subtotals,
+		showColSubTotals = Ext.create('Ext.form.field.Checkbox', {
+			boxLabel: NS.i18n.show_col_subtotals,
+			style: 'margin-top:' + separatorTopMargin + 'px; margin-bottom:' + checkboxBottomMargin + 'px',
+			checked: true
+		});
+
+		showRowSubTotals = Ext.create('Ext.form.field.Checkbox', {
+			boxLabel: NS.i18n.show_row_subtotals,
 			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
 			checked: true
 		});
 
+		showDimensionLabels = Ext.create('Ext.form.field.Checkbox', {
+			boxLabel: NS.i18n.show_dimension_labels,
+			style: 'margin-top:' + separatorTopMargin + 'px; margin-bottom:' + comboBottomMargin + 'px',
+			checked: true
+		});
+
 		hideEmptyRows = Ext.create('Ext.form.field.Checkbox', {
 			boxLabel: NS.i18n.hide_empty_rows,
 			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
 		});
 
-		showDimensionLabels = Ext.create('Ext.form.field.Checkbox', {
-			boxLabel: NS.i18n.show_dimension_labels,
-			style: 'margin-bottom:' + comboBottomMargin + 'px'
-		});
-
 		aggregationType = Ext.create('Ext.form.field.ComboBox', {
 			cls: 'ns-combo',
-			style: 'margin-top:3px; margin-bottom:' + comboBottomMargin + 'px',
+			style: 'margin-top:' + (separatorTopMargin + 1) + 'px; margin-bottom:' + comboBottomMargin + 'px',
 			width: comboboxWidth,
 			labelWidth: 130,
 			fieldLabel: NS.i18n.aggregation_type,
@@ -670,9 +679,10 @@
 			items: [
                 showColTotals,
 				showRowTotals,
-				showSubTotals,
+				showColSubTotals,
+                showRowSubTotals,
+                showDimensionLabels,
 				hideEmptyRows,
-                showDimensionLabels,
                 aggregationType
 			]
 		};
@@ -713,7 +723,7 @@
 
 		window = Ext.create('Ext.window.Window', {
 			title: NS.i18n.table_options,
-			bodyStyle: 'background-color:#fff; padding:3px',
+			bodyStyle: 'background-color:#fff; padding:2px',
 			closeAction: 'hide',
 			autoShow: true,
 			modal: true,
@@ -723,7 +733,8 @@
 				return {
 					showRowTotals: showRowTotals.getValue(),
                     showColTotals: showColTotals.getValue(),
-					showSubTotals: showSubTotals.getValue(),
+					showColSubTotals: showColSubTotals.getValue(),
+                    showRowSubTotals: showRowSubTotals.getValue(),
                     showDimensionLabels: showDimensionLabels.getValue(),
 					hideEmptyRows: hideEmptyRows.getValue(),
                     aggregationType: aggregationType.getValue(),
@@ -744,7 +755,8 @@
 			setOptions: function(layout) {
 				showRowTotals.setValue(Ext.isBoolean(layout.showRowTotals) ? layout.showRowTotals : true);
 				showColTotals.setValue(Ext.isBoolean(layout.showColTotals) ? layout.showColTotals : true);
-				showSubTotals.setValue(Ext.isBoolean(layout.showSubTotals) ? layout.showSubTotals : true);
+				showColSubTotals.setValue(Ext.isBoolean(layout.showColSubTotals) ? layout.showColSubTotals : true);
+				showRowSubTotals.setValue(Ext.isBoolean(layout.showRowSubTotals) ? layout.showRowSubTotals : true);
 				showDimensionLabels.setValue(Ext.isBoolean(layout.showDimensionLabels) ? layout.showDimensionLabels : true);
 				hideEmptyRows.setValue(Ext.isBoolean(layout.hideEmptyRows) ? layout.hideEmptyRows : false);
                 aggregationType.setValue(Ext.isString(layout.aggregationType) ? layout.aggregationType : 'default');
@@ -764,7 +776,7 @@
 			items: [
 				{
 					bodyStyle: 'border:0 none; color:#222; font-size:12px; font-weight:bold',
-					style: 'margin-top:2px; margin-bottom:6px; margin-left:3px',
+					style: 'margin-top:4px; margin-bottom:6px; margin-left:5px',
 					html: NS.i18n.data
 				},
 				data,
@@ -773,7 +785,7 @@
 				},
 				{
 					bodyStyle: 'border:0 none; color:#222; font-size:12px; font-weight:bold',
-					style: 'margin-bottom:6px; margin-left:3px',
+					style: 'margin-bottom:6px; margin-left:5px',
 					html: NS.i18n.organisation_units
 				},
 				organisationUnits,
@@ -782,7 +794,7 @@
 				},
 				{
 					bodyStyle: 'border:0 none; color:#222; font-size:12px; font-weight:bold',
-					style: 'margin-bottom:6px; margin-left:3px',
+					style: 'margin-bottom:6px; margin-left:5px',
 					html: NS.i18n.style
 				},
 				style,
@@ -861,9 +873,10 @@
 					}
 
 					// cmp
+                    w.showColTotals = showColTotals;
 					w.showRowTotals = showRowTotals;
-                    w.showColTotals = showColTotals;
-					w.showSubTotals = showSubTotals;
+					w.showColSubTotals = showColSubTotals
+					w.showRowSubTotals = showRowSubTotals;
                     w.showDimensionLabels = showDimensionLabels;
 					w.hideEmptyRows = hideEmptyRows;
                     w.aggregationType = aggregationType;
@@ -948,9 +961,6 @@
                 favorite.colTotals = favorite.showColTotals;
 				delete favorite.showColTotals;
 
-				favorite.subtotals = favorite.showSubTotals;
-				delete favorite.showSubTotals;
-
 				favorite.reportParams = {
 					paramReportingPeriod: favorite.reportingPeriod,
 					paramOrganisationUnit: favorite.organisationUnit,

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js	2014-10-03 11:48:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/core.js	2014-10-06 18:46:34 +0000
@@ -310,7 +310,9 @@
 
 				// showColTotals: boolean (true)
 
-				// showSubTotals: boolean (true)
+				// showColSubTotals: boolean (true)
+
+				// showRowSubTotals: boolean (true)
 
                 // showDimensionLabels: boolean (false)
 
@@ -477,9 +479,10 @@
 					layout.filters = config.filters;
 
 					// properties
+					layout.showColTotals = Ext.isBoolean(config.colTotals) ? config.colTotals : (Ext.isBoolean(config.showColTotals) ? config.showColTotals : true);
 					layout.showRowTotals = Ext.isBoolean(config.rowTotals) ? config.rowTotals : (Ext.isBoolean(config.showRowTotals) ? config.showRowTotals : true);
-					layout.showColTotals = Ext.isBoolean(config.colTotals) ? config.colTotals : (Ext.isBoolean(config.showColTotals) ? config.showColTotals : true);
-					layout.showSubTotals = Ext.isBoolean(config.subtotals) ? config.subtotals : (Ext.isBoolean(config.showSubTotals) ? config.showSubTotals : true);
+					layout.showColSubTotals = Ext.isBoolean(config.subtotals) ? config.subtotals : (Ext.isBoolean(config.showColSubTotals) ? config.showColSubTotals : true);
+					layout.showRowSubTotals = Ext.isBoolean(config.subtotals) ? config.subtotals : (Ext.isBoolean(config.showRowSubTotals) ? config.showRowSubTotals : true);
 					layout.showDimensionLabels = Ext.isBoolean(config.showDimensionLabels) ? config.showDimensionLabels : (Ext.isBoolean(config.showDimensionLabels) ? config.showDimensionLabels : true);
 					layout.hideEmptyRows = Ext.isBoolean(config.hideEmptyRows) ? config.hideEmptyRows : false;
                     layout.aggregationType = Ext.isString(config.aggregationType) ? config.aggregationType : 'default';
@@ -1630,8 +1633,12 @@
 					delete layout.showColTotals;
 				}
 
-				if (layout.showSubTotals) {
-					delete layout.showSubTotals;
+				if (layout.showColSubTotals) {
+					delete layout.showColSubTotals;
+				}
+
+				if (layout.showRowSubTotals) {
+					delete layout.showRowSubTotals;
 				}
 
 				if (!layout.hideEmptyRows) {
@@ -2183,18 +2190,22 @@
 					return html;
 				};
 
-				doSubTotals = function(xAxis) {
-					return !!xLayout.showSubTotals && xAxis && xAxis.dims > 1;
+				doColSubTotals = function() {
+					return !!xLayout.showColSubTotals && xRowAxis && xRowAxis.dims > 1;
+				};
+
+				doRowSubTotals = function() {
+					return !!xLayout.showRowSubTotals && xColAxis && xColAxis.dims > 1;
+				};
+
+                doColTotals = function() {
+					return !!xLayout.showColTotals;
 				};
 
 				doRowTotals = function() {
 					return !!xLayout.showRowTotals;
 				};
 
-                doColTotals = function() {
-					return !!xLayout.showColTotals;
-				};
-
 				doSortableColumnHeaders = function() {
 					return (xRowAxis && xRowAxis.dims === 1);
 				};
@@ -2243,7 +2254,7 @@
 
                             a.push(getEmptyNameTdConfig({
                                 cls: 'pivot-dim-label',
-                                htmlValue: dimConf.objectNameMap[xLayout.rowObjectNames[j]].name + ', ' + dimConf.objectNameMap[xLayout.columnObjectNames[i]].name
+                                htmlValue: dimConf.objectNameMap[xLayout.rowObjectNames[j]].name + '&nbsp;/&nbsp;' + dimConf.objectNameMap[xLayout.columnObjectNames[i]].name
                             }));
                         }
 
@@ -2289,7 +2300,7 @@
 
 							dimHtml.push(getTdHtml(obj, condoId));
 
-							if (i === 0 && spanCount === xColAxis.span[i] && doSubTotals(xColAxis) ) {
+							if (i === 0 && spanCount === xColAxis.span[i] && doRowSubTotals() ) {
 								dimHtml.push(getTdHtml({
 									type: 'dimensionSubtotal',
 									cls: 'pivot-dim-subtotal cursor-default',
@@ -2486,7 +2497,7 @@
                     xValueObjects = valueObjects;
 
 					// col subtotals
-					if (doSubTotals(xColAxis)) {
+					if (doRowSubTotals()) {
 						var tmpValueObjects = [];
 
 						for (var i = 0, row, rowSubTotal, colCount; i < xValueObjects.length; i++) {
@@ -2528,7 +2539,7 @@
 					}
 
 					// row subtotals
-					if (doSubTotals(xRowAxis)) {
+					if (doColSubTotals()) {
 						var tmpAxisAllObjects = [],
 							tmpValueObjects = [],
 							tmpTotalValueObjects = [],
@@ -2699,7 +2710,7 @@
 
 						xTotalColObjects = totalColObjects;
 
-						if (xColAxis && doSubTotals(xColAxis)) {
+						if (xColAxis && doRowSubTotals()) {
 							var tmp = [];
 
 							for (var i = 0, item, subTotal = 0, empty = [], colCount = 0; i < xTotalColObjects.length; i++) {