← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12392: (GIS) Startup performance improved + Several minor bugs fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 12392 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-02 15:39:15 +0200
message:
  (GIS) Startup performance improved + Several minor bugs fixed.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/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-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java	2013-09-20 13:43:24 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java	2013-10-02 12:46:52 +0000
@@ -104,7 +104,7 @@
         return callback;
     }
 
-    private Collection<OrganisationUnit> object;
+    private Collection<OrganisationUnit> object = new ArrayList<OrganisationUnit>();
 
     public Collection<OrganisationUnit> getObject()
     {
@@ -127,10 +127,6 @@
     {
         groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
 
-        // ---------------------------------------------------------------------
-        // Check if modified for caching purposes
-        // ---------------------------------------------------------------------
-
         Set<OrganisationUnitGroup> groups = new HashSet<OrganisationUnitGroup>();
         
         for ( OrganisationUnitGroupSet groupSet : groupSets )
@@ -139,9 +135,9 @@
         }
         
         // ---------------------------------------------------------------------
-        // Retrieve list of organisation units and populate group names
+        // Retrieve list of organisation units with valid coordinates
         // ---------------------------------------------------------------------
-        
+
         String paramString = "ou:";
         
         for ( String id : ids )
@@ -170,7 +166,7 @@
         cachingCollection.addAll( organisationUnits );
         
         boolean modified = !clearIfNotModified( ServletActionContext.getRequest(), ServletActionContext.getResponse(), cachingCollection );
-        
+
         if ( !modified )
         {
             return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2013-09-30 12:45:28 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2013-10-02 13:24:33 +0000
@@ -551,24 +551,28 @@
 			layer.menu = GIS.app.LayerMenu(layer, 'gis-toolbar-btn-menu-first');
 			layer.widget = GIS.app.LayerWidgetFacility(layer);
 			layer.window = GIS.app.WidgetWindow(layer);
+			layer.window.widget = layer.widget;
 			GIS.core.createSelectHandlers(gis, layer);
 
 			layer = gis.layer.boundary;
 			layer.menu = GIS.app.LayerMenu(layer);
 			layer.widget = GIS.app.LayerWidgetBoundary(layer);
 			layer.window = GIS.app.WidgetWindow(layer);
+			layer.window.widget = layer.widget;
 			GIS.core.createSelectHandlers(gis, layer);
 
 			layer = gis.layer.thematic1;
 			layer.menu = GIS.app.LayerMenu(layer);
 			layer.widget = GIS.app.LayerWidgetThematic(layer);
 			layer.window = GIS.app.WidgetWindow(layer);
+			layer.window.widget = layer.widget;
 			GIS.core.createSelectHandlers(gis, layer);
 
 			layer = gis.layer.thematic2;
 			layer.menu = GIS.app.LayerMenu(layer);
 			layer.widget = GIS.app.LayerWidgetThematic(layer);
 			layer.window = GIS.app.WidgetWindow(layer);
+			layer.window.widget = layer.widget;
 			GIS.core.createSelectHandlers(gis, layer);
 
 			layer = gis.layer.thematic3;
@@ -581,6 +585,7 @@
 			layer.menu = GIS.app.LayerMenu(layer);
 			layer.widget = GIS.app.LayerWidgetThematic(layer);
 			layer.window = GIS.app.WidgetWindow(layer);
+			layer.window.widget = layer.widget;
 			GIS.core.createSelectHandlers(gis, layer);
 		}());
 	};
@@ -601,22 +606,22 @@
 			getValue: function() {
 				return this.checkbox.getValue();
 			},
