dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21546
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10218: (PT) Option implemented: Show/hide (grand) totals.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 10218 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-14 13:59:07 +0100
message:
(PT) Option implemented: Show/hide (grand) totals.
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-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.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 2013-03-14 10:12:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2013-03-14 12:56:36 +0000
@@ -306,6 +306,11 @@
/**
* Indicates rendering of sub-totals for the table.
*/
+ private boolean totals;
+
+ /**
+ * Indicates rendering of sub-totals for the table.
+ */
private boolean subtotals;
/**
@@ -316,7 +321,7 @@
/**
* Indicates rendering of number formatting for the table.
*/
- private String numberFormatting;
+ private String digitGroupSeparator;
/**
* The display density of the text in the table.
@@ -1385,6 +1390,19 @@
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+ public boolean isTotals()
+ {
+ return totals;
+ }
+
+ public void setTotals( boolean totals )
+ {
+ this.totals = totals;
+ }
+
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
public boolean isSubtotals()
{
return subtotals;
@@ -1411,14 +1429,14 @@
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
- public String getNumberFormatting()
+ public String getDigitGroupSeparator()
{
- return numberFormatting;
+ return digitGroupSeparator;
}
- public void setNumberFormatting( String numberFormatting )
+ public void setDigitGroupSeparator( String digitGroupSeparator )
{
- this.numberFormatting = numberFormatting;
+ this.digitGroupSeparator = digitGroupSeparator;
}
@JsonProperty
@@ -1650,9 +1668,10 @@
reportParams = reportTable.getReportParams() == null ? reportParams : reportTable.getReportParams();
sortOrder = reportTable.getSortOrder() == null ? sortOrder : reportTable.getSortOrder();
topLimit = reportTable.getTopLimit() == null ? topLimit : reportTable.getTopLimit();
+ totals = reportTable.isTotals();
subtotals = reportTable.isSubtotals();
hideEmptyRows = reportTable.isHideEmptyRows();
- numberFormatting = reportTable.getNumberFormatting();
+ digitGroupSeparator = reportTable.getDigitGroupSeparator();
displayDensity = reportTable.getDisplayDensity();
fontSize = reportTable.getFontSize();
userOrganisationUnit = reportTable.isUserOrganisationUnit();
=== 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 2013-03-14 11:51:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-03-14 12:57:16 +0000
@@ -429,13 +429,14 @@
executeSql( "update reporttable set lastfinancialyear = false where lastfinancialyear is null" );
executeSql( "update reporttable set last5financialyears = false where last5financialyears is null" );
executeSql( "update reporttable set cumulative = false where cumulative is null" );
- executeSql( "update reporttable set subtotals = false where subtotals is null" );
executeSql( "update reporttable set userorganisationunit = false where userorganisationunit is null" );
executeSql( "update reporttable set userorganisationunitchildren = false where userorganisationunitchildren is null" );
+ executeSql( "update reporttable set totals = true where totals is null" );
+ executeSql( "update reporttable set subtotals = true where subtotals is null" );
+ executeSql( "update reporttable set hideemptyrows = false where hideemptyrows is null" );
executeSql( "update reporttable set displaydensity = 'normal' where displaydensity is null" );
executeSql( "update reporttable set fontsize = 'normal' where fontsize is null" );
- executeSql( "update reporttable set hideemptyrows = false where hideemptyrows is null" );
- executeSql( "update reporttable set numberformatting = 'space' where numberformatting is null" );
+ executeSql( "update reporttable set digitgroupseparator = 'space' where digitgroupseparator is null" );
executeSql( "update chart set reportingmonth = false where reportingmonth is null" );
executeSql( "update chart set reportingbimonth = false where reportingbimonth 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 2013-03-14 10:12:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2013-03-14 12:56:36 +0000
@@ -116,11 +116,13 @@
<property name="topLimit" />
+ <property name="totals" />
+
<property name="subtotals" />
<property name="hideEmptyRows" />
- <property name="numberFormatting" />
+ <property name="digitGroupSeparator" />
<property name="displayDensity" />
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-03-13 19:53:02 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-03-14 12:56:36 +0000
@@ -746,9 +746,10 @@
};
PT.app.OptionsWindow = function() {
- var showSubTotals,
+ var showTotals,
+ showSubTotals,
hideEmptyRows,
- numberFormatting,
+ digitGroupSeparator,
displayDensity,
fontSize,
@@ -756,22 +757,32 @@
style,
window;
+ showTotals = Ext.create('Ext.form.field.Checkbox', {
+ boxLabel: 'Show totals', //i18n
+ style: 'margin-bottom:4px',
+ checked: true
+ });
+ pt.viewport.showTotals = showTotals;
+
showSubTotals = Ext.create('Ext.form.field.Checkbox', {
boxLabel: 'Show sub-totals', //i18n
+ style: 'margin-bottom:4px',
checked: true
});
pt.viewport.showSubTotals = showSubTotals;
hideEmptyRows = Ext.create('Ext.form.field.Checkbox', {
- boxLabel: 'Hide empty rows' //i18n
+ boxLabel: 'Hide empty rows', //i18n
+ style: 'margin-bottom:4px',
});
pt.viewport.hideEmptyRows = hideEmptyRows;
- numberFormatting = Ext.create('Ext.form.field.ComboBox', {
- fieldLabel: 'Number formatting', //i18n
+ digitGroupSeparator = Ext.create('Ext.form.field.ComboBox', {
labelStyle: 'color:#333',
cls: 'pt-combo',
- width: 230,
+ width: 250,
+ labelWidth: 130,
+ fieldLabel: 'Digit group separator', //i18n
queryMode: 'local',
valueField: 'id',
editable: false,
@@ -785,13 +796,14 @@
]
})
});
- pt.viewport.numberFormatting = numberFormatting;
+ pt.viewport.digitGroupSeparator = digitGroupSeparator;
displayDensity = Ext.create('Ext.form.field.ComboBox', {
+ cls: 'pt-combo',
+ width: 250,
+ labelWidth: 130,
fieldLabel: 'Display density', //i18n
labelStyle: 'color:#333',
- cls: 'pt-combo',
- width: 230,
queryMode: 'local',
valueField: 'id',
editable: false,
@@ -808,11 +820,11 @@
pt.viewport.displayDensity = displayDensity;
fontSize = Ext.create('Ext.form.field.ComboBox', {
- xtype: 'combobox',
+ cls: 'pt-combo',
+ width: 250,
+ labelWidth: 130,
fieldLabel: 'Font size', //i18n
labelStyle: 'color:#333',
- cls: 'pt-combo',
- width: 230,
queryMode: 'local',
valueField: 'id',
editable: false,
@@ -832,6 +844,7 @@
bodyStyle: 'border:0 none',
style: 'margin-left:14px',
items: [
+ showTotals,
showSubTotals,
hideEmptyRows
]
@@ -841,9 +854,9 @@
bodyStyle: 'border:0 none',
style: 'margin-left:14px',
items: [
- numberFormatting,
displayDensity,
- fontSize
+ fontSize,
+ digitGroupSeparator
]
};
@@ -857,11 +870,12 @@
hideOnBlur: true,
getOptions: function() {
return {
+ showTotals: showTotals.getValue(),
showSubTotals: showSubTotals.getValue(),
hideEmptyRows: hideEmptyRows.getValue(),
- numberFormatting: numberFormatting.getValue(),
displayDensity: displayDensity.getValue(),
- fontSize: fontSize.getValue()
+ fontSize: fontSize.getValue(),
+ digitGroupSeparator: digitGroupSeparator.getValue()
};
},
items: [
@@ -965,6 +979,7 @@
favorite = Ext.clone(pt.xSettings.options);
// Server sync
+ favorite.totals = favorite.showTotals;
favorite.subtotals = favorite.showSubTotals;
// Dimensions
@@ -3575,11 +3590,12 @@
}
// Options
+ pt.viewport.showTotals.setValue(r.totals);
pt.viewport.showSubTotals.setValue(r.subtotals);
pt.viewport.hideEmptyRows.setValue(r.hideEmptyRows);
- pt.viewport.numberFormatting.setValue(r.numberFormatting);
pt.viewport.displayDensity.setValue(r.displayDensity);
pt.viewport.fontSize.setValue(r.fontSize);
+ pt.viewport.digitGroupSeparator.setValue(r.digitGroupSeparator);
update();
};
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2013-03-13 14:59:20 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2013-03-14 11:02:27 +0000
@@ -217,7 +217,7 @@
};
conf.pivot = {
- numberFormatting: {
+ digitGroupSeparator: {
'comma': ',',
'space': ' '
},
@@ -515,7 +515,7 @@
return x;
}
- return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, pt.conf.pivot.numberFormatting[nf]);
+ return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, pt.conf.pivot.digitGroupSeparator[nf]);
}
};
@@ -985,6 +985,7 @@
getTableHtml = function(xColAxis, xRowAxis, xResponse) {
var getTdHtml,
doSubTotals,
+ doTotals,
getColAxisHtmlArray,
getRowHtmlArray,
rowAxisHtmlArray,
@@ -1037,7 +1038,7 @@
colSpan = config.colSpan ? 'colspan="' + config.colSpan + '"' : '';
rowSpan = config.rowSpan ? 'rowspan="' + config.rowSpan + '"' : '';
htmlValue = config.collapsed ? ' ' : config.htmlValue || config.value || ' ';
- htmlValue = config.type !== 'dimension' ? pt.util.number.pp(htmlValue, options.numberFormatting) : htmlValue;
+ htmlValue = config.type !== 'dimension' ? pt.util.number.pp(htmlValue, options.digitGroupSeparator) : htmlValue;
displayDensity = pt.conf.pivot.displayDensity[config.displayDensity] || pt.conf.pivot.displayDensity[options.displayDensity];
fontSize = pt.conf.pivot.fontSize[config.fontSize] || pt.conf.pivot.fontSize[options.fontSize];
@@ -1065,6 +1066,10 @@
//return (multiItemDimension > 1);
};
+ doTotals = function() {
+ return !!options.showTotals;
+ };
+
getColAxisHtmlArray = function() {
var a = [],
getEmptyHtmlArray;
@@ -1103,13 +1108,15 @@
}));
}
- if (i === 0 && j === (dimItems.length - 1)) {
- dimHtml.push(getTdHtml(options, {
- type: 'dimensionTotal',
- cls: 'pivot-dim-total',
- rowSpan: xColAxis.dims,
- htmlValue: 'Total'
- }));
+ if (doTotals()) {
+ if (i === 0 && j === (dimItems.length - 1)) {
+ dimHtml.push(getTdHtml(options, {
+ type: 'dimensionTotal',
+ cls: 'pivot-dim-total',
+ rowSpan: xColAxis.dims,
+ htmlValue: 'Total'
+ }));
+ }
}
}
@@ -1199,7 +1206,7 @@
}
// Value total objects
- if (xColAxis) {
+ if (xColAxis && doTotals()) {
for (var i = 0, empty, total; i < valueObjects.length; i++) {
empty = [];
total = 0;
@@ -1239,7 +1246,9 @@
}
// Hide total
- totalValueObjects[i].collapsed = true;
+ if (doTotals()) {
+ totalValueObjects[i].collapsed = true;
+ }
// Hide/reduce parent dim span
parent = axisObjects[i][xRowAxis.dims-1];
@@ -1425,7 +1434,7 @@
getColTotalHtmlArray = function() {
var a = [];
- if (xRowAxis) {
+ if (xRowAxis && doTotals()) {
// Total col items
for (var i = 0, colSum; i < valueItems[0].length; i++) {
@@ -1488,17 +1497,19 @@
values = [],
a = [];
- for (var i = 0; i < totalColItems.length; i++) {
- values.push(totalColItems[i].value);
- }
-
- if (xColAxis && xRowAxis) {
- grandTotalSum = Ext.Array.sum(values);
-
- a.push(getTdHtml(options, {
- cls: 'pivot-value-grandtotal',
- htmlValue: pt.util.number.roundIf(grandTotalSum, 1).toString()
- }));
+ if (doTotals()) {
+ for (var i = 0; i < totalColItems.length; i++) {
+ values.push(totalColItems[i].value);
+ }
+
+ if (xColAxis && xRowAxis) {
+ grandTotalSum = Ext.Array.sum(values);
+
+ a.push(getTdHtml(options, {
+ cls: 'pivot-value-grandtotal',
+ htmlValue: pt.util.number.roundIf(grandTotalSum, 1).toString()
+ }));
+ }
}
return a;
@@ -1511,18 +1522,20 @@
row,
a = [];
- if (xRowAxis) {
- dimTotalArray = [getTdHtml(options, {
- cls: 'pivot-dim-total',
- colSpan: xRowAxis.dims,
- htmlValue: 'Total'
- })];
+ if (doTotals()) {
+ if (xRowAxis) {
+ dimTotalArray = [getTdHtml(options, {
+ cls: 'pivot-dim-total',
+ colSpan: xRowAxis.dims,
+ htmlValue: 'Total'
+ })];
+ }
+
+ row = [].concat(dimTotalArray || [], Ext.clone(colTotal) || [], Ext.clone(grandTotal) || []);
+
+ a.push(row);
}
- row = [].concat(dimTotalArray || [], Ext.clone(colTotal) || [], Ext.clone(grandTotal) || []);
-
- a.push(row);
-
return a;
};
@@ -1652,11 +1665,12 @@
validateSettings,
defaultOptions = {
+ showTotals: true,
showSubTotals: true,
hideEmptyRows: false,
- numberFormatting: 'space',
displayDensity: 'normal',
- fontSize: 'normal'
+ fontSize: 'normal',
+ digitGroupSeparator: 'space'
};
removeEmptyDimensions = function(axis) {
@@ -1714,11 +1728,12 @@
return defaultOptions;
}
+ options.showTotals = Ext.isDefined(options.showTotals) ? options.showTotals : defaultOptions.showTotals;
options.showSubTotals = Ext.isDefined(options.showSubTotals) ? options.showSubTotals : defaultOptions.showSubTotals;
options.hideEmptyRows = Ext.isDefined(options.hideEmptyRows) ? options.hideEmptyRows : defaultOptions.hideEmptyRows;
- options.numberFormatting = Ext.isDefined(options.numberFormatting) ? options.numberFormatting : defaultOptions.numberFormatting;
options.displayDensity = options.displayDensity || defaultOptions.displayDensity;
options.fontSize = options.fontSize || defaultOptions.fontSize;
+ options.digitGroupSeparator = Ext.isDefined(options.digitGroupSeparator) ? options.digitGroupSeparator : defaultOptions.digitGroupSeparator;
return options;
};
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js 2013-03-12 13:44:27 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js 2013-03-14 11:02:27 +0000
@@ -13,11 +13,12 @@
{name: 'ou', items: ['ImspTQPwCqd']}
],
options: {
+ showTotals: true,
showSubTotals: true,
hideEmptyRows: false,
- numberFormatting: 'space',
displayDensity: 'normal',
fontSize: 'normal',
+ digitGroupSeparator: 'space',
userOrganisationUnit: true,
userOrganisationUnitChildren: false
}
@@ -61,9 +62,12 @@
'ou': ['ImspTQPwCqd']
},
options: {
- showSubTotals: false,
+ showTotals: true,
+ showSubTotals: true,
+ hideEmptyRows: false,
displayDensity: 'normal',
- fontSize: 'normal'
+ fontSize: 'normal',
+ digitGroupSeparator: 'space'
}
};