← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16667: ER show dimension labels option implemented.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16667 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-09 13:26:45 +0200
message:
  ER show dimension labels option implemented.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/en.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css


--
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/eventreport/EventReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java	2014-09-09 11:00:47 +0000
@@ -144,6 +144,11 @@
      */
     private String fontSize;
 
+    /**
+     * The font size of the text in the table.
+     */
+    private boolean showDimensionLabels;
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -390,6 +395,19 @@
     {
         this.fontSize = fontSize;
     }
+    
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public boolean isShowDimensionLabels()
+    {
+        return showDimensionLabels;
+    }
+
+    public void setShowDimensionLabels( boolean showDimensionLabels )
+    {
+        this.showDimensionLabels = showDimensionLabels;
+    }    
 
     @Override
     public void mergeWith( IdentifiableObject other )
@@ -410,6 +428,7 @@
             hideEmptyRows = eventReport.isHideEmptyRows();
             countType = eventReport.getCountType();
             showHierarchy = eventReport.isShowHierarchy();
+            showDimensionLabels = eventReport.isShowDimensionLabels();
             displayDensity = eventReport.getDisplayDensity();
             fontSize = eventReport.getFontSize();
 

=== 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-09-08 14:31:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-09-09 11:00:47 +0000
@@ -431,6 +431,7 @@
         executeSql( "update eventchart set hidetitle = false where hidetitle is null" );
         executeSql( "update eventchart set hidesubtitle = false where hidesubtitle is null" );
         executeSql( "update reporttable set showdimensionlabels = false where showdimensionlabels is null" );
+        executeSql( "update eventreport set showdimensionlabels = false where showdimensionlabels is null" );
 
         // move timelydays from system setting => dataset property
         executeSql( "update dataset set timelydays = 15 where timelydays is null" );

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml	2014-07-09 15:43:12 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/eventreport/EventReport.hbm.xml	2014-09-09 11:00:47 +0000
@@ -122,6 +122,8 @@
 
     <property name="countType" />
 
+    <property name="showDimensionLabels" />
+
     <property name="digitGroupSeparator" />
 
     <property name="displayDensity" />

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/en.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/en.properties	2014-08-27 11:24:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/i18n/en.properties	2014-09-09 10:47:28 +0000
@@ -162,3 +162,4 @@
 go_to_event_charts=Go to event charts
 open_this_table_as_chart=Open this table as chart
 open_last_chart=Open last chart