-			setValue: function(value, opacity) {
+			setValue: function(value, opacity) {				
 				this.checkbox.setValue(value);
 				this.numberField.setDisabled(!value);
 				this.layer.setVisibility(value);
+				
+				if (value) {
+					opacity = Ext.isNumber(parseFloat(opacity)) ? parseFloat(opacity) : this.opacity;
 
-				if (opacity === 0) {
-					this.numberField.setValue(0);
-					this.setOpacity(0.01);
-				}
-				else if (opacity > 0) {
-					this.numberField.setValue(opacity * 100);
-					this.setOpacity(opacity);
-				}
-				else {
-					this.numberField.setValue(this.opacity * 100);
-					this.setOpacity(this.opacity);
+					if (opacity === 0) {
+						this.numberField.setValue(0);
+						this.setOpacity(0.01);
+					}
+					else {
+						this.numberField.setValue(opacity * 100);
+						this.setOpacity(opacity);
+					}
 				}
 			},
 			getOpacity: function() {
@@ -997,7 +1002,7 @@
 
 	GIS.app.WidgetWindow = function(layer) {
 		return Ext.create('Ext.window.Window', {
-			autoShow: true,
+			//autoShow: true,
 			title: layer.name,
 			layout: 'fit',
 			iconCls: 'gis-window-title-icon-' + layer.id,
@@ -1029,11 +1034,13 @@
 				show: function() {
 					if (!this.isRendered) {
 						this.isRendered = true;
-						this.hide();
-					}
-					else {
-						gis.util.gui.window.setPositionTopLeft(this);
-					}
+						
+						if (this.view) {
+							this.widget.setGui(this.view);
+						}
+					}
+					
+					gis.util.gui.window.setPositionTopLeft(this);
 				}
 			}
 		});
@@ -2156,7 +2163,7 @@
 												view = layer.core.view;
 
 												// add
-												view.layer = layer[record.data.id];
+												view.layer = layer.id;
 
 												// remove
 												delete view.periodType;
@@ -3634,7 +3641,7 @@
 		toolMenu = Ext.create('Ext.menu.Menu', {
 			shadow: false,
 			showSeparator: false,
-			menuValue: 'orgunit',
+			menuValue: 'level',
 			clickHandler: function(param) {
 				if (!param) {
 					return;
@@ -3733,11 +3740,21 @@
 
 		// Functions
 
-		reset = function() {
+		reset = function(skipTree) {
+
+			// Item
+			layer.item.setValue(false);
+			
+			if (!layer.window.isRendered) {
+				return;
+			}
 
 			// Components
-			toolMenu.clickHandler('orgunit');
-			treePanel.reset();
+			toolMenu.clickHandler(toolMenu.menuValue);
+			
+			if (!skipTree) {
+				treePanel.reset();
+			}
 			
 			userOrganisationUnit.setValue(false);
 			userOrganisationUnitChildren.setValue(false);
@@ -3755,9 +3772,6 @@
 				layer.labelWindow.destroy();
 				layer.labelWindow = null;
 			}
-
-			// Item
-			layer.item.setValue(false);
 		};
 
 		setGui = function(view) {
@@ -3766,57 +3780,73 @@
 				isOuc = false,
 				isOugc = false,
 				levels = [],
-				groups = [];
-
-			// Organisation units
-			for (var i = 0, item; i < ouDim.items.length; i++) {
-				item = ouDim.items[i];
-				
-				if (item.id === 'USER_ORGUNIT') {
-					isOu = true;
-				}
-				else if (item.id === 'USER_ORGUNIT_CHILDREN') {
-					isOuc = true;
-				}
-				else if (item.id === 'USER_ORGUNIT_GRANDCHILDREN') {
-					isOugc = true;
-				}
-				else if (item.id.substr(0,5) === 'LEVEL') {
-					levels.push(parseInt(item.id.split('-')[1]));
-				}
-				else if (item.id.substr(0,8) === 'OU_GROUP') {
-					groups.push(parseInt(item.id.split('-')[1]));
-				}
-			}
-
-			if (levels.length) {
-				toolMenu.clickHandler('level');
-				organisationUnitLevel.setValue(levels);
-			}
-			else if (groups.length) {
-				toolMenu.clickHandler('group');
-				organisationUnitGroup.setValue(groups);
-			}
-			else {
-				toolMenu.clickHandler('orgunit');
-				userOrganisationUnit.setValue(isOu);
-				userOrganisationUnitChildren.setValue(isOuc);
-				userOrganisationUnitGrandChildren.setValue(isOugc);
-			}
-			
-			treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
-			
-			for (var key in view.parentGraphMap) {
-				if (view.parentGraphMap.hasOwnProperty(key)) {
-					treePanel.multipleExpand(key, view.parentGraphMap[key], false);
-				}
-			}
-
-			// Layer item
-			layer.item.setValue(true, view.opacity);
-
-			// Layer menu
-			layer.menu.enableItems();
+				groups = [],
+				setWidgetGui,
+				setLayerGui;
+				
+			setWidgetGui = function() {
+				
+				// Components			
+				if (!layer.window.isRendered) {
+					layer.window.view = view;
+					return;
+				}
+				
+				reset(true);
+
+				// Organisation units
+				for (var i = 0, item; i < ouDim.items.length; i++) {
+					item = ouDim.items[i];
+					
+					if (item.id === 'USER_ORGUNIT') {
+						isOu = true;
+					}
+					else if (item.id === 'USER_ORGUNIT_CHILDREN') {
+						isOuc = true;
+					}
+					else if (item.id === 'USER_ORGUNIT_GRANDCHILDREN') {
+						isOugc = true;
+					}
+					else if (item.id.substr(0,5) === 'LEVEL') {
+						levels.push(parseInt(item.id.split('-')[1]));
+					}
+					else if (item.id.substr(0,8) === 'OU_GROUP') {
+						groups.push(parseInt(item.id.split('-')[1]));
+					}
+				}
+
+				if (levels.length) {
+					toolMenu.clickHandler('level');
+					organisationUnitLevel.setValue(levels);
+				}
+				else if (groups.length) {
+					toolMenu.clickHandler('group');
+					organisationUnitGroup.setValue(groups);
+				}
+				else {
+					toolMenu.clickHandler('orgunit');
+					userOrganisationUnit.setValue(isOu);
+					userOrganisationUnitChildren.setValue(isOuc);
+					userOrganisationUnitGrandChildren.setValue(isOugc);
+				}
+				
+				treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
+				
+				for (var key in view.parentGraphMap) {
+					if (view.parentGraphMap.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, view.parentGraphMap[key], false);
+					}
+				}
+			}();
+			
+			setLayerGui = function() {
+
+				// Layer item
+				layer.item.setValue(true, view.opacity);
+
+				// Layer menu
+				layer.menu.enableItems();
+			}();
 		};
 
 		getView = function(config) {
@@ -3883,7 +3913,12 @@
 						treePanel
 					]
 				}
-			]
+			],
+			listeners: {
+				render: function() {
+					toolMenu.clickHandler('level');
+				}
+			}
 		});
 
 		//createSelectHandlers();
