← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 519: (GIS, med) deleteMapOrganisationUnitRelations bug fixed. MapView confirmation messages improved.

 

------------------------------------------------------------
revno: 519
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-08-29 18:39:42 +0700
message:
  (GIS, med) deleteMapOrganisationUnitRelations bug fixed. MapView confirmation messages improved.
modified:
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java
  gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.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-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2009-08-20 18:52:55 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2009-08-29 11:39:42 +0000
@@ -218,7 +218,7 @@
     {
         Session session = sessionFactory.getCurrentSession();
 
-        Query query = session.createQuery( "delete from OrganisationUnitRelation where map = :map" );
+        Query query = session.createQuery( "delete from MapOrganisationUnitRelation where map = :map" );
 
         return query.setParameter( "map", map ).executeUpdate();
     }

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js'
--- gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-08-29 07:28:06 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-08-29 11:39:42 +0000
@@ -1190,6 +1190,7 @@
         url: path + 'getAllMapViews' + type,
         root: 'mapViews',
         fields: ['id', 'name'],
+        id: 'id',
         sortInfo: { field: 'name', direction: 'ASC' },
         autoLoad: true
     });
@@ -1232,7 +1233,7 @@
         handler: function() {
             var vn = Ext.getCmp('viewname_tf').getValue();
             var ig = Ext.getCmp('indicatorgroup_cb').getValue();
-            var i = Ext.getCmp('indicator_cb').getValue();
+            var ii = Ext.getCmp('indicator_cb').getValue();
             var pt = Ext.getCmp('periodtype_cb').getValue();
             var p = Ext.getCmp('period_cb').getValue();
             var mst = MAPSOURCE;
@@ -1241,7 +1242,7 @@
             var ca = Ext.getCmp('colorA_cf').getValue();
             var cb = Ext.getCmp('colorB_cf').getValue();
             
-            if (!vn || !ig || !i || !pt || !p || !mst || !ms || !c ) {
+            if (!vn || !ig || !ii || !pt || !p || !mst || !ms || !c ) {
                 Ext.messageRed.msg('New map view', 'Map view form is not complete.');
                 return;
             }
@@ -1252,17 +1253,36 @@
             }
             
             Ext.Ajax.request({
-                url: path + 'addOrUpdateMapView' + type,
-                method: 'POST',
-                params: { name: vn, indicatorGroupId: ig, indicatorId: i, periodTypeId: pt, periodId: p, mapSourceType: mst, mapSource: ms, method: 2, classes: c, colorLow: ca, colorHigh: cb },
+                url: path + 'getAllMapViews' + type,
+                method: 'GET',
+                success: function( responseObject ) {
+                    var mapViews = Ext.util.JSON.decode( responseObject.responseText ).mapViews;
+                    
+                    for (var i = 0; i < mapViews.length; i++) {
+                        if (mapViews[i].name == vn) {
+                            Ext.messageRed.msg('New map view', 'There is already a map view called ' + msg_highlight_start + vn + msg_highlight_end + '.');
+                            return;
+                        }
+                    }
+            
+                    Ext.Ajax.request({
+                        url: path + 'addOrUpdateMapView' + type,
+                        method: 'POST',
+                        params: { name: vn, indicatorGroupId: ig, indicatorId: ii, periodTypeId: pt, periodId: p, mapSourceType: mst, mapSource: ms, method: 2, classes: c, colorLow: ca, colorHigh: cb },
 
-                success: function( responseObject ) {
-                    Ext.messageBlack.msg('New map view', 'The view ' + msg_highlight_start + vn + msg_highlight_end + ' was registered.');
-                    Ext.getCmp('view_cb').getStore().reload();
-                    Ext.getCmp('mapview_cb').getStore().reload();
+                        success: function( responseObject ) {
+                            Ext.messageBlack.msg('New map view', 'The view ' + msg_highlight_start + vn + msg_highlight_end + ' was registered.');
+                            Ext.getCmp('view_cb').getStore().reload();
+                            Ext.getCmp('mapview_cb').getStore().reload();
+                            Ext.getCmp('viewname_tf').reset();
+                        },
+                        failure: function() {
+                            alert( 'Error: addOrUpdateMapView' );
+                        }
+                    });
                 },
                 failure: function() {
-                    alert( 'Status', 'Error while saving data' );
+                            alert( 'Error: getAllMapViews' );
                 }
             });
         }
@@ -1273,6 +1293,7 @@
         text: 'Delete view',
         handler: function() {
             var v = Ext.getCmp('view_cb').getValue();
+            var name = Ext.getCmp('view_cb').getStore().getById(v).get('name');
             
             if (!v) {
                 Ext.messageRed.msg('Delete map view', 'Please select a map view.');
@@ -1285,7 +1306,7 @@
                 params: { id: v },
 
                 success: function( responseObject ) {
-                    Ext.messageBlack.msg('Delete map view', 'The map view ' + v + ' was deleted.');
+                    Ext.messageBlack.msg('Delete map view', 'The map view ' + msg_highlight_start + name + msg_highlight_end + ' was deleted.');
                     Ext.getCmp('view_cb').getStore().reload();
                     Ext.getCmp('view_cb').reset();
                     Ext.getCmp('mapview_cb').getStore().reload();
@@ -1315,6 +1336,7 @@
 
                 success: function( responseObject ) {
                     Ext.messageBlack.msg('Dashboard map view', 'The view ' + v + ' was added to dashboard.');
+                    
                     Ext.getCmp('view_cb').getStore().reload();
                     Ext.getCmp('view_cb').reset();
                     Ext.getCmp('mapview_cb').getStore().reload();
@@ -2450,7 +2472,7 @@
         }
     }
     
-    Ext.messageBlack.msg('Assign organisation units', + msg_highlight_start + count_match.valueOf() + msg_highlight_end + ' organisation units assigned.<br><br>Database: ' + msg_highlight_start + count_orgunits/count_features + msg_highlight_end + '<br>Shapefile: ' + msg_highlight_start + count_features + msg_highlight_end);
+    Ext.messageBlack.msg('Assign organisation units', + msg_highlight_start + count_match + msg_highlight_end + ' organisation units assigned.<br><br>Database: ' + msg_highlight_start + count_orgunits/count_features + msg_highlight_end + '<br>Shapefile: ' + msg_highlight_start + count_features + msg_highlight_end);
     
     Ext.getCmp('grid_gp').getStore().reload();
     loadMapData('assignment');