← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11016: (PT) Orgunit order issue fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 11016 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-05-27 15:08:55 +0200
message:
  (PT) Orgunit order 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-05-23 13:06:37 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-05-27 12:22:12 +0000
@@ -1210,7 +1210,7 @@
 
 					if (id && name) {
 						Ext.Ajax.request({
-							url: pt.baseUrl + '/api/reportTables/' + id + '.json?links=false',
+							url: pt.baseUrl + '/api/reportTables/' + id + '.json?viewClass=dimensional&links=false',
 							method: 'GET',
 							failure: function(r) {
 								pt.viewport.mask.show();
@@ -3777,7 +3777,7 @@
 
 						if (recMap[key]) {
 							s.add(recMap[key]);
-							dv.util.multiselect.filterAvailable({store: a}, {store: s});
+							pt.util.multiselect.filterAvailable({store: a}, {store: s});
 						}
 					}
 				}

=== 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-05-23 18:19:04 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-05-27 13:05:57 +0000
@@ -759,22 +759,44 @@
 
 				return function() {
 					var headerNames = getHeaderNames(),
+						xOuDimension = xLayout.objectNameDimensionsMap[dimConf.organisationUnit.objectName],
+						isUserOrgunit = xOuDimension && Ext.Array.contains(xOuDimension.items, 'USER_ORGUNIT'),
+						isUserOrgunitChildren = xOuDimension && Ext.Array.contains(xOuDimension.items, 'USER_ORGUNIT_CHILDREN'),
 						co = dimConf.category.objectName,
+						ou = dimConf.organisationUnit.objectName,
 						layout;
 
-					// Use metaData ids if any
+					// Set items from init/metaData/xLayout
 					for (var i = 0, dim, metaDataDim, items; i < dimensions.length; i++) {
 						dim = dimensions[i];
+						dim.items = [];
 						metaDataDim = response.metaData[dim.objectName];
 
-						if (Ext.isArray(metaDataDim)) {
-							items = [];
-
-							for (var j = 0; j < metaDataDim.length; j++) {
-								items.push({id: metaDataDim[j]});
-							}
-
-							dim.items = items;
+						// If ou and children
+						if (dim.dimensionName === ou) {
+							if (isUserOrgunit || isUserOrgunitChildren) {
+								if (isUserOrgunit) {
+									dim.items = dim.items.concat(pt.init.user.ou);
+								}
+								if (isUserOrgunitChildren) {
+									dim.items = dim.items.concat(pt.init.user.ouc);
+								}
+							}
+							else {
+								dim.items = Ext.clone(xLayout.dimensionNameItemsMap[dim.dimensionName]);
+							}
+						}
+						else {
+							// Items: get ids from metadata -> items
+							if (Ext.isArray(metaDataDim) && dim.dimensionName !== dimConf.organisationUnit.dimensionName) {
+								for (var j = 0, ids = Ext.clone(response.metaData[dim.dimensionName]); j < ids.length; j++) {
+									dim.items.push({id: ids[j]});
+								}
+							}
+							// Items: get items from xLayout
+							else {
+								dim.items = Ext.clone(xLayout.dimensionNameItemsMap[dim.dimensionName]);
+							}
 						}
 					}
 
@@ -857,20 +879,14 @@
 
 						if (header.meta) {
 
-							// Items: get ids from metadata
-							if (Ext.isArray(response.metaData[header.name])) {
-								header.items = Ext.clone(response.metaData[header.name]);
-							}
-							// Items: get ids from xLayout
-							else {
-								header.items = xLayout.dimensionNameIdsMap[header.name];
-							}
-
-							// Collect ids
-							ids = ids.concat(header.items);
+							// Items
+							header.items = Ext.clone(xLayout.dimensionNameIdsMap[header.name]);
 
 							// Size
 							header.size = header.items.length;
+
+							// Collect ids, used by extendMetaData
+							ids = ids.concat(header.items);
 						}
 					}
 
@@ -1985,7 +2001,10 @@
 		return function() {
 			var a = [],
 				objectNames = [],
-				dimConf = pt.conf.finals.dimension;
+				dimConf = pt.conf.finals.dimension,
+				dims,
+				isOu = false,
+				isOuc = false;
 
 			config.columns = getValidatedDimensionArray(config.columns);
 			config.rows = getValidatedDimensionArray(config.rows);
@@ -2016,6 +2035,22 @@
 				return;
 			}
 
+			dims = [].concat(config.columns, config.rows, config.filters);
+			for (var i = 0, dim; i < dims.length; i++) {
+				dim = dims[i];
+
+				if (dim) {
+					for (var j = 0; j < dims[i].items.length; j++) {
+						if (dims[i].items[j].id === 'USER_ORGUNIT') {
+							isOu = true;
+						}
+						else if (dims[i].items[j].id === 'USER_ORGUNIT_CHILDREN') {
+							isOuc = true;
+						}
+					}
+				}
+			}
+
 			// Layout
 			layout.columns = config.columns;
 			layout.rows = config.rows;
@@ -2030,8 +2065,8 @@
 			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';
 
-			layout.userOrganisationUnit = Ext.isBoolean(config.userOrganisationUnit) ? config.userOrganisationUnit : false;
-			layout.userOrganisationUnitChildren = Ext.isBoolean(config.userOrganisationUnitChildren) ? config.userOrganisationUnitChildren : false;
+			layout.userOrganisationUnit = isOu;
+			layout.userOrganisationUnitChildren = isOuc;
 
 			layout.parentGraphMap = Ext.isObject(config.parentGraphMap) ? config.parentGraphMap : undefined;