@@ -4889,7 +4924,6 @@
 			displayField: 'name',
 			emptyText: GIS.i18n.select_organisation_unit_levels,
 			editable: false,
-			hidden: true,
 			store: {
 				fields: ['id', 'name', 'level'],
 				data: gis.init.organisationUnitLevels
@@ -4905,14 +4939,13 @@
 			displayField: 'name',
 			emptyText: GIS.i18n.select_organisation_unit_groups,
 			editable: false,
-			hidden: true,
 			store: gis.store.organisationUnitGroup
 		});
 
 		toolMenu = Ext.create('Ext.menu.Menu', {
 			shadow: false,
 			showSeparator: false,
-			menuValue: 'orgunit',
+			menuValue: 'level',
 			clickHandler: function(param) {
 				if (!param) {
 					return;
@@ -5070,7 +5103,28 @@
 
 		reset = function(skipTree) {
 
-			// Components
+			// Item
+			layer.item.setValue(false);
+
+			// Layer options
+			if (layer.searchWindow) {
+				layer.searchWindow.destroy();
+				layer.searchWindow = null;
+			}
+			if (layer.filterWindow) {
+				layer.filterWindow.destroy();
+				layer.filterWindow = null;
+			}
+			if (layer.labelWindow) {
+				layer.labelWindow.destroy();
+				layer.labelWindow = null;
+			}
+
+			// Components			
+			if (!layer.window.isRendered) {
+				return;
+			}
+			
 			valueType.reset();
 			valueTypeToggler(dimConf.indicator.objectName);
 
@@ -5101,10 +5155,9 @@
 			radiusLow.reset();
 			radiusHigh.reset();
 			
-			toolMenu.clickHandler('orgunit');
+			toolMenu.clickHandler(toolMenu.menuValue);
 			
 			if (!skipTree) {
-				toolMenu.clickHandler('orgunit');
 				treePanel.reset();
 			}
 			
@@ -5114,23 +5167,6 @@
 			
 			organisationUnitLevel.clearValue();
 			organisationUnitGroup.clearValue();
-
-			// Layer options
-			if (layer.searchWindow) {
-				layer.searchWindow.destroy();
-				layer.searchWindow = null;
-			}
-			if (layer.filterWindow) {
-				layer.filterWindow.destroy();
-				layer.filterWindow = null;
-			}
-			if (layer.labelWindow) {
-				layer.labelWindow.destroy();
-				layer.labelWindow = null;
-			}
-
-			// Item
-			layer.item.setValue(false);
 		};
 
 		setGui = function(view) {
@@ -5144,103 +5180,117 @@
 				isOuc = false,
 				isOugc = false,
 				levels = [],
-				groups = [];
+				groups = [],
+				setLayerGui,
+				setWidgetGui;
 				
 			objectNameCmpMap[dimConf.indicator.objectName] = indicator;
 			objectNameCmpMap[dimConf.dataElement.objectName] = dataElement;
 			objectNameCmpMap[dimConf.operand.objectName] = dataElement;
 			objectNameCmpMap[dimConf.dataSet.objectName] = dataSet;
 			
-			// Reset
-			reset(true);
-
-			// Value type
-			valueType.setValue(vType);
-			valueTypeToggler(vType);			
-			
-			if (vType === dimConf.dataElement.objectName) {
-				dataElementDetailLevel.setValue(dxDim.dimension);
-			}
-			
-			// Data
-			objectNameCmpMap[dxDim.dimension].store.add(dxDim.items[0]);
-			objectNameCmpMap[dxDim.dimension].setValue(dxDim.items[0].id);
-			
-			// Period
-			period.store.add(peDim.items[0])
-			period.setValue(peDim.items[0].id);
-			
-			// Legend
-			legendType.setValue(lType);
-			legendTypeToggler(lType);
-			
-			if (lType === gis.conf.finals.widget.legendtype_automatic) {
-				classes.setValue(view.classes);
-				method.setValue(view.method);
-				colorLow.setValue(view.colorLow);
-				colorHigh.setValue(view.colorHigh);
-				radiusLow.setValue(view.radiusLow);
-				radiusHigh.setValue(view.radiusHigh);
-			}
-			else if (lType === gis.conf.finals.widget.legendtype_predefined) {
-				legendSet.store.add(view.legendSet);
-				legendSet.setValue(view.legendSet.id);
-			}
-
-			// Organisation units
-			for (var i = 0, item; i < ouDim.items.length; i++) {
-				item = ouDim.items[i];
-				
-				if (item.id === 'USER_ORGUNIT') {
-					isOu = true;
-				}
-				else if (item.id === 'USER_ORGUNIT_CHILDREN') {
-					isOuc = true;
-				}
-				else if (item.id === 'USER_ORGUNIT_GRANDCHILDREN') {
-					isOugc = true;
-				}
-				else if (item.id.substr(0,5) === 'LEVEL') {
-					levels.push(parseInt(item.id.split('-')[1]));
-				}
-				else if (item.id.substr(0,8) === 'OU_GROUP') {
-					groups.push(parseInt(item.id.split('-')[1]));
-				}
-			}
-
-			if (levels.length) {
-				toolMenu.clickHandler('level');
-				organisationUnitLevel.setValue(levels);
-			}
-			else if (groups.length) {
-				toolMenu.clickHandler('group');
-				organisationUnitGroup.setValue(groups);
-			}
-			else {
-				toolMenu.clickHandler('orgunit');
-				userOrganisationUnit.setValue(isOu);
-				userOrganisationUnitChildren.setValue(isOuc);
-				userOrganisationUnitGrandChildren.setValue(isOugc);
-			}
-			
-			treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
-			
-			for (var key in view.parentGraphMap) {
-				if (view.parentGraphMap.hasOwnProperty(key)) {
-					treePanel.multipleExpand(key, view.parentGraphMap[key], false);
-				}
-			}
-
-			// Layer item
-			layer.item.setValue(true, view.opacity);
-
-			// Layer menu
-			layer.menu.enableItems();
-
-			// Filter
-			if (layer.filterWindow && layer.filterWindow.isVisible()) {
-				layer.filterWindow.filter();
-			}
+			setWidgetGui = function() {
+				
+				// Components			
+				if (!layer.window.isRendered) {
+					layer.window.view = view;
+					return;
+				}
+				
+				// Reset
+				reset(true);
+
+				// Value type
+				valueType.setValue(vType);
+				valueTypeToggler(vType);			
+				
+				if (vType === dimConf.dataElement.objectName) {
+					dataElementDetailLevel.setValue(dxDim.dimension);
+				}
+				
+				// Data
+				objectNameCmpMap[dxDim.dimension].store.add(dxDim.items[0]);
+				objectNameCmpMap[dxDim.dimension].setValue(dxDim.items[0].id);
+				
+				// Period
+				period.store.add(peDim.items[0])
+				period.setValue(peDim.items[0].id);
+				
+				// Legend
+				legendType.setValue(lType);
+				legendTypeToggler(lType);
+				
+				if (lType === gis.conf.finals.widget.legendtype_automatic) {
+					classes.setValue(view.classes);
+					method.setValue(view.method);
+					colorLow.setValue(view.colorLow);
+					colorHigh.setValue(view.colorHigh);
+					radiusLow.setValue(view.radiusLow);
+					radiusHigh.setValue(view.radiusHigh);
+				}
+				else if (lType === gis.conf.finals.widget.legendtype_predefined) {
+					legendSet.store.add(view.legendSet);
+					legendSet.setValue(view.legendSet.id);
+				}
+
+				// Organisation units
+				for (var i = 0, item; i < ouDim.items.length; i++) {
+					item = ouDim.items[i];
+					
+					if (item.id === 'USER_ORGUNIT') {
+						isOu = true;
+					}
+					else if (item.id === 'USER_ORGUNIT_CHILDREN') {
+						isOuc = true;
+					}
+					else if (item.id === 'USER_ORGUNIT_GRANDCHILDREN') {
+						isOugc = true;
+					}
+					else if (item.id.substr(0,5) === 'LEVEL') {
+						levels.push(parseInt(item.id.split('-')[1]));
+					}
+					else if (item.id.substr(0,8) === 'OU_GROUP') {
+						groups.push(parseInt(item.id.split('-')[1]));
+					}
+				}
+
+				if (levels.length) {
+					toolMenu.clickHandler('level');
+					organisationUnitLevel.setValue(levels);
+				}
+				else if (groups.length) {
+					toolMenu.clickHandler('group');
+					organisationUnitGroup.setValue(groups);
+				}
+				else {
+					toolMenu.clickHandler('orgunit');
+					userOrganisationUnit.setValue(isOu);
+					userOrganisationUnitChildren.setValue(isOuc);
+					userOrganisationUnitGrandChildren.setValue(isOugc);
+				}
+				
+				treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
+				
+				for (var key in view.parentGraphMap) {
+					if (view.parentGraphMap.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, view.parentGraphMap[key], false);
+					}
+				}
+			}();
+			
+			setLayerGui = function() {
+
+				// Layer item
+				layer.item.setValue(true, view.opacity);
+
+				// Layer menu
+				layer.menu.enableItems();
+
+				// Filter
+				if (layer.filterWindow && layer.filterWindow.isVisible()) {
+					layer.filterWindow.filter();
+				}
+			}();			
 		};
 
 		getView = function(config) {
@@ -5352,7 +5402,12 @@
 						treePanel
 					]
 				}
-			]
+			],
+			listeners: {
+				render: function() {
+					toolMenu.clickHandler('level');
+				}
+			}
 		});
 
 		//createSelectHandlers();
