← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9788: (PT) Support for misc special cases.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 9788 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-02-12 13:22:04 +0100
message:
  (PT) Support for misc special cases.
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-02-11 10:31:27 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-02-12 12:15:42 +0000
@@ -623,6 +623,7 @@
 				width: (pt.conf.layout.west_fieldset_width - pt.conf.layout.west_width_padding) / 2,
 				valueField: 'id',
 				displayField: 'name',
+				ddReorder: true,
 				store: pt.store.indicatorSelected,
 				tbar: [
 					{
@@ -1312,7 +1313,7 @@
 				height: 180,
 				valueField: 'id',
 				displayField: 'name',
-				ddReorder: false,
+				ddReorder: true,
 				store: pt.store.fixedPeriodSelected,
 				tbar: [
 					' ',
@@ -1983,10 +1984,31 @@
 				return getPanels();
 			};
 
+			validateSpecialCases = function(settings) {
+				// indicator as filter
+				if (settings.filter && pt.store.indicatorSelected.data.length) {
+					for (var i = 0; i < settings.filter.length; i++) {
+						if (settings.filter[i].name === 'dx') {
+							alert('Indicators not accepted as filter');
+							return;
+						}
+					}
+				}
+
+				return true;
+			};
+
 			update = function() {
 				var config = pt.util.pivot.getSettingsConfig(),
 					settings = pt.api.Settings(config);
 
+				if (!settings) {
+					return;
+				}
+				if (!validateSpecialCases(settings)) {
+					return;
+				}
+					
 				if (settings) {
 					pt.util.pivot.getTable(settings, pt, centerRegion);
 				}

=== 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-02-12 08:27:56 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2013-02-12 12:15:42 +0000
@@ -480,6 +480,73 @@
 				
 				return xSettings;
 			};
+
+			getSyncedXSettings = function(xSettings, response) {
+				var getHeaderNames,
+				
+					headerNames,
+					newSettings;
+
+				getHeaderNames = function() {
+					var a = [];
+
+					for (var i = 0; i < response.headers.length; i++) {
+						a.push(response.headers[i].name);
+					}
+
+					return a;
+				};
+
+				removeDimensionFromSettings = function(dimensionName) {
+					var getCleanAxis;
+
+					getAxis = function(axis) {
+						var axis = Ext.clone(axis),
+							dimension;
+						
+						for (var i = 0; i < axis.length; i++) {
+							if (axis[i].name === dimensionName) {
+								dimension = axis[i];
+							}
+						}
+
+						if (dimension) {
+							Ext.Array.remove(axis, dimension);
+						}
+
+						return axis;
+					};
+
+					if (settings.col) {
+						settings.col = getAxis(settings.col);
+					}
+					if (settings.row) {
+						settings.row = getAxis(settings.row);
+					}
+					if (settings.filter) {
+						settings.filter = getAxis(settings.filter);
+					}						
+				};
+				
+				headerNames = getHeaderNames();
+				
+				// remove coc from settings if it does not exist in response
+				if (Ext.Array.contains(xSettings.dimensionNames, 'coc') && !(Ext.Array.contains(headerNames, 'coc'))) {
+					removeDimensionFromSettings('coc');
+					
+					newSettings = pt.api.Settings(settings);
+
+					if (!newSettings) {
+						return;
+					}
+
+					return extendSettings(newSettings);
+				}
+				else {
+					return xSettings;
+				}
+			};
+				
 			
 			getParamString = function(xSettings) {
 				var sortedDimensions = xSettings.sortedDimensions,
@@ -546,7 +613,7 @@
 				response.idValueMap = {};
 
 				var extendHeaders = function() {
-					var dimensions = xSettings.dimensions;
+					//var dimensions = xSettings.dimensions;
 
 					// Extend headers: index, items (ordered), size
 					for (var i = 0, header, settingsItems, responseItems, orderedResponseItems; i < headers.length; i++) {
@@ -1079,6 +1146,13 @@
 response.metaData['PT59n8BQbqM'] = '(Outreach)';
 response.metaData['pq2XI5kz2BY'] = '(Fixed)';
 
+						xSettings = getSyncedXSettings(xSettings, response);
+
+						if (!xSettings) {
+							pt.util.mask.hideMask();
+							return;
+						}
+
 						xResponse = extendResponse(response, xSettings);
 
 						xColAxis = extendAxis(xSettings.col, xResponse);