← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12508: (PT, DV, GIS) Fixed bug where tree state was lost during node expansion.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 12508 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-08 17:31:48 +0200
message:
  (PT,DV,GIS) Fixed bug where tree state was lost during node expansion.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.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/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-10-08 14:06:23 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2013-10-08 15:18:45 +0000
@@ -1920,65 +1920,66 @@
 						view,
 						map;
 
-					if (layers.length) {
-						if (name) {
-							for (var i = 0; i < layers.length; i++) {
-								layer = layers[i];
-								view = layer.widget.getView();
-
-								// Operand
-								if (Ext.isArray(view.columns) && view.columns.length) {
-									for (var j = 0; j < view.columns.length; j++) {
-										for (var k = 0, item; k < view.columns[j].items.length; k++) {
-											item = view.columns[j].items[k];
-
-											if (item.id.indexOf('-') !== -1) {
-												item.id = item.id.replace('-', '.');
-											}
-										}
-									}
-								}
-
-								// add
-								view.layer = layer.id;
-
-								views.push(view);
-							}
-
-							map = {
-								name: name,
-								longitude: lonlat.lon,
-								latitude: lonlat.lat,
-								zoom: gis.olmap.getZoom(),
-								mapViews: views,
-								user: {
-									id: 'currentUser'
-								}
-							};
-
-							Ext.Ajax.request({
-								url: gis.init.contextPath + gis.conf.finals.url.path_api + 'maps/',
-								method: 'POST',
-								headers: {'Content-Type': 'application/json'},
-								params: Ext.encode(map),
-								success: function(r) {
-									var id = r.getAllResponseHeaders().location.split('/').pop();
-
-									gis.store.maps.loadStore();
-
-									gis.viewport.interpretationButton.enable();
-
-									window.destroy();
-								}
-							});
-						}
-						else {
-							alert('Please enter a name');
-						}
-					}
-					else {
+					if (!layers.length) {
 						alert('Please create a map first');
-					}
+						return;
+					}
+
+					if (!name) {
+						alert('Please enter a name');
+						return;
+					}
+
+					for (var i = 0; i < layers.length; i++) {
+						layer = layers[i];
+						//view = layer.widget.getView();
+						view = Ext.clone(layer.core.view);
+
+						// Operand
+						if (Ext.isArray(view.columns) && view.columns.length) {
+							for (var j = 0; j < view.columns.length; j++) {
+								for (var k = 0, item; k < view.columns[j].items.length; k++) {
+									item = view.columns[j].items[k];
+
+									if (item.id.indexOf('-') !== -1) {
+										item.id = item.id.replace('-', '.');
+									}
+								}
+							}
+						}
+
+						// add
+						view.layer = layer.id;
+
+						views.push(view);
+					}
+
+					map = {
+						name: name,
+						longitude: lonlat.lon,
+						latitude: lonlat.lat,
+						zoom: gis.olmap.getZoom(),
+						mapViews: views,
+						user: {
+							id: 'currentUser'
+						}
+					};
+
+					Ext.Ajax.request({
+						url: gis.init.contextPath + gis.conf.finals.url.path_api + 'maps/',
+						method: 'POST',
+						headers: {'Content-Type': 'application/json'},
+						params: Ext.encode(map),
+						success: function(r) {
+							var id = r.getAllResponseHeaders().location.split('/').pop();
+
+							gis.store.maps.loadStore();
+
+							gis.viewport.interpretationButton.enable();
+
+							window.destroy();
+						}
+					});
 				}
 			});
 
@@ -3438,6 +3439,15 @@
 
 				return map;
 			},
+			selectGraphMap: function(map, doUpdate) {
+				this.numberOfRecords = gis.util.object.getLength(map);
+
+				for (var key in map) {
+					if (map.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, map[key], doUpdate);
+					}
+				}
+			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
 					type: 'ajax',
@@ -3531,6 +3541,14 @@
 				return config.items.length ? config : null;
 			},
             listeners: {
+				load: function() {
+					if (treePanel.tmpSelection) {
+						treePanel.selectGraphMap(treePanel.tmpSelection);
+					}
+				},
+				beforeitemexpand: function() {
+					treePanel.tmpSelection = treePanel.getParentGraphMap();
+				},
 				render: function() {
 					this.rendered = true;
 				},
@@ -3821,13 +3839,7 @@
 					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);
-					}
-				}
+				treePanel.selectGraphMap(view.parentGraphMap);
 			}();
 
 			setLayerGui = function() {
@@ -4731,6 +4743,15 @@
 
 				return map;
 			},
+			selectGraphMap: function(map, doUpdate) {
+				this.numberOfRecords = gis.util.object.getLength(map);
+
+				for (var key in map) {
+					if (map.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, map[key], doUpdate);
+					}
+				}
+			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
 					type: 'ajax',