@@ -5715,7 +5770,7 @@
 		toolMenu = Ext.create('Ext.menu.Menu', {
 			shadow: false,
 			showSeparator: false,
-			menuValue: 'orgunit',
+			menuValue: 'level',
 			clickHandler: function(param) {
 				if (!param) {
 					return;
@@ -5819,22 +5874,10 @@
 
 		// Functions
 
-		reset = function() {
-
-			// Components
-			groupSet.clearValue();
-			
-			toolMenu.clickHandler('orgunit');
-			treePanel.reset();
-			
-			userOrganisationUnit.setValue(false);
-			userOrganisationUnitChildren.setValue(false);
-			userOrganisationUnitGrandChildren.setValue(false);
-			
-			organisationUnitLevel.clearValue();
-			organisationUnitGroup.clearValue();
-
-			areaRadius.reset();
+		reset = function(skipTree) {
+
+			// Item
+			layer.item.setValue(false, layer.item.defaultOpacity);
 
 			// Layer
 			if (layer.searchWindow) {
@@ -5855,8 +5898,27 @@
 				layer.circleLayer = null;
 			}
 
-			// Item
-			layer.item.setValue(false, layer.item.defaultOpacity);
+			// Components			
+			if (!layer.window.isRendered) {
+				return;
+			}
+			
+			groupSet.clearValue();
+			
+			toolMenu.clickHandler(toolMenu.menuValue);
+			
+			if (!skipTree) {
+				treePanel.reset();
+			}
+			
+			userOrganisationUnit.setValue(false);
+			userOrganisationUnitChildren.setValue(false);
+			userOrganisationUnitGrandChildren.setValue(false);
+			
+			organisationUnitLevel.clearValue();
+			organisationUnitGroup.clearValue();
+
+			areaRadius.reset();
 		};
 
 		setGui = function(view) {
@@ -5865,75 +5927,93 @@
 				isOuc = false,
 				isOugc = false,
 				levels = [],
-				groups = [];
-				
-			// Group set
-			groupSet.store.removeAll();
-			groupSet.store.add(view.organisationUnitGroupSet);
-			groupSet.setValue(view.organisationUnitGroupSet.id);
-
-			// Organisation units
-			for (var i = 0, item; i < ouDim.items.length; i++) {
-				item = ouDim.items[i];
-				
-				if (item.id === 'USER_ORGUNIT') {
-					isOu = true;
-				}
-				else if (item.id === 'USER_ORGUNIT_CHILDREN') {
-					isOuc = true;
-				}
-				else if (item.id === 'USER_ORGUNIT_GRANDCHILDREN') {
-					isOugc = true;
-				}
-				else if (item.id.substr(0,5) === 'LEVEL') {
-					levels.push(parseInt(item.id.split('-')[1]));
-				}
-				else if (item.id.substr(0,8) === 'OU_GROUP') {
-					groups.push(parseInt(item.id.split('-')[1]));
-				}
-			}
-
-			if (levels.length) {
-				toolMenu.clickHandler('level');
-				organisationUnitLevel.setValue(levels);
-			}
-			else if (groups.length) {
-				toolMenu.clickHandler('group');
-				organisationUnitGroup.setValue(groups);
-			}
-			else {
-				toolMenu.clickHandler('orgunit');
-				userOrganisationUnit.setValue(isOu);
-				userOrganisationUnitChildren.setValue(isOuc);
-				userOrganisationUnitGrandChildren.setValue(isOugc);
-			}
-			
-			treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
-			
-			for (var key in view.parentGraphMap) {
-				if (view.parentGraphMap.hasOwnProperty(key)) {
-					treePanel.multipleExpand(key, view.parentGraphMap[key], false);
-				}
-			}
-			
-			// Area radius
-			areaRadius.setValue(true, view.areaRadius);
-
-			// Layer item
-			layer.item.setValue(true, view.opacity);
-
-			// Layer menu
-			layer.menu.enableItems();
-
-			// Update filter window
-			if (layer.filterWindow && layer.filterWindow.isVisible()) {
-				layer.filterWindow.filter();
-			}
+				groups = [],
+				setWidgetGui,
+				setLayerGui;
+				
+			setWidgetGui = function() {
+			
+				// Components			
+				if (!layer.window.isRendered) {
+					layer.window.view = view;
+					return;
+				}
+				
+				reset(true);
+					
+				// Group set
+				groupSet.store.removeAll();
+				groupSet.store.add(view.organisationUnitGroupSet);
+				groupSet.setValue(view.organisationUnitGroupSet.id);
+
+				// Organisation units
+				for (var i = 0, item; i < ouDim.items.length; i++) {
+					item = ouDim.items[i];
+					
+					if (item.id === 'USER_ORGUNIT') {
+						isOu = true;
+					}
+					else if (item.id === 'USER_ORGUNIT_CHILDREN') {
+						isOuc = true;
+					}
+					else if (item.id === 'USER_ORGUNIT_GRANDCHILDREN') {
+						isOugc = true;
+					}
+					else if (item.id.substr(0,5) === 'LEVEL') {
+						levels.push(parseInt(item.id.split('-')[1]));
+					}
+					else if (item.id.substr(0,8) === 'OU_GROUP') {
+						groups.push(parseInt(item.id.split('-')[1]));
+					}
+				}
+
+				if (levels.length) {
+					toolMenu.clickHandler('level');
+					organisationUnitLevel.setValue(levels);
+				}
+				else if (groups.length) {
+					toolMenu.clickHandler('group');
+					organisationUnitGroup.setValue(groups);
+				}
+				else {
+					toolMenu.clickHandler('orgunit');
+					userOrganisationUnit.setValue(isOu);
+					userOrganisationUnitChildren.setValue(isOuc);
+					userOrganisationUnitGrandChildren.setValue(isOugc);
+				}
+				
+				treePanel.numberOfRecords = gis.util.object.getLength(view.parentGraphMap);
+				
+				for (var key in view.parentGraphMap) {
+					if (view.parentGraphMap.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, view.parentGraphMap[key], false);
+					}
+				}
+				
+				// Area radius
+				areaRadius.setValue(!!view.areaRadius, !!view.areaRadius ? view.areaRadius : null);
+			}();
+			
+			setLayerGui = function() {
+
+				// Layer item
+				layer.item.setValue(true, view.opacity);
+
+				// Layer menu
+				layer.menu.enableItems();
+
+				// Update filter window
+				if (layer.filterWindow && layer.filterWindow.isVisible()) {
+					layer.filterWindow.filter();
+				}
+			}();
 		};
 
 		getView = function(config) {
 			var view = {};
 			
+			view.layer = layer.id;
+			
 			view.rows = [treePanel.getDimension()];
 			
 			view.organisationUnitGroupSet = {
@@ -6018,7 +6098,12 @@
 						areaRadius
 					]
 				}
-			]
+			],
+			listeners: {
+				render: function() {
+					toolMenu.clickHandler('level');
+				}
+			}
 		});
 
 		//createSelectHandlers();

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2013-09-30 15:43:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js	2013-10-02 12:52:37 +0000
@@ -2109,24 +2109,6 @@
 						}
 					}
 					
