← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1649: (GIS) Filter behaviour improved + improved code.

 

------------------------------------------------------------
revno: 1649
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-03-15 15:43:49 +0100
message:
  (GIS) Filter behaviour improved + improved code.
modified:
  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/Mapping.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/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-03-15 14:28:53 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-03-15 14:43:49 +0000
@@ -3345,8 +3345,51 @@
         method: 'GET',
         params: { mapLayerPath: mlp, format: 'json' },
 
-        success: function( responseObject ) {
-            dataReceivedAssignOrganisationUnit( responseObject.responseText );
+        success: function(r) {
+			var layers = MAP.getLayersByName('Thematic map');
+			features = layers[0]['features'];
+			var relations = Ext.util.JSON.decode(r.responseText).mapOrganisationUnitRelations;
+			var nameColumn = MAPDATA.nameColumn;
+			var noCls = 1;
+			var noAssigned = 0;
+			var options = {};
+			
+			for (var i = 0; i < features.length; i++) {
+				features[i].attributes['value'] = 0;
+			
+				for (var j=0; j < relations.length; j++) {
+					if (relations[j].featureId == features[i].attributes[nameColumn]) {
+						features[i].attributes['value'] = 1;
+						noAssigned++;
+						if (noCls < 2) {
+							noCls = 2;
+						}
+						break;
+					}
+				}
+			}
+	
+			var color = noCls > 1 && noAssigned == features.length ? assigned_row_color : unassigned_row_color;
+			noCls = noCls > 1 && noAssigned == features.length ? 1 : noCls;
+			
+			mapping.indicator = 'value';
+			mapping.indicatorText = 'Indicator';
+			options.indicator = mapping.indicator;
+			
+			options.method = 1;
+			options.numClasses = noCls;
+			
+			var colorA = new mapfish.ColorRgb();
+			colorA.setFromHex(color);
+			var colorB = new mapfish.ColorRgb();
+			colorB.setFromHex(assigned_row_color);
+			options.colors = [colorA, colorB];
+			
+			mapping.coreComp.updateOptions(options);
+			mapping.coreComp.applyClassification();
+			mapping.classificationApplied = true;
+			
+			MASK.hide();
         },
         failure: function() {
             alert( 'Error while retrieving data: getAssignOrganisationUnitData' );
@@ -3354,53 +3397,6 @@
     });
 }
 
-function dataReceivedAssignOrganisationUnit( responseText ) {
-    var layers = MAP.getLayersByName('Thematic map');
-    features = layers[0]['features'];
-    var relations = Ext.util.JSON.decode(responseText).mapOrganisationUnitRelations;
-    var nameColumn = MAPDATA.nameColumn;
-	var noCls = 1;
-	var noAssigned = 0;
-	var options = {};
-	
-	for (var i = 0; i < features.length; i++) {
-        features[i].attributes['value'] = 0;
-        
-        for (var j=0; j < relations.length; j++) {
-            if (relations[j].featureId == features[i].attributes[nameColumn]) {
-                features[i].attributes['value'] = 1;
-				noAssigned++;
-				if (noCls < 2) {
-					noCls = 2;
-				}
-				break;
-            }
-        }
-    }
-	
-	var color = noCls > 1 && noAssigned == features.length ? assigned_row_color : unassigned_row_color;
-	noCls = noCls > 1 && noAssigned == features.length ? 1 : noCls;
-	
-    mapping.indicator = 'value';
-    mapping.indicatorText = 'Indicator';
-    options.indicator = mapping.indicator;
-    
-    options.method = 1;
-    options.numClasses = noCls;
-    
-    var colorA = new mapfish.ColorRgb();
-    colorA.setFromHex(color);
-    var colorB = new mapfish.ColorRgb();
-    colorB.setFromHex(assigned_row_color);
-    options.colors = [colorA, colorB];
-    
-    mapping.coreComp.updateOptions(options);
-    mapping.coreComp.applyClassification();
-    mapping.classificationApplied = true;
-    
-    MASK.hide();
-}
-
 /*AUTO MAPPING*/
 function getAutoAssignOrganisationUnitData(position) {
 	MASK.msg = 'Loading data...';

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js	2010-03-15 14:28:53 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js	2010-03-15 14:43:49 +0000
@@ -385,6 +385,7 @@
 													Ext.getCmp('grid_gp').getStore().reload();
 													popup.hide();
 													mapping.relation = false;
+													Ext.getCmp('filter_tf').setValue('');
 													loadMapData(organisationUnitAssignment, true);
 												},
 												failure: function() {