← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2457: (GIS) Level combo creates/shows orgunittree window as well.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2457 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2010-12-31 06:14:28 +0100
message:
  (GIS) Level combo creates/shows orgunittree window as well.
modified:
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2010-11-30 13:04:58 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2010-12-31 05:07:49 +0000
@@ -641,11 +641,14 @@
     public Collection<MapView> getAllMapViews()
     {
         Collection<MapView> mapViews = mappingStore.getAllMapViews();
-
-        for ( MapView mapView : mapViews )
+        
+        if ( mapViews.size() > 0 )
         {
-            mapView.getParentOrganisationUnit().setLevel(
-                organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit() ) );
+            for ( MapView mapView : mapViews )
+            {
+                mapView.getParentOrganisationUnit().setLevel(
+                    organisationUnitService.getLevelOfOrganisationUnit( mapView.getParentOrganisationUnit() ) );
+            }
         }
 
         return mapViews;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2010-12-20 22:21:18 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2010-12-31 05:07:49 +0000
@@ -12,19 +12,19 @@
     padding-left: 8px;
 }
 .x-form-field {
-	font:10px lucida sans unicode,ubuntu,arial,tahoma,helvetica,sans-serif;
+	font:10px lucida sans unicode,ubuntu,arial;
 }
 .x-form-item label.x-form-item-label {
     padding:3px 3px 3px 4px;
 }
 .x-combo-list {
-	font:10px lucida sans unicode,ubuntu,arial,tahoma,helvetica,sans-serif;
+	font:10px lucida sans unicode,ubuntu,arial;
 }
 .x-tree-node {
-	font:10px lucida sans unicode,ubuntu,arial,tahoma,helvetica,sans-serif;
+	font:10px lucida sans unicode,ubuntu,arial;
 }
 .x-panel-mc {
-	font:10px lucida sans unicode,ubuntu,arial,tahoma,helvetica,sans-serif;
+	font:10px lucida sans unicode,ubuntu,arial;
 }
 .x-tree-node a span, .x-dd-drag-ghost a span {
 	padding:1px 3px 1px 4px;
@@ -50,11 +50,11 @@
     padding:0;
 }
 .ux-mselect-item {
-	font:10px lucida sans unicode,ubuntu,tahoma,arial,helvetica,sans-serif;
+	font:10px lucida sans unicode,ubuntu,tahoma,arial;
 	padding:1px 1px 1px 3px;
 }
 .x-box-mc {
-	font-family:ubuntu,arial,tahoma,helvetica;
+	font-family:ubuntu,arial;
 	font-weight:normal;
 }
 .loading-indicator {
@@ -244,7 +244,8 @@
 
 /* Ext ComboBox */
 .combo-disabled {
-    opacity:0.70;
+    opacity:0.60;
+    filter:alpha(opacity=60);
     color:#000000;
     border-color:#9ca1b8;
     cursor: default;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-12-24 15:51:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-12-31 05:07:49 +0000
@@ -29,7 +29,6 @@
             'parentOrganisationUnitLevel', 'organisationUnitLevel', 'organisationUnitLevelName', 'mapLegendType', 'method', 'classes',
             'bounds', 'colorLow', 'colorHigh', 'mapLegendSetId', 'radiusLow', 'radiusHigh', 'longitude', 'latitude', 'zoom'
         ],
-        sortInfo: {field: 'name', direction: 'ASC'},
         autoLoad: false,
         isLoaded: false,
         listeners: {
@@ -476,15 +475,15 @@
                     {
                         xtype: 'combo',
                         id: 'favorite_cb',
-                        editable: false,
-                        valueField: 'id',
-                        displayField: 'name',
-                        mode: 'remote',
-                        forceSelection: true,
-                        triggerAction: 'all',
-                        emptyText: GLOBAL.conf.emptytext,
-                        labelSeparator: GLOBAL.conf.labelseparator,
                         fieldLabel: i18n_favorite,
+                        editable: false,
+                        valueField: 'id',
+                        displayField: 'name',
+                        mode: 'remote',
+                        forceSelection: true,
+                        triggerAction: 'all',
+                        emptyText: GLOBAL.conf.emptytext,
+                        labelSeparator: GLOBAL.conf.labelseparator,
                         selectOnFocus: true,
                         width: GLOBAL.conf.combo_width_fieldset,
                         minListWidth: GLOBAL.conf.combo_width_fieldset,
@@ -581,20 +580,19 @@
 				text: i18n_delete,
 				handler: function() {
 					var v = Ext.getCmp('favorite_cb').getValue();
+					var rw = Ext.getCmp('favorite_cb').getRawValue();
 					
                     if (!v) {
 						Ext.message.msg(false, i18n_please_select_a_map_view);
 						return;
 					}
-                    
-					var name = GLOBAL.stores.mapView.getById(v).get('name');				
 					
 					Ext.Ajax.request({
 						url: GLOBAL.conf.path_mapping + 'deleteMapView' + GLOBAL.conf.type,
 						method: 'POST',
-						params: {id:v},
+						params: {id: v},
 						success: function(r) {
-							Ext.message.msg(true, i18n_favorite + ' <span class="x-msg-hl">' + name + '</span> ' + i18n_deleted);
+							Ext.message.msg(true, i18n_favorite + ' <span class="x-msg-hl">' + rw + '</span> ' + i18n_deleted);
                             GLOBAL.stores.mapView.load();
                             Ext.getCmp('favorite_cb').clearValue();
                             if (v == choropleth.form.findField('mapview').getValue()) {
@@ -2335,7 +2333,7 @@
 	var favoritesButton = new Ext.Button({
 		iconCls: 'icon-favorite',
 		tooltip: i18n_favorite_map_views,
-		hidden: !GLOBAL.vars.user.isAdmin,
+		disabled: !GLOBAL.vars.user.isAdmin,
 		handler: function() {
 			var x = Ext.getCmp('center').x + 15;
 			var y = Ext.getCmp('center').y + 41;    
@@ -2389,7 +2387,7 @@
 	var predefinedMapLegendSetButton = new Ext.Button({
 		iconCls: 'icon-predefinedlegendset',
 		tooltip: i18n_create_predefined_legend_sets,
-		hidden: !GLOBAL.vars.user.isAdmin,
+		disabled: !GLOBAL.vars.user.isAdmin,
 		handler: function() {
 			var x = Ext.getCmp('center').x + 15;
 			var y = Ext.getCmp('center').y + 41;
@@ -2410,7 +2408,7 @@
 	var adminButton = new Ext.Button({
 		iconCls: 'icon-admin',
 		tooltip: 'Administrator settings',
-		hidden: !GLOBAL.vars.user.isAdmin,
+		disabled: !GLOBAL.vars.user.isAdmin,
 		handler: function() {
 			var x = Ext.getCmp('center').x + 15;
 			var y = Ext.getCmp('center').y + 41;
@@ -2421,7 +2419,7 @@
 	
 	var helpButton = new Ext.Button({
 		iconCls: 'icon-help',
-		tooltip: i18n_help ,
+		tooltip: i18n_help,
 		handler: function() {
 			var c = Ext.getCmp('center').x;
 			var e = Ext.getCmp('east').x;
@@ -2459,9 +2457,9 @@
 			exitButton,' ',' '
 		]
 	});
-    
+
 	/* Section: viewport */
-    viewport = new Ext.Viewport({
+    var viewport = new Ext.Viewport({
         id: 'viewport',
         layout: 'border',
         margins: '0 0 5 0',

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-12-21 12:12:23 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-12-31 05:07:49 +0000
@@ -580,162 +580,23 @@
             xtype: 'textfield',
             name: 'boundary',
             fieldLabel: i18n_boundary,
-            typeAhead: true,
             editable: false,
-            valueField: 'id',
-            displayField: 'name',
-            mode: 'remote',
-            forceSelection: true,
-            triggerAction: 'all',
             emptyText: GLOBAL.conf.emptytext,
 			labelSeparator: GLOBAL.conf.labelseparator,
-            selectOnFocus: true,
             width: GLOBAL.conf.combo_width,
+            style: 'cursor:pointer',
             node: {attributes: {hasChildrenWithCoordinates: false}},
             selectedNode: null,
-            style: 'cursor:pointer',
+            treeWindow: false,
             listeners: {
                 'focus': {
                     scope: this,
                     fn: function(tf) {
-                        if (GLOBAL.vars.topLevelUnit) {
-                            Ext.getCmp('tree_w').show();
+                        if (tf.treeWindow) {
+                            tf.treeWindow.show();
                         }
                         else {
-                            Ext.Ajax.request({
-                                url: GLOBAL.conf.path_commons + 'getOrganisationUnits' + GLOBAL.conf.type,
-                                params: {level: 1},
-                                method: 'POST',
-                                scope: this,
-                                success: function(r) {
-                                    var rootNode = Ext.util.JSON.decode(r.responseText).organisationUnits[0];
-                                    GLOBAL.vars.topLevelUnit = {
-                                        id: rootNode.id,
-                                        name: rootNode.name,
-                                        hasChildrenWithCoordinates: rootNode.hasChildrenWithCoordinates
-                                    };
-                                    
-                                    var w = new Ext.Window({
-                                        id: 'tree_w',
-                                        title: 'Boundary and level',
-                                        closeAction: 'hide',
-                                        autoScroll: true,
-                                        height: 'auto',
-                                        autoHeight: true,
-                                        width: GLOBAL.conf.window_width,
-                                        items: [
-                                            {
-                                                xtype: 'panel',
-                                                bodyStyle: 'padding:8px; background-color:#ffffff',
-                                                items: [
-                                                    {html: '<div class="window-info">Select outer boundary</div>'},
-                                                    {
-                                                        xtype: 'treepanel',
-                                                        bodyStyle: 'background-color:#ffffff',
-                                                        height: screen.height / 3,
-                                                        autoScroll: true,
-                                                        lines: false,
-                                                        loader: new Ext.tree.TreeLoader({
-                                                            dataUrl: GLOBAL.conf.path_mapping + 'getOrganisationUnitChildren' + GLOBAL.conf.type
-                                                        }),
-                                                        root: {
-                                                            id: GLOBAL.vars.topLevelUnit.id,
-                                                            text: GLOBAL.vars.topLevelUnit.name,
-                                                            hasChildrenWithCoordinates: GLOBAL.vars.topLevelUnit.hasChildrenWithCoordinates,
-                                                            nodeType: 'async',
-                                                            draggable: false,
-                                                            expanded: true
-                                                        },
-                                                        clickedNode: null,
-                                                        listeners: {
-                                                            'click': {
-                                                                scope: this,
-                                                                fn: function(n) {
-                                                                    this.form.findField('boundary').selectedNode = n;
-                                                                }
-                                                            }
-                                                        }
-                                                    }
-                                                ]
-                                            },
-                                            {
-                                                xtype: 'panel',
-                                                layout: 'form',
-                                                bodyStyle: 'padding:8px; background-color:#ffffff',
-                                                items: [
-                                                    {html: '<div class="window-info">Select organisation unit level</div>'},
-                                                    {
-                                                        xtype: 'combo',
-                                                        id: 'level_cb',
-                                                        fieldLabel: i18n_level,
-                                                        editable: false,
-                                                        valueField: 'level',
-                                                        displayField: 'name',
-                                                        mode: 'remote',
-                                                        forceSelection: true,
-                                                        triggerAction: 'all',
-                                                        selectOnFocus: true,
-                                                        emptyText: GLOBAL.conf.emptytext,
-                                                        labelSeparator: GLOBAL.conf.labelseparator,
-                                                        fieldLabel: 'Level',
-                                                        width: GLOBAL.conf.combo_width_fieldset,
-                                                        minListWidth: GLOBAL.conf.combo_width_fieldset,
-                                                        store: GLOBAL.stores.polygonOrganisationUnitLevel,
-                                                        listeners: {
-                                                            'select': {
-                                                                scope: this,
-                                                                fn: function(cb) {
-                                                                    this.form.findField('level').level = cb.getValue();
-                                                                    this.form.findField('level').levelName = cb.getRawValue();
-                                                                }
-                                                            }
-                                                        }
-                                                    }
-                                                ]
-                                            }
-                                        ],
-                                        bbar: [
-                                            '->',
-                                            {
-                                                xtype: 'button',
-                                                text: i18n_apply,
-                                                iconCls: 'icon-assign',
-                                                scope: this,
-                                                handler: function() {
-                                                    var node = this.form.findField('boundary').selectedNode;
-                                                    if (!node || !Ext.getCmp('level_cb').getValue()) {
-                                                        return;
-                                                    }
-                                                    if (node.attributes.level > this.form.findField('level').level) {
-                                                        Ext.message.msg(false, 'Level is higher than boundary level');
-                                                        return;
-                                                    }
-                                                    
-                                                    if (Ext.getCmp('locatefeature_w')) {
-                                                        Ext.getCmp('locatefeature_w').destroy();
-                                                    }
-                                                    
-                                                    this.form.findField('mapview').clearValue();
-                                                    this.updateValues = true;
-                                                    this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level,
-                                                        this.form.findField('level').level, this.form.findField('level').levelName);
-                                                        
-                                                    this.form.findField('boundary').setValue(node.attributes.text);
-                                                    this.form.findField('level').setValue(this.form.findField('level').levelName);
-                                                    Ext.getCmp('tree_w').hide();
-                                                    
-                                                    this.loadGeoJson();
-                                                }
-                                            }
-                                        ]
-                                    });
-                                    
-                                    var x = Ext.getCmp('center').x + 15;
-                                    var y = Ext.getCmp('center').y + 41;
-                                    w.setPosition(x,y);
-                                    w.show();
-                                }
-                            });
+							this.createSingletonCmp.treeWindow.call(this);
                         }
                     }
                 }
@@ -745,15 +606,27 @@
         {
             xtype: 'textfield',
             name: 'level',
-            disabled: true,
-            disabledClass: 'combo-disabled',
             fieldLabel: i18n_level,
             editable: false,
             emptyText: GLOBAL.conf.emptytext,
 			labelSeparator: GLOBAL.conf.labelseparator,
             width: GLOBAL.conf.combo_width,
+            style: 'cursor:pointer',
             level: null,
-            levelName: null
+            levelName: null,
+            listeners: {
+                'focus': {
+                    scope: this,
+                    fn: function() {
+                        if (this.form.findField('boundary').treeWindow) {
+                            this.form.findField('boundary').treeWindow.show();
+                        }
+                        else {
+							this.createSingletonCmp.treeWindow.call(this);
+                        }
+                    }
+                }
+            }
         },
         
         { html: '<div class="thematic-br">' },
@@ -953,6 +826,145 @@
         ];
     },
     
+	createSingletonCmp: {
+		treeWindow: function() {
+			Ext.Ajax.request({
+				url: GLOBAL.conf.path_commons + 'getOrganisationUnits' + GLOBAL.conf.type,
+				params: {level: 1},
+				method: 'POST',
+				scope: this,
+				success: function(r) {
+					var rootNode = Ext.util.JSON.decode(r.responseText).organisationUnits[0];
+					GLOBAL.vars.topLevelUnit = {
+						id: rootNode.id,
+						name: rootNode.name,
+						hasChildrenWithCoordinates: rootNode.hasChildrenWithCoordinates
+					};
+					
+					var w = new Ext.Window({
+						title: 'Boundary and level',
+						closeAction: 'hide',
+						autoScroll: true,
+						height: 'auto',
+						autoHeight: true,
+						width: GLOBAL.conf.window_width,
+						items: [
+							{
+								xtype: 'panel',
+								bodyStyle: 'padding:8px; background-color:#ffffff',
+								items: [
+									{html: '<div class="window-info">Select outer boundary</div>'},
+									{
+										xtype: 'treepanel',
+										bodyStyle: 'background-color:#ffffff',
+										height: screen.height / 3,
+										autoScroll: true,
+										lines: false,
+										loader: new Ext.tree.TreeLoader({
+											dataUrl: GLOBAL.conf.path_mapping + 'getOrganisationUnitChildren' + GLOBAL.conf.type
+										}),
+										root: {
+											id: GLOBAL.vars.topLevelUnit.id,
+											text: GLOBAL.vars.topLevelUnit.name,
+											hasChildrenWithCoordinates: GLOBAL.vars.topLevelUnit.hasChildrenWithCoordinates,
+											nodeType: 'async',
+											draggable: false,
+											expanded: true
+										},
+										clickedNode: null,
+										listeners: {
+											'click': {
+												scope: this,
+												fn: function(n) {
+													this.form.findField('boundary').selectedNode = n;
+												}
+											}
+										}
+									}
+								]
+							},
+							{
+								xtype: 'panel',
+								layout: 'form',
+								bodyStyle: 'padding:8px; background-color:#ffffff',
+								items: [
+									{html: '<div class="window-info">Select organisation unit level</div>'},
+									{
+										xtype: 'combo',
+										id: 'level_cb',
+										fieldLabel: i18n_level,
+										editable: false,
+										valueField: 'level',
+										displayField: 'name',
+										mode: 'remote',
+										forceSelection: true,
+										triggerAction: 'all',
+										selectOnFocus: true,
+										emptyText: GLOBAL.conf.emptytext,
+										labelSeparator: GLOBAL.conf.labelseparator,
+										fieldLabel: 'Level',
+										width: GLOBAL.conf.combo_width_fieldset,
+										minListWidth: GLOBAL.conf.combo_width_fieldset,
+										store: GLOBAL.stores.polygonOrganisationUnitLevel,
+										listeners: {
+											'select': {
+												scope: this,
+												fn: function(cb) {
+													this.form.findField('level').level = cb.getValue();
+													this.form.findField('level').levelName = cb.getRawValue();
+												}
+											}
+										}
+									}
+								]
+							}
+						],
+						bbar: [
+							'->',
+							{
+								xtype: 'button',
+								text: i18n_apply,
+								iconCls: 'icon-assign',
+								scope: this,
+								handler: function() {
+									var node = this.form.findField('boundary').selectedNode;
+									if (!node || !Ext.getCmp('level_cb').getValue()) {
+										return;
+									}
+									if (node.attributes.level > this.form.findField('level').level) {
+										Ext.message.msg(false, 'Level is higher than boundary level');
+										return;
+									}
+									
+									if (Ext.getCmp('locatefeature_w')) {
+										Ext.getCmp('locatefeature_w').destroy();
+									}
+									
+									this.form.findField('mapview').clearValue();
+									this.updateValues = true;
+									this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level,
+										this.form.findField('level').level, this.form.findField('level').levelName);
+										
+									this.form.findField('boundary').setValue(node.attributes.text);
+									this.form.findField('level').setValue(this.form.findField('level').levelName);
+									
+									this.form.findField('boundary').treeWindow.hide();									
+									this.loadGeoJson();
+								}
+							}
+						]
+					});
+					
+					var x = Ext.getCmp('center').x + 15;
+					var y = Ext.getCmp('center').y + 41;
+					w.setPosition(x,y);
+					w.show();
+					this.form.findField('boundary').treeWindow = w;
+				}
+			});
+		}
+	},
+    
     createSelectFeatures: function() {
         var scope = this;
         

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-12-21 12:12:23 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-12-31 05:07:49 +0000
@@ -579,121 +579,23 @@
             xtype: 'textfield',
             name: 'boundary',
             fieldLabel: i18n_boundary,
-            typeAhead: true,
             editable: false,
-            valueField: 'id',
-            displayField: 'name',
-            mode: 'remote',
-            forceSelection: true,
-            triggerAction: 'all',
             emptyText: GLOBAL.conf.emptytext,
 			labelSeparator: GLOBAL.conf.labelseparator,
-            selectOnFocus: true,
             width: GLOBAL.conf.combo_width,
+            style: 'cursor:pointer',
             node: {attributes: {hasChildrenWithCoordinates: false}},
             selectedNode: null,
-            style: 'cursor:pointer',
+            treeWindow: false,
             listeners: {
                 'focus': {
                     scope: this,
                     fn: function(tf) {
-                        if (GLOBAL.vars.topLevelUnit) {
-                            Ext.getCmp('tree_w2').show();
+                        if (tf.treeWindow) {
+                            tf.treeWindow.show();
                         }
                         else {
-                            Ext.Ajax.request({
-                                url: GLOBAL.conf.path_commons + 'getOrganisationUnits' + GLOBAL.conf.type,
-                                params: {level: 1},
-                                method: 'POST',
-                                scope: this,
-                                success: function(r) {
-                                    var rootNode = Ext.util.JSON.decode(r.responseText).organisationUnits[0];
-                                    GLOBAL.vars.topLevelUnit = {
-                                        id: rootNode.id,
-                                        name: rootNode.name,
-                                        hasChildrenWithCoordinates: rootNode.hasChildrenWithCoordinates
-                                    };
-                                    
-                                    var w = new Ext.Window({
-                                        id: 'tree_w2',
-                                        title: 'Boundary',
-                                        closeAction: 'hide',
-                                        autoScroll: true,
-                                        height: 'auto',
-                                        autoHeight: true,
-                                        width: GLOBAL.conf.window_width,
-                                        items: [
-                                            {
-                                                xtype: 'panel',
-                                                bodyStyle: 'padding:8px; background-color:#ffffff',
-                                                items: [
-                                                    {html: '<div class="window-info">Select outer boundary</div>'},
-                                                    {
-                                                        xtype: 'treepanel',
-                                                        bodyStyle: 'background-color:#ffffff',
-                                                        height: screen.height / 3,
-                                                        autoScroll: true,
-                                                        lines: false,
-                                                        loader: new Ext.tree.TreeLoader({
-                                                            dataUrl: GLOBAL.conf.path_mapping + 'getOrganisationUnitChildren' + GLOBAL.conf.type
-                                                        }),
-                                                        root: {
-                                                            id: GLOBAL.vars.topLevelUnit.id,
-                                                            text: GLOBAL.vars.topLevelUnit.name,
-                                                            hasChildrenWithCoordinates: GLOBAL.vars.topLevelUnit.hasChildrenWithCoordinates,
-                                                            nodeType: 'async',
-                                                            draggable: false,
-                                                            expanded: true
-                                                        },
-                                                        clickedNode: null,
-                                                        listeners: {
-                                                            'click': {
-                                                                scope: this,
-                                                                fn: function(n) {
-                                                                    this.form.findField('boundary').selectedNode = n;
-                                                                }
-                                                            }
-                                                        }
-                                                    }
-                                                ]
-                                            }
-                                        ],
-                                        bbar: [
-                                            '->',
-                                            {
-                                                xtype: 'button',
-                                                text: i18n_apply,
-                                                iconCls: 'icon-assign',
-                                                scope: this,
-                                                handler: function() {
-                                                    var node = this.form.findField('boundary').selectedNode;
-                                                    if (!node) {
-                                                        return;
-                                                    }
-
-                                                    if (Ext.getCmp('locatefeature_w')) {
-                                                        Ext.getCmp('locatefeature_w').destroy();
-                                                    }
-                                                    
-                                                    this.form.findField('mapview').clearValue();
-                                                    this.updateValues = true;
-                                                    this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level, null, null);
-                                                    
-                                                    this.form.findField('boundary').setValue(node.attributes.text);
-                                                    Ext.getCmp('tree_w2').hide();
-                                                    
-                                                    this.loadGeoJson();
-                                                }
-                                            }
-                                        ]
-                                    });
-                                    
-                                    var x = Ext.getCmp('center').x + 15;
-                                    var y = Ext.getCmp('center').y + 41;
-                                    w.setPosition(x,y);
-                                    w.show();
-                                }
-                            });
+							this.createSingletonCmp.treeWindow.call(this);
                         }
                     }
                 }
@@ -703,9 +605,9 @@
         {
             xtype: 'textfield',
             name: 'level',
+            fieldLabel: i18n_level,
             disabled: true,
             disabledClass: 'combo-disabled',
-            fieldLabel: i18n_level,
             editable: false,
             emptyText: GLOBAL.conf.emptytext,
 			labelSeparator: GLOBAL.conf.labelseparator,
@@ -939,6 +841,103 @@
         ];
     },
     
+    createSingletonCmp: {
+		treeWindow: function() {
+			Ext.Ajax.request({
+				url: GLOBAL.conf.path_commons + 'getOrganisationUnits' + GLOBAL.conf.type,
+				params: {level: 1},
+				method: 'POST',
+				scope: this,
+				success: function(r) {
+					var rootNode = Ext.util.JSON.decode(r.responseText).organisationUnits[0];
+					GLOBAL.vars.topLevelUnit = {
+						id: rootNode.id,
+						name: rootNode.name,
+						hasChildrenWithCoordinates: rootNode.hasChildrenWithCoordinates
+					};
+					
+					var w = new Ext.Window({
+						title: 'Boundary',
+						closeAction: 'hide',
+						autoScroll: true,
+						height: 'auto',
+						autoHeight: true,
+						width: GLOBAL.conf.window_width,
+						items: [
+							{
+								xtype: 'panel',
+								bodyStyle: 'padding:8px; background-color:#ffffff',
+								items: [
+									{html: '<div class="window-info">Select outer boundary</div>'},
+									{
+										xtype: 'treepanel',
+										bodyStyle: 'background-color:#ffffff',
+										height: screen.height / 3,
+										autoScroll: true,
+										lines: false,
+										loader: new Ext.tree.TreeLoader({
+											dataUrl: GLOBAL.conf.path_mapping + 'getOrganisationUnitChildren' + GLOBAL.conf.type
+										}),
+										root: {
+											id: GLOBAL.vars.topLevelUnit.id,
+											text: GLOBAL.vars.topLevelUnit.name,
+											hasChildrenWithCoordinates: GLOBAL.vars.topLevelUnit.hasChildrenWithCoordinates,
+											nodeType: 'async',
+											draggable: false,
+											expanded: true
+										},
+										clickedNode: null,
+										listeners: {
+											'click': {
+												scope: this,
+												fn: function(n) {
+													this.form.findField('boundary').selectedNode = n;
+												}
+											}
+										}
+									}
+								]
+							}
+						],
+						bbar: [
+							'->',
+							{
+								xtype: 'button',
+								text: i18n_apply,
+								iconCls: 'icon-assign',
+								scope: this,
+								handler: function() {
+									var node = this.form.findField('boundary').selectedNode;
+									if (!node) {
+										return;
+									}
+
+									if (Ext.getCmp('locatefeature_w')) {
+										Ext.getCmp('locatefeature_w').destroy();
+									}
+									
+									this.form.findField('mapview').clearValue();
+									this.updateValues = true;
+									this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level, null, null);
+									this.form.findField('boundary').setValue(node.attributes.text);
+									
+									this.form.findField('boundary').treeWindow.hide();									
+									this.loadGeoJson();
+								}
+							}
+						]
+					});
+					
+					var x = Ext.getCmp('center').x + 15;
+					var y = Ext.getCmp('center').y + 41;
+					w.setPosition(x,y);
+					w.show();
+					this.form.findField('boundary').treeWindow = w;
+				}
+			});
+		}
+	},
+    
     createSelectFeatures: function() {
         var scope = this;