← Back to team overview

dhis2-devs team mailing list archive

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

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2288 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-09-30 13:58:49 +0200
message:
  (GIS) 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/mapping/script/util.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/Mapping.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/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-30 11:07:08 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-09-30 11:57:08 +0000
@@ -6,11 +6,6 @@
 var MAPSOURCE;
 /* Fixed periods or from-to dates */
 var MAPDATETYPE;
-/* A map object */
-var MAPDATA = {};
-// MAPDATA[thematicMap] = {};
-// MAPDATA[thematicMap2] = {};
-MAPDATA[organisationUnitAssignment] = {};
 /* Filename or level */
 var URL;
 /* Active mapview id parameter from URL */
@@ -19,11 +14,6 @@
 var ACTIVEPANEL;
 /* Mask */
 var MASK;
-/* Labels activated (boolean) */
-var LABELS = {};
-LABELS[thematicMap] = false;
-LABELS[thematicMap2] = false;
-LABELS[organisationUnitAssignment] = false;
 /* Legend colors for export */
 var COLORINTERPOLATION;
 /* Export values */
@@ -3082,14 +3072,22 @@
                                         if (layer.features.length > 0) {
                                             if (layer.name == 'Polygon layer') {
                                                 if (ACTIVEPANEL == thematicMap) {
-                                                    GLOBALS.util.toggleFeatureLabelsPolygons(layer);
+                                                    GLOBALS.util.toggleFeatureLabels(choropleth);
+                                                }
+                                                else if (ACTIVEPANEL == organisationUnitAssignment) {
+                                                    GLOBALS.util.toggleFeatureLabelsAssignment(true, mapping);
                                                 }
                                                 else {
-                                                    GLOBALS.util.toggleFeatureLabelsAssignment(true, layer);
+                                                    Ext.message.msg(false, 'Please use <span class="x-msg-hl">Point layer</span> options');
                                                 }
                                             }
                                             else if (layer.name == 'Point layer') {
-                                                GLOBALS.util.toggleFeatureLabelsPoints(layer);
+                                                if (ACTIVEPANEL == thematicMap2) {
+                                                    GLOBALS.util.toggleFeatureLabels(proportionalSymbol);
+                                                }
+                                                else {
+                                                    Ext.message.msg(false, 'Please use <span class="x-msg-hl">Polygon layer</span> options');
+                                                }
                                             }
                                         }
                                         else {
@@ -3971,7 +3969,7 @@
     FEATURE[thematicMap] = feature;
 
     if (ACTIVEPANEL == organisationUnitAssignment) {
-        Ext.getCmp('featureinfo_l').setText('<span style="color:black">' + FEATURE[thematicMap].attributes[MAPDATA[organisationUnitAssignment].nameColumn] + '</span>', false);
+        Ext.getCmp('featureinfo_l').setText('<span style="color:black">' + FEATURE[thematicMap].attributes[mapping.mapData.nameColumn] + '</span>', false);
     }
     else {
         Ext.getCmp('featureinfo_l').setText('<div style="color:black">' + FEATURE[thematicMap].attributes[choropleth.mapData.nameColumn] + '</div><div style="color:#555">' + FEATURE[thematicMap].attributes.value + '</div>', false);
@@ -4014,7 +4012,7 @@
 			height: 65,
 			layout: 'fit',
 			plain: true,
-			html: '<div class="window-orgunit-text">' + FEATURE[thematicMap].attributes[MAPDATA[organisationUnitAssignment].nameColumn] + '</div>',
+			html: '<div class="window-orgunit-text">' + FEATURE[thematicMap].attributes[mapping.mapData.nameColumn] + '</div>',
 			x: x,
 			y: y,
 			listeners: {
@@ -4028,7 +4026,7 @@
 		
 		popup = feature_popup;		
 		feature_popup.show();
-		mapping.relation = FEATURE[thematicMap].attributes[MAPDATA[organisationUnitAssignment].nameColumn];
+		mapping.relation = FEATURE[thematicMap].attributes[mapping.mapData.nameColumn];
     }
 	//else {
         // featureWindow.setPagePosition(Ext.getCmp('east').x - 202, Ext.getCmp('center').y + 41);

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js	2010-09-30 11:07:08 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js	2010-09-30 11:57:08 +0000
@@ -1,5 +1,4 @@
 var GLOBALS = {};
-
 GLOBALS.util = {
     
     /* Detect mapview parameter in URL */
@@ -66,7 +65,7 @@
         return tmp.indexOf(dec_sep) > -1 ? tmp.length-tmp.indexOf(dec_sep) - 1 : 0;
     },
 
-    /* Toggle feature labels */
+    /* Feature labels */
     labels: {    
         getActivatedOpenLayersStyleMap: function() {
             return new OpenLayers.StyleMap({
@@ -108,46 +107,24 @@
         }
     },
 
-    toggleFeatureLabelsPolygons: function(layer) {    
-        function activateLabels(scope) {
-            layer.styleMap = scope.labels.getActivatedOpenLayersStyleMap();
-            LABELS[thematicMap] = true;
-        }
-        function deactivateLabels(scope) {
-            layer.styleMap = scope.labels.getDeactivatedOpenLayersStyleMap();
-            LABELS[thematicMap] = false;
-        }
-        
-        if (LABELS[thematicMap]) {
-            deactivateLabels(this);
-        }
-        else {
-            activateLabels(this);
-        }
-        
-        FEATURE[thematicMap] = layer.features;
-        choropleth.applyValues();
-    },
-
-    toggleFeatureLabelsPoints: function(layer) {        
-        function activateLabels(scope) {
-            layer.styleMap = scope.labels.getActivatedOpenLayersStyleMap();
-            LABELS[thematicMap2] = true;
-        }
-        function deactivateLabels(scope) {
-            layer.styleMap = scope.labels.getDeactivatedOpenLayersStyleMap();
-            LABELS[thematicMap2] = false;
-        }
-        
-        if (LABELS[thematicMap2]) {
-            deactivateLabels(this);
-        }
-        else {
-            activateLabels(this);
-        }
-        
-        FEATURE[thematicMap2] = layer.features;
-        proportionalSymbol.applyValues();
+    toggleFeatureLabels: function(widget) {
+        function activateLabels(scope) {
+            widget.layer.styleMap = scope.labels.getActivatedOpenLayersStyleMap();
+            widget.labels = true;
+        }
+        function deactivateLabels(scope) {
+            widget.layer.styleMap = scope.labels.getDeactivatedOpenLayersStyleMap();
+            widget.labels = false;
+        }
+        
+        if (widget.labels) {
+            deactivateLabels(this);
+        }
+        else {
+            activateLabels(this);
+        }
+        
+        widget.applyValues();
     },
 
     toggleFeatureLabelsAssignment: function(classify, layer) {

=== 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-09-30 11:07:08 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2010-09-30 11:57:08 +0000
@@ -68,6 +68,8 @@
 
     mapData: false,
     
+    labels: false,
+    
     stores: false,
     
     initComponent: function() {

=== 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-09-30 11:07:08 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js	2010-09-30 11:57:08 +0000
@@ -74,6 +74,8 @@
 	relation: false,
     
     mapData: false,
+    
+    labels: false,
 	
     initComponent : function() {
         
@@ -299,20 +301,20 @@
 									url: path_mapping + 'getMapOrganisationUnitRelationByFeatureId' + type,
 									method: 'POST',
 									params: {featureId:mapping.relation, mapLayerPath:mlp},
-									success: function( responseObject ) {
-										var mour = Ext.util.JSON.decode( responseObject.responseText ).mapOrganisationUnitRelation[0];
+									success: function(r) {
+										var mour = Ext.util.JSON.decode(r.responseText).mapOrganisationUnitRelation[0];
 										if (mour.featureId == '') {
 											Ext.Ajax.request({
 												url: path_mapping + 'addOrUpdateMapOrganisationUnitRelation' + type,
 												method: 'POST',
-												params: { mapLayerPath:mlp, organisationUnitId:id, featureId:mapping.relation },
-												success: function( responseObject ) {
+												params: {mapLayerPath:mlp, organisationUnitId:id, featureId:mapping.relation},
+												success: function() {
 													Ext.message.msg(true, '<span class="x-msg-hl">' + mapping.relation + '</span> (' + i18n_in_the_map + ') ' + i18n_assigned_to + ' <span class="x-msg-hl">' + name + '</span> (' + i18n_database + ').');
 													Ext.getCmp('grid_gp').getStore().load();
 													popup.hide();
 													mapping.relation = false;
 													Ext.getCmp('filter_tf').setValue('');
-													mapping.classify(true);
+													mapping.classify(true, true);
 												},
 												failure: function() {
 													alert( 'Error: addOrUpdateMapOrganisationUnitRelation' );
@@ -519,7 +521,7 @@
                     var noAssigned = 0;
         
                     for (var i = 0; i < FEATURE[thematicMap].length; i++) {
-                        FEATURE[thematicMap][i].attributes['value'] = 0;
+                        FEATURE[thematicMap][i].attributes.value = 0;
 
                         for (var j = 0; j < relations.getTotalCount(); j++) {
                             if (relations.getAt(j).data.featureId == FEATURE[thematicMap][i].attributes[nameColumn]) {

=== 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-09-30 11:07:08 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2010-09-30 11:57:08 +0000
@@ -67,6 +67,8 @@
     mapView: false,
 
     mapData: false,
+    
+    labels: false,
 
     initComponent: function() {
         this.legend = {};