@@ -4824,6 +4845,14 @@
 				return config.items.length ? config : null;
 			},
             listeners: {
+				load: function() {
+					if (treePanel.tmpSelection) {
+						treePanel.selectGraphMap(treePanel.tmpSelection);
+					}
+				},
+				beforeitemexpand: function() {
+					treePanel.tmpSelection = treePanel.getParentGraphMap();
+				},
 				render: function() {
 					this.rendered = true;
 				},
@@ -5247,13 +5276,7 @@
 					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);
-					}
-				}
+				treePanel.selectGraphMap(view.parentGraphMap);
 			}();
 
 			setLayerGui = function() {
@@ -5541,6 +5564,15 @@
 
 				return map;
 			},
+			selectGraphMap: function(map, doUpdate) {
+				this.numberOfRecords = gis.util.object.getLength(map);
+
+				for (var key in map) {
+					if (map.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, map[key], doUpdate);
+					}
+				}
+			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
 					type: 'ajax',
@@ -5634,6 +5666,14 @@
 				return config.items.length ? config : null;
 			},
             listeners: {
+				load: function() {
+					if (treePanel.tmpSelection) {
+						treePanel.selectGraphMap(treePanel.tmpSelection);
+					}
+				},
+				beforeitemexpand: function() {
+					treePanel.tmpSelection = treePanel.getParentGraphMap();
+				},
 				render: function() {
 					this.rendered = true;
 				},
@@ -5947,13 +5987,7 @@
 					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);
-					}
-				}
+				treePanel.selectGraphMap(view.parentGraphMap);
 
 				// Area radius
 				areaRadius.setValue(!!view.areaRadius, !!view.areaRadius ? view.areaRadius : null);

=== 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-10-08 11:41:57 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2013-10-08 15:02:26 +0000
@@ -3441,6 +3441,15 @@
 				
 				return map;
 			},
+			selectGraphMap: function(map, doUpdate) {
+				this.numberOfRecords = pt.util.object.getLength(map);
+
+				for (var key in map) {
+					if (map.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, map[key], doUpdate);
+					}
+				}
+			},
 			store: Ext.create('Ext.data.TreeStore', {
 				proxy: {
 					type: 'ajax',
@@ -3463,6 +3472,14 @@
 				this.enable();
 			},
 			listeners: {
+				load: function() {
+					if (treePanel.tmpSelection) {
+						treePanel.selectGraphMap(treePanel.tmpSelection);
+					}
+				},
+				beforeitemexpand: function() {
+					treePanel.tmpSelection = treePanel.getParentGraphMap();
+				},
 				added: function() {
 					pt.cmp.dimension.organisationUnit.treepanel = this;
 				},
@@ -4643,18 +4660,10 @@
 				userOrganisationUnitChildren.setValue(isOuc);
 				userOrganisationUnitGrandChildren.setValue(isOugc);
 			}
-			
+
 			if (!(isOu || isOuc || isOugc)) {
-
-				// If fav has organisation units, wait for tree callback before update
 				if (Ext.isObject(graphMap)) {
-					treePanel.numberOfRecords = pt.util.object.getLength(graphMap);
-
-					for (var key in graphMap) {						
-						if (graphMap.hasOwnProperty(key)) {
-							treePanel.multipleExpand(key, graphMap[key], false);
-						}
-					}
+					treePanel.selectGraphMap(graphMap);
 				}
 			}
 			else {

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2013-10-08 09:53:16 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2013-10-08 14:53:59 +0000
@@ -3594,6 +3594,15 @@
 
 				return map;
 			},
+			selectGraphMap: function(map, doUpdate) {
+				this.numberOfRecords = dv.util.object.getLength(map);
+
+				for (var key in map) {
+					if (map.hasOwnProperty(key)) {
+						treePanel.multipleExpand(key, map[key], doUpdate);
+					}
+				}
+			},
             store: Ext.create('Ext.data.TreeStore', {
                 proxy: {
                     type: 'ajax',
@@ -3616,6 +3625,14 @@
 				this.enable();
 			},
             listeners: {
+				load: function() {
+					if (treePanel.tmpSelection) {
+						treePanel.selectGraphMap(treePanel.tmpSelection);
+					}
+				},
+				beforeitemexpand: function() {
+					treePanel.tmpSelection = treePanel.getParentGraphMap();
+				},
                 added: function() {
                     dv.cmp.dimension.organisationUnit.treepanel = this;
                 },
@@ -4793,16 +4810,8 @@
 			}
 
 			if (!(isOu || isOuc || isOugc)) {
-
-				// If fav has organisation units, wait for tree callback before update
 				if (Ext.isObject(graphMap)) {
-					treePanel.numberOfRecords = dv.util.object.getLength(graphMap);
-
-					for (var key in graphMap) {
-						if (graphMap.hasOwnProperty(key)) {
-							treePanel.multipleExpand(key, graphMap[key], false);
-						}
-					}
+					treePanel.selectGraphMap(graphMap);
 				}
 			}
 			else {