-					if (!dxDim) {
-						return;
-					}
-					
-					if (!peDim) {
-						peDim = {
-							dimension: 'pe',
-							items: [{id: 'LAST_MONTH'}]
-						};
-					}
-					
-					if (!ouDim) {
-						ouDim = {
-							dimension: 'ou',
-							items: [{id: 'LEVEL-2'}]
-						};
-					}
-					
 					config.columns = [dxDim];
 					config.rows = [ouDim];
 					config.filters = [peDim];
@@ -2141,21 +2123,21 @@
 						isOu = false,
 						isOuc = false,
 						isOugc = false;
+					
+					config = validateSpecialCases(config);
 
 					config.columns = getValidatedDimensionArray(config.columns);
 					config.rows = getValidatedDimensionArray(config.rows);
 					config.filters = getValidatedDimensionArray(config.filters);
-					
-					config = validateSpecialCases(config);
 
-					// Config must be an object
-					if (!(config && Ext.isObject(config))) {
-						alert(gis.el + ': Data required');
+					// At least one dimension
+					if (!(config.columns || config.rows || config.filters)) {
+						alert(gis.el + ': At least one dimension required');
 						return;
 					}
 
 					// Collect object names and user orgunits
-					for (var i = 0, dim, dims = [].concat(config.columns, config.rows, config.filters); i < dims.length; i++) {
+					for (var i = 0, dim, dims = Ext.Array.clean([].concat(config.columns, config.rows, config.filters)); i < dims.length; i++) {
 						dim = dims[i];
 
 						if (dim) {
@@ -2182,12 +2164,6 @@
 						}
 					}
 
-					// At least one period
-					if (!Ext.Array.contains(objectNames, dimConf.period.objectName)) {
-						alert(GIS.i18n.at_least_one_period_must_be_specified_as_column_row_or_filter);
-						return;
-					}
-
 					// Layout
 					layout.columns = config.columns;
 					layout.rows = config.rows;
@@ -2210,6 +2186,9 @@
 					layout.parentGraphMap = Ext.isObject(config.parentGraphMap) ? config.parentGraphMap : null;
 					
 					layout.legendSet = config.legendSet;
+					
+					layout.organisationUnitGroupSet = config.organisationUnitGroupSet;
+					layout.areaRadius = config.areaRadius;
 
 					return Ext.clone(layout);
 				}();