← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3183: (GIS) Refresh and clear layer buttons implemented.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 3183 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-03-28 15:32:54 +0200
message:
  (GIS) Refresh and clear layer buttons implemented.
modified:
  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/javascript/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.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-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	2011-03-25 13:46:01 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2011-03-25 13:59:06 +0000
@@ -33,14 +33,11 @@
 	background-color:#F8F8F8;
 }
 .x-tree-node-leaf .x-tree-node-icon {
-    background-image:url('../../resources/ext-ux/theme/gray-extend-ux/leaf.gif');
-    background-position:center center;
+    background:url('../../resources/ext-ux/theme/gray-extend-ux/leaf.gif') center center;
     padding-right:1px;
 }
 #layertree_tp .x-tree-node-leaf .x-tree-node-icon {
-    background-image:url('../../../images/settings_small.png');
-    background-position:center 4px;
-    padding-right:0px;
+    background:url('../../../images/settings_small.png') center center no-repeat;
 }
 .x-btn-tl, .x-btn-tr, .x-btn-tc, .x-btn-ml, .x-btn-mr, .x-btn-mc, .x-btn-bl, .x-btn-br, .x-btn-bc {
 	background-image:url('../../resources/ext-ux/theme/gray-extend-ux/btn.gif');

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-03-25 10:22:40 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-03-28 12:02:08 +0000
@@ -508,13 +508,13 @@
 					}
                     
                     if (G.vars.activePanel.isPolygon()) {
-                        if (!choropleth.formValidation.validateForm(true)) {
+                        if (!choropleth.formValidation.validateForm.apply(choropleth, [true])) {
                             return;
                         }
                         params = choropleth.formValues.getAllValues.call(choropleth);
                     }
                     else if (G.vars.activePanel.isPoint()) {
-                        if (!symbol.formValidation.validateForm(true)) {
+                        if (!symbol.formValidation.validateForm.apply(symbol, [true])) {
                             return;
                         }
                         params = symbol.formValues.getAllValues.call(symbol);
@@ -709,8 +709,8 @@
                     var values, svg;
                     
                     if (polygonLayer.visibility && pointLayer.visibility) {
-                        if (choropleth.formValidation.validateForm()) {
-                            if (symbol.formValidation.validateForm()) {
+                        if (choropleth.formValidation.validateForm.call(choropleth)) {
+                            if (symbol.formValidation.validateForm.call(symbol)) {
                                 document.getElementById('layerField').value = 3;
                                 document.getElementById('imageLegendRowsField').value = choropleth.imageLegend.length;
                                 
@@ -739,7 +739,7 @@
                         }
                     }
                     else if (polygonLayer.visibility) {
-                        if (choropleth.formValidation.validateForm()) {
+                        if (choropleth.formValidation.validateForm.call(choropleth)) {
                             values = choropleth.formValues.getImageExportValues.call(choropleth);
                             document.getElementById('layerField').value = 1;
                             document.getElementById('periodField').value = values.dateValue;
@@ -753,7 +753,7 @@
                         }
                     }
                     else if (pointLayer.visibility) {
-                        if (symbol.formValidation.validateForm()) {
+                        if (symbol.formValidation.validateForm.call(symbol)) {
                             values = symbol.formValues.getImageExportValues.call(symbol);
                             document.getElementById('layerField').value = 2;
                             document.getElementById('periodField').value = values.dateValue;  
@@ -2255,19 +2255,27 @@
     /* Section: widgets */
     choropleth = new mapfish.widgets.geostat.Choropleth({
         id: 'choropleth',
+		title: '<span class="panel-title">' + G.i18n.polygon_layer + '</span>',
         map: G.vars.map,
         layer: polygonLayer,
-		title: '<span class="panel-title">' + G.i18n.polygon_layer + '</span>',
         featureSelection: false,
         legendDiv: 'polygonlegend',
         defaults: {width: 130},
         tools: [
             {
                 id: 'refresh',
+                qtip: 'Refresh layer',
                 handler: function() {
                     choropleth.updateValues = true;
                     choropleth.classify();
                 }
+            },
+            {
+                id: 'close',
+                qtip: 'Clear layer',
+                handler: function() {
+                    choropleth.formValues.clearForm.call(choropleth);
+                }
             }
         ],
         listeners: {
@@ -2291,10 +2299,18 @@
         tools: [
             {
                 id: 'refresh',
+                qtip: 'Refresh layer',
                 handler: function() {
                     symbol.updateValues = true;
                     symbol.classify();
                 }
+            },
+            {
+                id: 'close',
+                qtip: 'Clear layer',
+                handler: function() {
+                    symbol.formValues.clearForm.call(symbol);
+                }
             }
         ],
         listeners: {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-03-16 11:49:41 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-03-28 12:02:08 +0000
@@ -95,13 +95,13 @@
         this.requestSuccess(request);
 
         if (G.vars.activePanel.isPolygon()) {
-            if (!choropleth.formValidation.validateForm()) {
+            if (!choropleth.formValidation.validateForm.call(choropleth)) {
                 G.vars.mask.hide();
             }
             choropleth.classify(false);
         }
         else if (G.vars.activePanel.isPoint()) {
-            if (!symbol.formValidation.validateForm()) {
+            if (!symbol.formValidation.validateForm.call(symbol)) {
                 G.vars.mask.hide();
             }
             symbol.classify(false);

=== 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	2011-03-22 16:15:33 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-03-28 12:50:18 +0000
@@ -149,7 +149,12 @@
         this.legend = {
             value: G.conf.map_legend_type_automatic,
             method: G.conf.classify_by_equal_intervals,
-            classes: 5
+            classes: 5,
+            reset: function() {
+                this.value = G.conf.map_legend_type_automatic;
+                this.method = G.conf.classify_by_equal_intervals;
+                this.classes = 5;
+            }
         };
         
         this.organisationUnitSelection = {
@@ -589,6 +594,7 @@
             node: {attributes: {hasChildrenWithCoordinates: false}},
             selectedNode: null,
             treeWindow: null,
+            treePanel: null,
             listeners: {
                 'focus': {
                     scope: this,
@@ -613,8 +619,7 @@
 			labelSeparator: G.conf.labelseparator,
             width: G.conf.combo_width,
             style: 'cursor:pointer',
-            level: null,
-            levelName: null,
+            levelComboBox: null,
             listeners: {
                 'focus': {
                     scope: this,
@@ -881,7 +886,13 @@
 												fn: function(n) {
 													this.form.findField('boundary').selectedNode = n;
 												}
-											}
+											},
+                                            'afterrender': {
+                                                scope: this,
+                                                fn: function(tp) {
+                                                    this.form.findField('boundary').treePanel = tp;
+                                                }
+                                            }
 										}
 									}
 								]
@@ -895,7 +906,6 @@
 									{html: '<div class="window-info">Select organisation unit level</div>'},
 									{
 										xtype: 'combo',
-										id: 'level_cb',
 										fieldLabel: G.i18n.level,
 										editable: false,
 										valueField: 'level',
@@ -911,11 +921,10 @@
 										minListWidth: G.conf.combo_width_fieldset,
 										store: G.stores.polygonOrganisationUnitLevel,
 										listeners: {
-											'select': {
+											'afterrender': {
 												scope: this,
 												fn: function(cb) {
-													this.form.findField('level').level = cb.getValue();
-													this.form.findField('level').levelName = cb.getRawValue();
+													this.form.findField('level').levelComboBox = cb;
 												}
 											}
 										}
@@ -932,10 +941,10 @@
 								scope: this,
 								handler: function() {
 									var node = this.form.findField('boundary').selectedNode;
-									if (!node || !Ext.getCmp('level_cb').getValue()) {
+									if (!node || !this.form.findField('level').levelComboBox.getValue()) {
 										return;
 									}
-									if (node.attributes.level > this.form.findField('level').level) {
+									if (node.attributes.level > this.form.findField('level').levelComboBox.getValue()) {
 										Ext.message.msg(false, 'Level is higher than boundary level');
 										return;
 									}
@@ -947,10 +956,10 @@
 									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('level').levelComboBox.getValue(), this.form.findField('level').levelComboBox.getRawValue());
 										
 									this.form.findField('boundary').setValue(node.attributes.text);
-									this.form.findField('level').setValue(this.form.findField('level').levelName);
+									this.form.findField('level').setValue(this.form.findField('level').levelComboBox.getRawValue());
 									
 									this.form.findField('boundary').treeWindow.hide();									
 									this.loadGeoJson();
@@ -1277,17 +1286,16 @@
     
     formValidation: {
         validateForm: function(exception) {
-            var scope = choropleth;
-            if (scope.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_indicator) {
-                if (!scope.form.findField('indicator').getValue()) {
+            if (this.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_indicator) {
+                if (!this.form.findField('indicator').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
                     return false;
                 }
             }
-            else if (scope.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_dataelement) {
-                if (!scope.form.findField('dataelement').getValue()) {
+            else if (this.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_dataelement) {
+                if (!this.form.findField('dataelement').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1296,7 +1304,7 @@
             }
 
             if (G.system.mapDateType.isFixed()) {
-                if (!scope.form.findField('period').getValue()) {
+                if (!this.form.findField('period').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1304,7 +1312,7 @@
                 }
             }
             else {
-                if (!scope.form.findField('startdate').getValue() || !scope.form.findField('enddate').getValue()) {
+                if (!this.form.findField('startdate').getValue() || !this.form.findField('enddate').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1312,16 +1320,16 @@
                 }
             }
 
-            if (!scope.form.findField('boundary').getValue() || !scope.form.findField('level').getValue()) {
+            if (!this.form.findField('boundary').getValue() || !this.form.findField('level').getValue()) {
                 if (exception) {
                     Ext.message.msg(false, G.i18n.form_is_not_complete);
                 }
                 return false;
             }
 
-            if (scope.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_automatic) {
-                if (scope.form.findField('method').getValue() == G.conf.classify_with_bounds) {
-                    if (!scope.form.findField('bounds').getValue()) {
+            if (this.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_automatic) {
+                if (this.form.findField('method').getValue() == G.conf.classify_with_bounds) {
+                    if (!this.form.findField('bounds').getValue()) {
                         if (exception) {
                             Ext.message.msg(false, G.i18n.form_is_not_complete);
                         }
@@ -1329,8 +1337,8 @@
                     }
                 }
             }
-            else if (scope.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_predefined) {
-                if (!scope.form.findField('maplegendset').getValue()) {
+            else if (this.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_predefined) {
+                if (!this.form.findField('maplegendset').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1339,28 +1347,6 @@
             }
             
             return true;
-        },
-        
-        validateLevel: function(exception) {
-            var scope = choropleth;
-            if (scope.mapView || scope.idDrillDown) {
-                return true;
-            }
-            
-            if (scope.form.findField('boundary').getValue() && scope.form.findField('level').getValue()) {
-                if (scope.organisationUnitSelection.parent.level <= scope.organisationUnitSelection.level.level) {
-
-                    return true;
-                }
-                else {
-                    if (exception) {
-                        Ext.message.msg(false, 'Level is higher than boundary level');
-                    }
-                    return false;
-                }
-            }
-
-            return false;
         }
     },
     
@@ -1408,7 +1394,43 @@
 				dateValue: G.system.mapDateType.isFixed() ?
 					this.form.findField('period').getRawValue() : new Date(this.form.findField('startdate').getRawValue()).format('Y M j') + ' - ' + new Date(this.form.findField('enddate').getRawValue()).format('Y M j')
 			};
-		}
+		},
+        
+        clearForm: function() {            
+            this.form.findField('mapview').clearValue();            
+            
+            this.form.findField('mapvaluetype').setValue(G.conf.map_value_type_indicator);
+            this.valueType.setIndicator();
+            this.prepareMapViewValueType();
+            this.form.findField('indicatorgroup').clearValue();
+            this.form.findField('indicator').clearValue();
+            this.form.findField('dataelementgroup').clearValue();
+            this.form.findField('dataelement').clearValue();
+            
+            G.system.mapDateType.setFixed();
+            this.prepareMapViewDateType();
+            this.form.findField('periodtype').clearValue();
+            this.form.findField('period').clearValue();
+            this.form.findField('startdate').reset();
+            this.form.findField('enddate').reset();
+            
+            this.form.findField('boundary').reset();
+            this.form.findField('level').reset();
+            if (this.form.findField('boundary').treePanel && this.form.findField('level').levelComboBox) {
+                this.form.findField('boundary').treePanel.selectPath(this.form.findField('boundary').treePanel.getRootNode().getPath());
+                this.form.findField('level').levelComboBox.clearValue();
+            }
+            
+            this.legend.reset();
+            this.prepareMapViewLegend();
+            this.form.findField('method').setValue(this.legend.method);
+            this.form.findField('classes').setValue(this.legend.classes);
+            this.form.findField('bounds').reset();
+            
+            this.layer.destroyFeatures();
+            this.layer.setVisibility(false);
+            
+        }
 	},
     
     loadGeoJson: function() {
@@ -1422,7 +1444,7 @@
     },
 
     classify: function(exception, position) {
-        if (this.formValidation.validateForm(exception)) {
+        if (this.formValidation.validateForm.apply(this, [exception])) {
             G.vars.mask.msg = G.i18n.aggregating_map_values;
             G.vars.mask.show();
             

=== 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	2011-03-22 16:15:33 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-03-28 12:50:18 +0000
@@ -148,7 +148,12 @@
         this.legend = {
             value: G.conf.map_legend_type_automatic,
             method: G.conf.classify_by_equal_intervals,
-            classes: 5
+            classes: 5,
+            reset: function() {
+                this.value = G.conf.map_legend_type_automatic;
+                this.method = G.conf.classify_by_equal_intervals;
+                this.classes = 5;
+            }
         };
         
         this.organisationUnitSelection = {
@@ -588,6 +593,7 @@
             node: {attributes: {hasChildrenWithCoordinates: false}},
             selectedNode: null,
             treeWindow: null,
+			treePanel: null,
             listeners: {
                 'focus': {
                     scope: this,
@@ -613,8 +619,7 @@
             emptyText: G.conf.emptytext,
 			labelSeparator: G.conf.labelseparator,
             width: G.conf.combo_width,
-            level: null,
-            levelName: null
+			levelComboBox: null
         },
         
         { html: '<div class="thematic-br">' },
@@ -733,7 +738,15 @@
 			labelSeparator: G.conf.labelseparator,
             emptyText: G.i18n.comma_separated_values,
             width: G.conf.combo_width,
-            hidden: true
+            hidden: true,
+            listeners: {
+                'change': {
+                    scope: this,
+                    fn: function() {
+                        this.classify(false, true);
+                    }
+                }                
+            }
         },
         
         {
@@ -902,7 +915,13 @@
 												fn: function(n) {
 													this.form.findField('boundary').selectedNode = n;
 												}
-											}
+											},
+                                            'afterrender': {
+                                                scope: this,
+                                                fn: function(tp) {
+                                                    this.form.findField('boundary').treePanel = tp;
+                                                }
+                                            }
 										}
 									}
 								]
@@ -961,7 +980,7 @@
         
         var onHoverUnselect = function onHoverUnselect(feature) {
             if (feature.attributes.name) {
-                document.getElementById('featuredatatext').innerHTML = '<span style="color:#666">' + G.i18n.no_feature_selected + '</span>';
+                document.getElementById('featuredatatext').innerHTML = '<div style="color:#666">' + G.i18n.no_feature_selected + '</div>';
             }
             else {
                 document.getElementById('featuredatatext').innerHTML = '';
@@ -1012,7 +1031,6 @@
     
     prepareMapViewValueType: function() {
         var obj = {};
-
         if (this.valueType.isIndicator()) {
             this.form.findField('indicatorgroup').showField();
             this.form.findField('indicator').showField();
@@ -1122,7 +1140,6 @@
         
         function valueTypeGroupStoreCallback() {
             obj.components.valueTypeGroup.setValue(this.mapView[obj.mapView.valueTypeGroup]);
-            
             obj.stores.valueType.setBaseParam(obj.mapView.valueTypeGroup, obj.components.valueTypeGroup.getValue());
             obj.stores.valueType.load({scope: this, callback: function() {
                 obj.components.valueType.setValue(this.mapView[obj.mapView.valueType]);
@@ -1259,17 +1276,16 @@
     
     formValidation: {
         validateForm: function(exception) {
-            var scope = symbol;
-            if (scope.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_indicator) {
-                if (!scope.form.findField('indicator').getValue()) {
+            if (this.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_indicator) {
+                if (!this.form.findField('indicator').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
                     return false;
                 }
             }
-            else if (scope.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_dataelement) {
-                if (!scope.form.findField('dataelement').getValue()) {
+            else if (this.form.findField('mapvaluetype').getValue() == G.conf.map_value_type_dataelement) {
+                if (!this.form.findField('dataelement').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1278,7 +1294,7 @@
             }
 
             if (G.system.mapDateType.isFixed()) {
-                if (!scope.form.findField('period').getValue()) {
+                if (!this.form.findField('period').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1286,7 +1302,7 @@
                 }
             }
             else {
-                if (!scope.form.findField('startdate').getValue() || !scope.form.findField('enddate').getValue()) {
+                if (!this.form.findField('startdate').getValue() || !this.form.findField('enddate').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1294,16 +1310,16 @@
                 }
             }
 
-            if (!scope.form.findField('boundary').getValue() || !scope.form.findField('level').getValue()) {
+            if (!this.form.findField('boundary').getValue() || !this.form.findField('level').getValue()) {
                 if (exception) {
                     Ext.message.msg(false, G.i18n.form_is_not_complete);
                 }
                 return false;
             }
 
-            if (scope.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_automatic) {
-                if (scope.form.findField('method').getValue() == G.conf.classify_with_bounds) {
-                    if (!scope.form.findField('bounds').getValue()) {
+            if (this.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_automatic) {
+                if (this.form.findField('method').getValue() == G.conf.classify_with_bounds) {
+                    if (!this.form.findField('bounds').getValue()) {
                         if (exception) {
                             Ext.message.msg(false, G.i18n.form_is_not_complete);
                         }
@@ -1311,8 +1327,8 @@
                     }
                 }
             }
-            else if (scope.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_predefined) {
-                if (!scope.form.findField('maplegendset').getValue()) {
+            else if (this.form.findField('maplegendtype').getValue() == G.conf.map_legend_type_predefined) {
+                if (!this.form.findField('maplegendset').getValue()) {
                     if (exception) {
                         Ext.message.msg(false, G.i18n.form_is_not_complete);
                     }
@@ -1320,7 +1336,7 @@
                 }
             }
             
-            if (!scope.form.findField('radiuslow').getValue() || !scope.form.findField('radiushigh').getValue()) {
+            if (!this.form.findField('radiuslow').getValue() || !this.form.findField('radiushigh').getValue()) {
                 if (exception) {
                     Ext.message.msg(false, G.i18n.form_is_not_complete);
                 }
@@ -1328,28 +1344,6 @@
             }
             
             return true;
-        },
-        
-        validateLevel: function(exception) {
-            var scope = symbol;
-            if (scope.mapView || scope.idDrillDown) {
-                return true;
-            }
-            
-            if (scope.form.findField('boundary').getValue() && scope.form.findField('level').getValue()) {
-                if (scope.organisationUnitSelection.parent.level <= scope.organisationUnitSelection.level.level) {
-
-                    return true;
-                }
-                else {
-                    if (exception) {
-                        Ext.message.msg(false, 'Level is higher than boundary level');
-                    }
-                    return false;
-                }
-            }
-
-            return false;
         }
     },
     
@@ -1397,7 +1391,43 @@
 				dateValue: G.system.mapDateType.isFixed() ?
 					this.form.findField('period').getRawValue() : new Date(this.form.findField('startdate').getRawValue()).format('Y M j') + ' - ' + new Date(this.form.findField('enddate').getRawValue()).format('Y M j')
 			};
-		}
+		},
+        
+        clearForm: function() {            
+            this.form.findField('mapview').clearValue();            
+            
+            this.form.findField('mapvaluetype').setValue(G.conf.map_value_type_indicator);
+            this.valueType.setIndicator();
+            this.prepareMapViewValueType();
+            this.form.findField('indicatorgroup').clearValue();
+            this.form.findField('indicator').clearValue();
+            this.form.findField('dataelementgroup').clearValue();
+            this.form.findField('dataelement').clearValue();
+            
+            G.system.mapDateType.setFixed();
+            this.prepareMapViewDateType();
+            this.form.findField('periodtype').clearValue();
+            this.form.findField('period').clearValue();
+            this.form.findField('startdate').reset();
+            this.form.findField('enddate').reset();
+            
+            this.form.findField('boundary').reset();
+            if (this.form.findField('boundary').treePanel) {
+                this.form.findField('boundary').treePanel.selectPath(this.form.findField('boundary').treePanel.getRootNode().getPath());
+            }
+            
+            this.legend.reset();
+            this.prepareMapViewLegend();
+            this.form.findField('method').setValue(this.legend.method);
+            this.form.findField('classes').setValue(this.legend.classes);
+            this.form.findField('bounds').reset();
+            
+            this.form.findField('radiuslow').reset();
+            this.form.findField('radiushigh').reset();
+            
+            this.layer.destroyFeatures();
+            this.layer.setVisibility(false);            
+        }
 	},
     
     loadGeoJson: function() {
@@ -1411,7 +1441,7 @@
     },
 
     classify: function(exception, position) {
-        if (this.formValidation.validateForm(exception)) {
+        if (this.formValidation.validateForm.apply(this, [exception])) {
             G.vars.mask.msg = G.i18n.aggregating_map_values;
             G.vars.mask.show();