Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Stop using updatenode and the JsonController

Instead of using a separate file on the client-side (thebrain.js) and an ad-hoc
controller like JsonController, make the client-side code call the
NodesController directly which already supports JSON operations.
  • Loading branch information...
commit 5e241166271aa3c29c8e7d1386ca65c21434d0e1 1 parent 0b3f2f3
Daniel Martin authored
Showing with 23 additions and 28 deletions.
  1. +23 −2 public/javascripts/nodestree.js
  2. +0 −26 public/javascripts/thebrain.js
View
25 public/javascripts/nodestree.js
@@ -216,7 +216,27 @@ dradis.NodesTree = Ext.extend(Ext.tree.TreePanel, {
// Handle label edits
this.on('textchange', function(node, new_text, old_text){
- updatenode(node);
+ Ext.Ajax.request({
+ url: 'nodes/' + node.id + '.json',
+ method: 'put',
+ params: {
+ data: Ext.util.JSON.encode({ label: new_text })
+ },
+ success: function(response, options) {
+ dradisstatus.setStatus({
+ text: 'Node label edited',
+ clear: 5000
+ });
+ },
+ failure: function(response, options) {
+ dradisstatus.setStatus({
+ text: 'An error occured with the Ajax request',
+ iconCls: 'error',
+ clear: 5000
+ });
+ node.text = old_text;
+ }
+ });
});
// Handle node drops (drag'n'drop)
@@ -254,7 +274,8 @@ dradis.NodesTree = Ext.extend(Ext.tree.TreePanel, {
}
}
Ext.Ajax.request({
- url: 'json/node_update',
+ url: 'nodes/' + node.id + '.json',
+ method: 'put',
params: p,
success: function(response, options) {
dradisstatus.setStatus({
View
26 public/javascripts/thebrain.js
@@ -54,32 +54,6 @@ function delnode(node, callback){
}
-function updatenode(node, callback){
- var p = { id: node.id, label: node.text };
- if (node.parentNode.parentNode !== null) {
- p.parent_id = node.parentNode.id;
- }
- Ext.Ajax.request({
- url: 'json/node_update',
- params: p,
- success: function(response, options) {
- dradisstatus.setStatus({
- text: 'Node label edited',
- clear: 5000
- });
- dradis.revision += 1;
- },
- failure: function(response, options) {
- dradisstatus.setStatus({
- text: 'An error occured with the Ajax request',
- iconCls: 'error',
- clear: 5000
- });
- }
- })
-
-}
-
//------------------------------------------------------------------------ revision poller
Please sign in to comment.
Something went wrong with that request. Please try again.