Commit 429f876c4df01e586c37d189bee5dbc0a8e8d271

Authored by Benjamin Renard
1 parent 3a420953

Fix plot request deletion

js/app/models/InteractiveNode.js
... ... @@ -52,7 +52,7 @@ Ext.define('amdaModel.InteractiveNode', {
52 52 {
53 53 node.eachChild(function(n)
54 54 {
55   - if (!n.isLoaded() && !n.isLeaf())
  55 + if (!n.isLoaded() && !n.isRealLeaf())
56 56 {
57 57 nodesToLoad.push(n);
58 58 me.preloadTreeNode(n,nodesToLoad,onloaded);
... ... @@ -70,7 +70,7 @@ Ext.define('amdaModel.InteractiveNode', {
70 70 {
71 71 records.forEach(function (record)
72 72 {
73   - if (!record.isLoaded() && !record.isLeaf())
  73 + if (!record.isLoaded() && !record.isRealLeaf())
74 74 {
75 75 nodesToLoad.push(record);
76 76 me.preloadTreeNode(record,nodesToLoad,onloaded);
... ... @@ -99,6 +99,11 @@ Ext.define('amdaModel.InteractiveNode', {
99 99 }
100 100 }
101 101 },
  102 +
  103 + isRealLeaf: function()
  104 + {
  105 + return this.isLeaf();
  106 + },
102 107  
103 108 /**
104 109 * this method is overriden into ExecutableNode to return true
... ... @@ -146,7 +151,7 @@ Ext.define('amdaModel.InteractiveNode', {
146 151 */
147 152 rename: function(value,callBackFn)
148 153 {
149   - var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')};
  154 + var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')};
150 155 AmdaAction.renameObject(dataToSend, callBackFn);
151 156 },
152 157  
... ... @@ -155,7 +160,7 @@ Ext.define('amdaModel.InteractiveNode', {
155 160 */
156 161 renameDD: function(parentId, callBackFn)
157 162 {
158   - var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')};
  163 + var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')};
159 164 AmdaAction.renameObject(dataToSend, callBackFn);
160 165 },
161 166  
... ... @@ -166,7 +171,7 @@ Ext.define('amdaModel.InteractiveNode', {
166 171 */
167 172 isValidName : function(name, callBackFn)
168 173 {
169   - var dataToSend = {name: name, nodeType: this.get('nodeType'), leaf: this.isLeaf()};
  174 + var dataToSend = {name: name, nodeType: this.get('nodeType'), leaf: this.isRealLeaf()};
170 175 AmdaAction.validNameObject(dataToSend, callBackFn);
171 176 },
172 177  
... ... @@ -515,7 +520,7 @@ Ext.define('amdaModel.InteractiveNode', {
515 520  
516 521 deleteNode: function() {
517 522 // if the target is a directory
518   - if (!this.isLeaf()) {
  523 + if (!this.isRealLeaf()) {
519 524 // determine if this directory is empty before launching the delete confirmation method
520 525 this.isNotEmptyDir(this.confirmDirectoryDeletion);
521 526 // else (the target is a leaf)
... ... @@ -568,14 +573,14 @@ Ext.define('amdaModel.InteractiveNode', {
568 573 */
569 574 realDelete : function()
570 575 {
571   - AmdaAction.deleteObject({id: this.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}, function(res,e){
  576 + AmdaAction.deleteObject({id: this.get('id'), leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}, function(res,e){
572 577 //TODO proper errors handling
573 578 // node deletion in tree
574 579 if (res) { // if success
575 580 if (res.id) {
576 581 //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK});
577 582 if (this.parentNode) {
578   - if (this.isLeaf()){
  583 + if (this.isRealLeaf()){
579 584 var moduleId = this.get('moduleId');
580 585 // if really interactive node
581 586 if (moduleId) {
... ...
js/app/models/PlotNode.js
... ... @@ -135,16 +135,10 @@ Ext.define('amdaModel.PlotNode', {
135 135 }
136 136 },
137 137  
138   - rename: function(value,callBackFn) {
  138 + isRealLeaf: function()
  139 + {
139 140 var isFolder = (!this.isLeaf()) && (this.get('tabs') === false);
140   - var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: !isFolder, nodeType: this.get('nodeType')};
141   - AmdaAction.renameObject(dataToSend, callBackFn);
142   - },
143   -
144   - renameDD: function(parentId, callBackFn) {
145   - var isFolder = (!this.isLeaf()) && (this.get('tabs') === false);
146   - var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: !isFolder, nodeType: this.get('nodeType')};
147   - AmdaAction.renameObject(dataToSend, callBackFn);
  141 + return !isFolder;
148 142 },
149 143  
150 144 insertPlotTabsRequest: function() {
... ...