← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11275: (PT) dx/dc/co issue fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 11275 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-06-28 12:43:28 +0200
message:
  (PT) dx/dc/co issue fixed.
modified:
  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


--
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-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-06-27 16:41:44 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-06-28 10:42:07 +0000
@@ -3846,6 +3846,12 @@
 					return;
 				}
 
+				// dc and co
+				if (objectNameDimensionMap[dimConf.operand.objectName] && objectNameDimensionMap[dimConf.category.objectName]) {
+					alert('Categories and detailed data elements cannot be specified together');
+					return;
+				}
+
 				// Degs and datasets in the same query
 				//if (Ext.Array.contains(dimensionNames, dimConf.data.dimensionName) && pt.store.dataSetSelected.data.length) {
 					//for (var i = 0; i < pt.init.degs.length; i++) {

=== 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-06-26 16:11:35 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-06-28 10:42:07 +0000
@@ -738,7 +738,8 @@
 				dimConf = pt.conf.finals.dimension,
 				addCategoryDimension = false,
 				map = xLayout.dimensionNameItemsMap,
-				dx = dimConf.indicator.dimensionName;
+				dx = dimConf.indicator.dimensionName,
+				co = dimConf.category.dimensionName;
 
 			for (var i = 0, dimName, items; i < axisDimensionNames.length; i++) {
 				dimName = axisDimensionNames[i];
@@ -759,8 +760,8 @@
 
 					items = Ext.Array.unique(items);
 				}
-
-				if (dimName !== dimConf.category.dimensionName) {
+				
+				if (dimName !== co) {
 					paramString += ':' + items.join(';');
 				}
 
@@ -768,7 +769,7 @@
 					paramString += '&';
 				}
 			}
-
+			
 			if (addCategoryDimension) {
 				paramString += '&dimension=' + pt.conf.finals.dimension.category.dimensionName;
 			}
@@ -970,6 +971,8 @@
 				var createValueIdMap = function() {
 					var valueHeaderIndex = response.nameHeaderMap[pt.conf.finals.dimension.value.value].index,
 						coHeader = response.nameHeaderMap[pt.conf.finals.dimension.category.dimensionName],
+						dx = dimConf.data.dimensionName,
+						co = dimConf.category.dimensionName,
 						axisDimensionNames = xLayout.axisDimensionNames,
 						idIndexOrder = [];
 
@@ -977,8 +980,8 @@
 					for (var i = 0; i < axisDimensionNames.length; i++) {
 						idIndexOrder.push(response.nameHeaderMap[axisDimensionNames[i]].index);
 
-						// If co exists in response, add co after dx
-						if (coHeader && axisDimensionNames[i] === pt.conf.finals.dimension.data.dimensionName) {
+						// If co exists in response and is not added in layout, add co after dx
+						if (coHeader && !Ext.Array.contains(axisDimensionNames, co) && axisDimensionNames[i] === dx) {
 							idIndexOrder.push(coHeader.index);
 						}
 					}
@@ -1462,17 +1465,17 @@
 					}
 
 					// Value objects
-					for (var i = 0, valueItemsRow, valueObjectsRow, map = Ext.clone(xResponse.idValueMap); i < rowSize; i++) {
+					for (var i = 0, valueItemsRow, valueObjectsRow, idValueMap = Ext.clone(xResponse.idValueMap); i < rowSize; i++) {
 						valueItemsRow = [];
 						valueObjectsRow = [];
 
 						for (var j = 0, id, value, htmlValue, empty; j < colSize; j++) {
 							id = (xColAxis ? pt.util.str.replaceAll(xColAxis.ids[j], '-', '') : '') + (xRowAxis ? pt.util.str.replaceAll(xRowAxis.ids[i], '-', '') : '');
 							empty = false;
-							
-							if (map[id]) {
-								value = parseFloat(map[id]);
-								htmlValue = pt.util.number.roundIf(map[id], 1).toString();
+console.log(id);							
+							if (idValueMap[id]) {
+								value = parseFloat(idValueMap[id]);
+								htmlValue = pt.util.number.roundIf(idValueMap[id], 1).toString();
 							}
 							else {
 								value = 0;
@@ -1963,9 +1966,8 @@
 					alert(r.responseText);
 				},
 				success: function(r) {
-					var layoutConfig = Ext.decode(r.responseText);
-
-					var	layout = pt.api.layout.Layout(layoutConfig);
+					var layoutConfig = Ext.decode(r.responseText),
+						layout = pt.api.layout.Layout(layoutConfig);
 
 					if (layout) {
 						pt.favorite = Ext.clone(layout);