← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1650: (GIS) Improved code.

 

------------------------------------------------------------
revno: 1650
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-03-15 15:51:22 +0100
message:
  (GIS) Improved code.
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/script/index.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	2010-03-10 14:41:28 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2010-03-15 14:51:22 +0000
@@ -124,7 +124,7 @@
 	padding:8px 0 0 0;
 }
 .window-orgunit-text {
-	padding:5px 5px 5px 7px;
+	padding:6px 6px 6px 8px;
 	font:normal 11px lucida sans unicode,arial;
 	color:#333;
 }

=== 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:43:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-03-15 14:51:22 +0000
@@ -3409,67 +3409,58 @@
         method: 'POST',
         params: { level: level, format: 'json' },
 
-        success: function( responseObject ) {
-            dataReceivedAutoAssignOrganisationUnit( responseObject.responseText, position );			
+        success: function(r) {
+		    var layers = MAP.getLayersByName('Thematic map');
+			var features = layers[0]['features'];
+			var organisationUnits = Ext.util.JSON.decode(r.responseText).organisationUnits;
+			var nameColumn = MAPDATA.nameColumn;
+			var mlp = MAPDATA.mapLayerPath;
+			var count_match = 0;
+			var relations = '';
+			var featureName, orgunitName;
+			
+			for ( var i = 0; i < features.length; i++ ) {
+				features[i].attributes.compareName = features[i].attributes[nameColumn].split(' ').join('').toLowerCase();
+			}
+	
+			for ( var i = 0; i < organisationUnits.length; i++ ) {
+				organisationUnits[i].compareName = organisationUnits[i].name.split(' ').join('').toLowerCase();
+			}
+			
+			for ( var i=0; i < organisationUnits.length; i++ ) {
+				for ( var j=0; j < features.length; j++ ) {
+					if (features[j].attributes.compareName == organisationUnits[i].compareName) {
+						count_match++;
+						relations += organisationUnits[i].id + '::' + features[j].attributes[nameColumn] + ';;';
+						break;
+					}
+				}
+			}
+			
+			MASK.msg = count_match == 0 ? 'No organisation units assigned...' : 'Assigning ' + count_match + ' organisation units...';
+			MASK.show();
+
+			Ext.Ajax.request({
+				url: path + 'addOrUpdateMapOrganisationUnitRelations' + type,
+				method: 'POST',
+				params: { mapLayerPath: mlp, relations: relations },
+
+				success: function( responseObject ) {
+					MASK.msg = 'Applying organisation units relations...';
+					MASK.show();
+					
+					Ext.messageBlack.msg('Assign organisation units', '<span class="x-msg-hl">' + count_match + '</span> organisation units assigned.<br><br>Database: <span class="x-msg-hl">' + organisationUnits.length + '</span><br>Shapefile: <span class="x-msg-hl">' + features.length + '</span>');
+					
+					Ext.getCmp('grid_gp').getStore().reload();
+					loadMapData(organisationUnitAssignment, position);
+				},
+				failure: function() {
+					alert( 'Error: addOrUpdateMapOrganisationUnitRelations' );
+				} 
+			});
         },
         failure: function() {
             alert( 'Status', 'Error while retrieving data' );
         } 
     });
 }
-
-function dataReceivedAutoAssignOrganisationUnit( responseText, position ) {
-    var layers = MAP.getLayersByName('Thematic map');
-    var features = layers[0]['features'];
-    var organisationUnits = Ext.util.JSON.decode(responseText).organisationUnits;
-    var nameColumn = MAPDATA.nameColumn;
-    var mlp = MAPDATA.mapLayerPath;
-    var count_match = 0;
-    var relations = '';
-	var featureName, orgunitName;
-	
-	for ( var i = 0; i < features.length; i++ ) {
-		features[i].attributes.compareName = features[i].attributes[nameColumn].split(' ').join('').toLowerCase();
-	}
-	
-	for ( var i = 0; i < organisationUnits.length; i++ ) {
-		organisationUnits[i].compareName = organisationUnits[i].name.split(' ').join('').toLowerCase();
-	}
-	
-    for ( var i=0; i < organisationUnits.length; i++ ) {
-        for ( var j=0; j < features.length; j++ ) {
-			if (features[j].attributes.compareName == organisationUnits[i].compareName) {
-                count_match++;
-                relations += organisationUnits[i].id + '::' + features[j].attributes[nameColumn] + ';;';
-				break;
-            }
-        }
-    }
-	
-	if (count_match == 0) {
-		MASK.msg = 'No organisation units assigned...';
-	}
-	else {
-		MASK.msg = 'Assigning ' + count_match + ' organisation units...';
-	}
-	MASK.show();
-
-    Ext.Ajax.request({
-        url: path + 'addOrUpdateMapOrganisationUnitRelations' + type,
-        method: 'POST',
-        params: { mapLayerPath: mlp, relations: relations },
-
-        success: function( responseObject ) {
-			MASK.msg = 'Applying organisation units relations...';
-			MASK.show();
-			
-            Ext.messageBlack.msg('Assign organisation units', '<span class="x-msg-hl">' + count_match + '</span> organisation units assigned.<br><br>Database: <span class="x-msg-hl">' + organisationUnits.length + '</span><br>Shapefile: <span class="x-msg-hl">' + features.length + '</span>');
-            
-            Ext.getCmp('grid_gp').getStore().reload();
-            loadMapData(organisationUnitAssignment, position);
-        },
-        failure: function() {
-            alert( 'Error: addOrUpdateMapOrganisationUnitRelations' );
-        } 
-    });                
-}
\ No newline at end of file