From 429f876c4df01e586c37d189bee5dbc0a8e8d271 Mon Sep 17 00:00:00 2001 From: Benjamin Renard <benjamin.renard@akka.eu> Date: Thu, 9 May 2019 15:32:29 +0200 Subject: [PATCH] Fix plot request deletion --- js/app/models/InteractiveNode.js | 21 +++++++++++++-------- js/app/models/PlotNode.js | 12 +++--------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/js/app/models/InteractiveNode.js b/js/app/models/InteractiveNode.js index 4409e81..b40ced8 100644 --- a/js/app/models/InteractiveNode.js +++ b/js/app/models/InteractiveNode.js @@ -52,7 +52,7 @@ Ext.define('amdaModel.InteractiveNode', { { node.eachChild(function(n) { - if (!n.isLoaded() && !n.isLeaf()) + if (!n.isLoaded() && !n.isRealLeaf()) { nodesToLoad.push(n); me.preloadTreeNode(n,nodesToLoad,onloaded); @@ -70,7 +70,7 @@ Ext.define('amdaModel.InteractiveNode', { { records.forEach(function (record) { - if (!record.isLoaded() && !record.isLeaf()) + if (!record.isLoaded() && !record.isRealLeaf()) { nodesToLoad.push(record); me.preloadTreeNode(record,nodesToLoad,onloaded); @@ -99,6 +99,11 @@ Ext.define('amdaModel.InteractiveNode', { } } }, + + isRealLeaf: function() + { + return this.isLeaf(); + }, /** * this method is overriden into ExecutableNode to return true @@ -146,7 +151,7 @@ Ext.define('amdaModel.InteractiveNode', { */ rename: function(value,callBackFn) { - var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')}; + var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; AmdaAction.renameObject(dataToSend, callBackFn); }, @@ -155,7 +160,7 @@ Ext.define('amdaModel.InteractiveNode', { */ renameDD: function(parentId, callBackFn) { - var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isLeaf(), nodeType: this.get('nodeType')}; + var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; AmdaAction.renameObject(dataToSend, callBackFn); }, @@ -166,7 +171,7 @@ Ext.define('amdaModel.InteractiveNode', { */ isValidName : function(name, callBackFn) { - var dataToSend = {name: name, nodeType: this.get('nodeType'), leaf: this.isLeaf()}; + var dataToSend = {name: name, nodeType: this.get('nodeType'), leaf: this.isRealLeaf()}; AmdaAction.validNameObject(dataToSend, callBackFn); }, @@ -515,7 +520,7 @@ Ext.define('amdaModel.InteractiveNode', { deleteNode: function() { // if the target is a directory - if (!this.isLeaf()) { + if (!this.isRealLeaf()) { // determine if this directory is empty before launching the delete confirmation method this.isNotEmptyDir(this.confirmDirectoryDeletion); // else (the target is a leaf) @@ -568,14 +573,14 @@ Ext.define('amdaModel.InteractiveNode', { */ realDelete : function() { - AmdaAction.deleteObject({id: this.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}, function(res,e){ + AmdaAction.deleteObject({id: this.get('id'), leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}, function(res,e){ //TODO proper errors handling // node deletion in tree if (res) { // if success if (res.id) { //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); if (this.parentNode) { - if (this.isLeaf()){ + if (this.isRealLeaf()){ var moduleId = this.get('moduleId'); // if really interactive node if (moduleId) { diff --git a/js/app/models/PlotNode.js b/js/app/models/PlotNode.js index 267dc46..dc783e5 100644 --- a/js/app/models/PlotNode.js +++ b/js/app/models/PlotNode.js @@ -135,16 +135,10 @@ Ext.define('amdaModel.PlotNode', { } }, - rename: function(value,callBackFn) { + isRealLeaf: function() + { var isFolder = (!this.isLeaf()) && (this.get('tabs') === false); - var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: !isFolder, nodeType: this.get('nodeType')}; - AmdaAction.renameObject(dataToSend, callBackFn); - }, - - renameDD: function(parentId, callBackFn) { - var isFolder = (!this.isLeaf()) && (this.get('tabs') === false); - var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: !isFolder, nodeType: this.get('nodeType')}; - AmdaAction.renameObject(dataToSend, callBackFn); + return !isFolder; }, insertPlotTabsRequest: function() { -- libgit2 0.21.2