← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1415: (GIS) "GIS map-orgunit assignment should be from map to orgunit list" implemented.

 

------------------------------------------------------------
revno: 1415
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-02-11 12:44:33 +0100
message:
  (GIS) "GIS map-orgunit assignment should be from map to orgunit list" implemented.
  
  https://bugs.launchpad.net/dhis2/+bug/496984
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-02-10 22:20:26 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-02-11 11:44:33 +0000
@@ -2870,48 +2870,31 @@
 });
 
 /*SELECT FEATURES*/
+
+var feature_popup = new Ext.Window({
+	title: '<font style="' + AA_DARK + '">Assign organisation unit</font>',
+	width: 190,
+	height: 71,
+	closeAction: 'hide',
+	layout: 'fit',
+	plain: true,
+	bodyStyle: 'padding:5px',
+	listeners: {
+		'hide': {
+			fn: function() {
+				mapping.relation = false;
+			}
+		}
+	}
+});
+
+
 function onHoverSelectChoropleth(feature) {
-    var east_panel = Ext.getCmp('east');
-    var x = east_panel.x - 210;
-    var y = east_panel.y + 41;
-    
     if (MAPDATA != null) {
         if (ACTIVEPANEL == 'choropleth') {
-/*            
-			popup_feature = new Ext.Window({
-                title: '<font style="' + AA_DARK + '">Organisation unit</font>',
-                width: 190,
-                height: 90,// + 60,
-                layout: 'fit',
-                plain: true,
-                bodyStyle: 'padding:5px',
-                x: x,
-                y: y
-            });    
-            
-            popup_feature.html = html;
-            popup_feature.show();
-*/			
-
 			Ext.getCmp('featureinfo_l').setText('<font style="color:black">' + feature.attributes[MAPDATA.nameColumn] + '</font><br><font style="color:#666">' + feature.attributes.value + '</font>', false);
         }
         else if (ACTIVEPANEL == 'mapping') {
-/*            popup_feature = new Ext.Window({
-                title: '<font style="' + AA_DARK + '">Organisation unit</font>',
-                width: 190,
-                height: 71,
-                layout: 'fit',
-                plain: true,
-                bodyStyle: 'padding:5px',
-                x: x,
-                y: y
-            });    
-
-			var html = '<p style="margin-top: 5px; padding-left:5px; padding-bottom:3px; ' + AA_MED + '">' + feature.attributes[MAPDATA.nameColumn] + '</p>';
-            
-            popup_feature.html = html;
-            popup_feature.show();
-*/
 			Ext.getCmp('featureinfo_l').setText('<font style="color:black">' + feature.attributes[MAPDATA.nameColumn] + '</font>', false);
         }
     }
@@ -2922,54 +2905,16 @@
 }
 
 function onClickSelectChoropleth(feature) {
+	var east_panel = Ext.getCmp('east');
+	var x = east_panel.x - 210;
+	var y = east_panel.y + 41;
+	
     if (ACTIVEPANEL == 'mapping') {
-		var selected = Ext.getCmp('grid_gp').getSelectionModel().getSelected();
-        if (!selected) {
-            Ext.messageRed.msg('Assign organisation units', 'Please select an organisation unit in the list first.');
-            return;
-        }
-		
-        var featureId = feature.attributes[MAPDATA.nameColumn];
-		var mlp = Ext.getCmp('maps_cb').getValue();
-		
-		Ext.Ajax.request({
-			url: path + 'getMapOrganisationUnitRelationByFeatureId' + type,
-            method: 'POST',
-			params: {featureId:featureId, mapLayerPath:mlp},
-			
-			success: function( responseObject ) {
-				var mour = Ext.util.JSON.decode( responseObject.responseText ).mapOrganisationUnitRelation[0];
-				var selected;
-				
-				if (mour.featureId == '') {
-					selected = Ext.getCmp('grid_gp').getSelectionModel().getSelected();
-					var organisationUnitId = selected.data.organisationUnitId;
-					var organisationUnit = selected.data.organisationUnit;
-
-					Ext.Ajax.request({
-						url: path + 'addOrUpdateMapOrganisationUnitRelation' + type,
-						method: 'GET',
-						params: { mapLayerPath: MAPDATA.mapLayerPath, organisationUnitId: organisationUnitId, featureId: featureId },
-
-						success: function( responseObject ) {
-							Ext.messageBlack.msg('Assign organisation units', msg_highlight_start + organisationUnit + msg_highlight_end + ' (database) assigned to ' + msg_highlight_start + featureId + msg_highlight_end + ' (map).');
-							Ext.getCmp('grid_gp').getStore().reload();
-							popup_feature.hide();
-							loadMapData('assignment');
-						},
-						failure: function() {
-							alert( 'Error: addOrUpdateMapOrganisationUnitRelation' );
-						} 
-					});
-				}
-				else {
-					Ext.messageRed.msg('Assign organisation units', msg_highlight_start + featureId + msg_highlight_end + ' is already assigned.');
-				}
-			},
-			failure: function() {
-				alert('Error: getMapOrganisationUnitRelationByFeatureId');
-			}
-		});
+		feature_popup.html = '<p style="margin-top: 5px; padding-left:5px; padding-bottom:3px; ' + AA_MED + '">' + feature.attributes[MAPDATA.nameColumn] + '</p>';
+		feature_popup.x = x;
+		feature_popup.y = y;
+		feature_popup.show();
+		mapping.relation = feature.attributes[MAPDATA.nameColumn];
     }
 	else {
 		MAP.setCenter(feature.geometry.getBounds().getCenterLonLat(), MAP.getZoom()+1);

=== 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-02-09 15:55:32 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js	2010-02-11 11:44:33 +0000
@@ -117,7 +117,7 @@
      * APIProperty: loadMask
      *     An Ext.LoadMask config or true to mask the widget while loading (defaults to false).
      */
-    loadMask : false,
+    loadMask: false,
 
     /**
      * APIProperty: labelGenerator
@@ -125,7 +125,7 @@
      */
     labelGenerator: null,
 
-    getGridPanelHeight : function() {
+    getGridPanelHeight: function() {
         var h = screen.height;
         
         if (h <= 800) {
@@ -142,14 +142,10 @@
         }
     },
      
-    newUrl : false,
-	
-	
+    newUrl: false,
+	
+	relation: false,
     
-    /**
-     * Method: initComponent
-     *    Inits the component
-     */    
     initComponent : function() {
     
         mapStore = new Ext.data.JsonStore({
@@ -248,14 +244,14 @@
                 id: 'grid_gp',
                 store: gridStore,
                 columns: [ { header: 'Organisation units ', id: 'organisationUnitId', dataIndex: 'organisationUnit', sortable: true, width: gridpanel_width } ],
-				  autoExpandColumn: 'organisationUnitId',
-				  enableHdMenu: true,
+				autoExpandColumn: 'organisationUnitId',
+				enableHdMenu: true,
                 width: gridpanel_width,
                 height: this.getGridPanelHeight(),				 
                 view: gridView,
                 style: 'left:0px',
                 bbar: new Ext.StatusBar({
-						defaultText: '',
+					defaultText: '',
                     id: 'relations_sb',
                     items:
                     [
@@ -366,7 +362,46 @@
                             scope: this
                         }
                     ]
-                })
+                }),
+				listeners: {
+					'cellclick': {
+						fn: function(grid, rowIndex) {
+							if (mapping.relation) {
+								var id = grid.getStore().getAt(rowIndex).get('organisationUnitId');
+								var name = grid.getStore().getAt(rowIndex).get('organisationUnit');
+								var mlp = Ext.getCmp('maps_cb').getValue();
+								
+								Ext.Ajax.request({
+									url: path + 'getMapOrganisationUnitRelationByFeatureId' + type,
+									method: 'POST',
+									params: {featureId:mapping.relation, mapLayerPath:mlp},
+									success: function( responseObject ) {
+										var mour = Ext.util.JSON.decode( responseObject.responseText ).mapOrganisationUnitRelation[0];
+										if (mour.featureId == '') {
+											Ext.Ajax.request({
+												url: path + 'addOrUpdateMapOrganisationUnitRelation' + type,
+												method: 'POST',
+												params: { mapLayerPath:mlp, organisationUnitId:id, featureId:name },
+												success: function( responseObject ) {
+													Ext.messageBlack.msg('Assign organisation units', msg_highlight_start + mapping.relation + msg_highlight_end + ' (map) assigned to ' + msg_highlight_start + name + msg_highlight_end + ' (database).');
+													Ext.getCmp('grid_gp').getStore().reload();
+													feature_popup.hide();
+													loadMapData('assignment');
+												},
+												failure: function() {
+													alert( 'Error: addOrUpdateMapOrganisationUnitRelation' );
+												} 
+											});
+										}
+										else {
+											Ext.messageRed.msg('Assign organisation units', msg_highlight_start + name + msg_highlight_end + ' is already assigned.');
+										}
+									}
+								});
+							}
+						}
+					}
+				}
              }
         ];