+show_dimension_labels=Show dimension labels

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2014-09-02 14:11:29 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2014-09-09 10:47:28 +0000
@@ -817,7 +817,7 @@
 
                 this.sortOrderCmp = Ext.create('Ext.form.field.ComboBox', {
                     cls: 'ns-combo',
-                    style: 'margin-bottom:2px',
+                    style: 'margin-bottom:' + container.comboBottomMargin + 'px',
                     width: sortWidth,
                     queryMode: 'local',
                     valueField: 'id',
@@ -834,7 +834,7 @@
 
                 this.topLimitCmp = Ext.create('Ext.form.field.Number', {
                     width: sortWidth - 1,
-                    style: 'margin-bottom:2px; margin-left:1px',
+                    style: 'margin-bottom:' + container.comboBottomMargin + 'px; margin-left:1px',
                     minValue: 1,
                     maxValue: 10000,
                     value: container.topLimit,
@@ -1564,6 +1564,7 @@
             aggregationType,
 			showHierarchy,
 			digitGroupSeparator,
+			showDimensionLabels,
 			displayDensity,
 			fontSize,
 			reportingPeriod,
@@ -1575,23 +1576,25 @@
 			parameters,
 
 			comboboxWidth = 280,
+            comboBottomMargin = 1,
+            checkboxBottomMargin = 2,
 			window;
 
 		showTotals = Ext.create('Ext.form.field.Checkbox', {
 			boxLabel: NS.i18n.show_totals,
-			style: 'margin-bottom:4px',
+			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
 			checked: true
 		});
 
 		showSubTotals = Ext.create('Ext.form.field.Checkbox', {
 			boxLabel: NS.i18n.show_subtotals,
-			style: 'margin-bottom:4px',
+			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
 			checked: true
 		});
 
 		hideEmptyRows = Ext.create('Ext.form.field.Checkbox', {
 			boxLabel: NS.i18n.hide_empty_rows,
-			style: 'margin-bottom:4px',
+			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
             checked: true
 		});
 
@@ -1599,12 +1602,13 @@
             boxLabel: NS.i18n.limit,
             sortOrder: 1,
             topLimit: 10,
-            comboboxWidth: comboboxWidth
+            comboboxWidth: comboboxWidth,
+            comboBottomMargin: comboBottomMargin
         });
 
         countType = Ext.create('Ext.form.field.ComboBox', {
 			cls: 'ns-combo',
-			style: 'margin-bottom:2px',
+			style: 'margin-bottom:' + comboBottomMargin + 'px',
 			width: comboboxWidth,
 			labelWidth: 130,
 			fieldLabel: NS.i18n.count_type,
@@ -1624,12 +1628,17 @@
 
 		showHierarchy = Ext.create('Ext.form.field.Checkbox', {
 			boxLabel: NS.i18n.show_hierarchy,
-			style: 'margin-bottom:4px'
+			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
+		});
+
+		showDimensionLabels = Ext.create('Ext.form.field.Checkbox', {
+			boxLabel: NS.i18n.show_dimension_labels,
+			style: 'margin-bottom:' + checkboxBottomMargin + 'px',
 		});
 
 		displayDensity = Ext.create('Ext.form.field.ComboBox', {
 			cls: 'ns-combo',
-			style: 'margin-bottom:2px',
+			style: 'margin-top:5px; margin-bottom:' + comboBottomMargin + 'px',
 			width: comboboxWidth,
 			labelWidth: 130,
 			fieldLabel: NS.i18n.display_density,
@@ -1650,7 +1659,7 @@
 
 		fontSize = Ext.create('Ext.form.field.ComboBox', {
 			cls: 'ns-combo',
-			style: 'margin-bottom:2px',
+			style: 'margin-bottom:' + comboBottomMargin + 'px',
 			width: comboboxWidth,
 			labelWidth: 130,
 			fieldLabel: NS.i18n.font_size,
@@ -1672,7 +1681,7 @@
 		digitGroupSeparator = Ext.create('Ext.form.field.ComboBox', {
 			labelStyle: 'color:#333',
 			cls: 'ns-combo',
-			style: 'margin-bottom:2px',
+			style: 'margin-bottom:0',
 			width: comboboxWidth,
 			labelWidth: 130,
 			fieldLabel: NS.i18n.digit_group_separator,
@@ -1728,6 +1737,7 @@
 			bodyStyle: 'border:0 none',
 			style: 'margin-left:14px',
 			items: [
+                showDimensionLabels,
 				displayDensity,
 				fontSize,
 				digitGroupSeparator
@@ -1737,7 +1747,7 @@
 
 		window = Ext.create('Ext.window.Window', {
 			title: NS.i18n.table_options,
-			bodyStyle: 'background-color:#fff; padding:5px 5px 3px',
+			bodyStyle: 'background-color:#fff; padding:3px',
 			closeAction: 'hide',
 			autoShow: true,
 			modal: true,
@@ -1752,6 +1762,7 @@
                     topLimit: limit.getTopLimit(),
 					countType: countType.getValue(),
 					showHierarchy: showHierarchy.getValue(),
+                    showDimensionLabels: showDimensionLabels.getValue(),
 					displayDensity: displayDensity.getValue(),
 					fontSize: fontSize.getValue(),
 					digitGroupSeparator: digitGroupSeparator.getValue()
@@ -1766,6 +1777,7 @@
 				countType.setValue(Ext.isString(layout.countType) ? layout.countType : 'events');
                 //aggregationType.setValue(Ext.isString(layout.aggregationType) ? layout.aggregationType : 'default');
 				showHierarchy.setValue(Ext.isBoolean(layout.showHierarchy) ? layout.showHierarchy : false);
+				showDimensionLabels.setValue(Ext.isBoolean(layout.showDimensionLabels) ? layout.showDimensionLabels : true);
 				displayDensity.setValue(Ext.isString(layout.displayDensity) ? layout.displayDensity : 'normal');
 				fontSize.setValue(Ext.isString(layout.fontSize) ? layout.fontSize : 'normal');
 				digitGroupSeparator.setValue(Ext.isString(layout.digitGroupSeparator) ? layout.digitGroupSeparator : 'space');
@@ -1781,25 +1793,25 @@
 			items: [
 				{
 					bodyStyle: 'border:0 none; color:#222; font-size:12px; font-weight:bold',
-					style: 'margin-bottom:6px; margin-left:2px',
+					style: 'margin-top:2px; margin-bottom:6px; margin-left:3px',
 					html: NS.i18n.data
 				},
 				data,
 				{
-					bodyStyle: 'border:0 none; padding:5px'
+					bodyStyle: 'border:0 none; padding:7px'
 				},
 				{
 					bodyStyle: 'border:0 none; color:#222; font-size:12px; font-weight:bold',
-					style: 'margin-bottom:6px; margin-left:2px',
+					style: 'margin-bottom:6px; margin-left:3px',
 					html: NS.i18n.organisation_units
 				},
 				organisationUnits,
 				{
-					bodyStyle: 'border:0 none; padding:5px'
+					bodyStyle: 'border:0 none; padding:7px'
 				},
 				{
 					bodyStyle: 'border:0 none; color:#222; font-size:12px; font-weight:bold',
-					style: 'margin-bottom:6px; margin-left:2px',
+					style: 'margin-bottom:6px; margin-left:3px',
 					html: NS.i18n.style
 				},
 				style
@@ -1849,6 +1861,7 @@
                     w.limit = limit;
 					w.countType = countType;
 					w.showHierarchy = showHierarchy;
+                    w.showDimensionLabels = showDimensionLabels;
 					w.displayDensity = displayDensity;
 					w.fontSize = fontSize;
 					w.digitGroupSeparator = digitGroupSeparator;
@@ -3465,7 +3478,7 @@
 			load = function(dataElements) {
                 var attributes = attributeStorage[programId],
                     data = Ext.Array.clean([].concat(attributes || [], dataElements || []));
-
+                    
 				dataElementsByStageStore.loadData(data);
 
                 if (layout) {
@@ -3617,11 +3630,10 @@
         });
 
         addUxFromDataElement = function(element, index) {
-			var getUxType,
+			var getUxType,            
 				ux;
 
             element.type = element.type || element.valueType;
-
 			index = index || dataElementSelected.items.items.length;
 
 			getUxType = function(element) {
@@ -6125,7 +6137,7 @@
 					},
 					success: function(r) {
 						var config = Ext.decode(r.responseText);
-
+                        
 						// sync
 						config.showTotals = config.totals;
 						delete config.totals;
@@ -6189,6 +6201,16 @@
 							return;
 						}
 
+                        // add to dimConf, TODO
+                        for (var i = 0, map = dimConf.objectNameMap, header; i < response.headers.length; i++) {
+                            header = response.headers[i];
+                            map[header.name] = map[header.name] || {
+                                id: header.name,
+                                dimensionName: header.name,
+                                name: header.column
+                            };
+                        }
+
                         web.mask.show(ns.app.centerRegion, 'Creating table..');
 
                         ns.app.paramString = paramString;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js	2014-09-01 12:48:09 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js	2014-09-09 10:47:28 +0000
@@ -308,6 +308,8 @@
 
 				// showHierarchy: boolean (false)
 
+                // showDimensionLabels: boolean (false)
+
 				// displayDensity: string ('normal') - 'compact', 'normal', 'comfortable'
 
 				// fontSize: string ('normal') - 'small', 'normal', 'large'
@@ -483,6 +485,7 @@
 
 					layout.showHierarchy = Ext.isBoolean(config.showHierarchy) ? config.showHierarchy : false;
 
+					layout.showDimensionLabels = Ext.isBoolean(config.showDimensionLabels) ? config.showDimensionLabels : (Ext.isBoolean(config.showDimensionLabels) ? config.showDimensionLabels : true);
 					layout.displayDensity = Ext.isString(config.displayDensity) && !Ext.isEmpty(config.displayDensity) ? config.displayDensity : 'normal';
 					layout.fontSize = Ext.isString(config.fontSize) && !Ext.isEmpty(config.fontSize) ? config.fontSize : 'normal';
 					layout.digitGroupSeparator = Ext.isString(config.digitGroupSeparator) && !Ext.isEmpty(config.digitGroupSeparator) ? config.digitGroupSeparator : 'space';
@@ -2058,7 +2061,7 @@
 					htmlArray;
 
 				xResponse.sortableIdObjects = [];
-
+                
 				getRoundedHtmlValue = function(value, dec) {
 					dec = dec || 2;
 					return parseFloat(support.prototype.number.roundIf(value, 2)).toString();
@@ -2171,14 +2174,52 @@
 					var a = [],
 						getEmptyHtmlArray;
 
-					getEmptyHtmlArray = function() {
-						return (xColAxis && xRowAxis) ? getTdHtml({
-							cls: 'pivot-dim-empty cursor-default',
-							colSpan: xRowAxis.dims,
-							rowSpan: xColAxis.dims,
-							htmlValue: '&nbsp;'
-						}) : '';
-					};
+                    getEmptyNameTdConfig = function(config) {
+                        config = config || {};
+
+                        return getTdHtml({
+                            cls: config.cls ? ' ' + config.cls : 'pivot-empty',
+                            colSpan: config.colSpan ? config.colSpan : 1,
+                            rowSpan: config.rowSpan ? config.rowSpan : 1,
+                            htmlValue: config.htmlValue ? config.htmlValue : '&nbsp;'
+                        });
+                    };
+
+                    getEmptyHtmlArray = function(i) {
+                        var a = [];
+
+                        if (i < xColAxis.dims - 1) {
+                            if (xRowAxis && xRowAxis.dims) {
+                                for (var j = 0; j < xRowAxis.dims - 1; j++) {
+                                    a.push(getEmptyNameTdConfig({
+                                        cls: 'pivot-dim-label'
+                                    }));
+                                }
+                            }
+
+                            a.push(getEmptyNameTdConfig({
+                                cls: 'pivot-dim-label',
+                                htmlValue: '&nbsp;&nbsp;' + dimConf.objectNameMap[xLayout.columnObjectNames[i]].name
+                            }));
+                        }
+                        else {
+                            if (xRowAxis && xRowAxis.dims) {                                
+                                for (var j = 0; j < xRowAxis.dims - 1; j++) {
+                                    a.push(getEmptyNameTdConfig({
+                                        cls: 'pivot-dim-label',
+                                        htmlValue: dimConf.objectNameMap[xLayout.rowObjectNames[j]].name
+                                    }));
+                                }
+                            }
+
+                            a.push(getEmptyNameTdConfig({
+                                cls: 'pivot-dim-label',
+                                htmlValue: dimConf.objectNameMap[xLayout.rowObjectNames[j]].name + ', ' + dimConf.objectNameMap[xLayout.columnObjectNames[i]].name
+                            }));
+                        }
+
+                        return a;
+                    };
 
 					if (!(xColAxis && Ext.isObject(xColAxis))) {
 						return a;
@@ -2188,8 +2229,14 @@
 					for (var i = 0, dimHtml; i < xColAxis.dims; i++) {
 						dimHtml = [];
 
-						if (i === 0) {
-							dimHtml.push(getEmptyHtmlArray());
+                        if (xLayout.showDimensionLabels) {
+                            dimHtml = dimHtml.concat(getEmptyHtmlArray(i));
+                        }
+                        else if (i === 0) {
+							dimHtml.push(xColAxis && xRowAxis ? getEmptyNameTdConfig({
+                                colSpan: xRowAxis.dims,
+                                rowSpan: xColAxis.dims
+                            }) : '');
 						}
 
 						for (var j = 0, obj, spanCount = 0, condoId, totalId; j < xColAxis.size; j++) {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css	2014-08-25 09:12:15 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css	2014-09-09 10:28:12 +0000
@@ -167,6 +167,13 @@
 .align-left {
 	text-align: left !important;
 }
+.align-right {
+	text-align: right !important;
+}
+
+.font-size-0 {
+    font-size: 0 !important;
+}
 
 .ns-form-item-label-top {
 	padding-left: 2px;
@@ -240,9 +247,14 @@
 	background-color: #adb8c9;
 }
 
-.pivot-dim-empty {
+.pivot-dim-label {
+	background-color: #f7f9fD;
+	white-space: nowrap;
+    text-align: center;
+}
+
+.pivot-empty {
 	background-color: #dae6f8;
-	text-align: center;
 }
 
 .pivot-value {