← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13404: gis rename map request migrated to web api

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 13404 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-23 16:34:26 +0100
message:
  gis rename map request migrated to web api
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.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/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2013-12-23 12:53:42 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/app.js	2013-12-23 15:33:38 +0000
@@ -2586,16 +2586,29 @@
 			updateButton = Ext.create('Ext.button.Button', {
 				text: GIS.i18n.update,
 				handler: function() {
-					var name = nameTextfield.getValue();
-
-					Ext.Ajax.request({
-						url: gis.init.contextPath + gis.conf.finals.url.path_module + 'renameMap.action?id=' + id + '&name=' + name + '&user=true',
-						success: function() {
-							gis.store.maps.loadStore();
-
-							window.destroy();
-						}
-					});
+					var name = nameTextfield.getValue(),
+                        map;
+
+                    Ext.Ajax.request({
+                        url: gis.init.contextPath + '/api/maps/' + id + '.json?viewClass=dimensional&links=false',
+                        success: function(r) {
+                            map = Ext.decode(r.responseText);
+
+                            map.name = name;
+
+                            Ext.Ajax.request({
+                                url: gis.init.contextPath + '/api/maps/' + id,
+                                method: 'PUT',
+                                headers: {'Content-Type': 'application/json'},
+                                params: Ext.encode(map),
+                                success: function() {
+                                    gis.store.maps.loadStore();
+
+                                    window.destroy();
+                                }
+                            });
+                        }
+                    });
 				}
 			});