Commit 3993a03b39eecb74a70e3d2f478adab8eece12d8
Exists in
master
and in
94 other branches
Merge branch 'master' of https://gitlab.irap.omp.eu/CDPP/AMDA_IHM
Showing
1 changed file
with
52 additions
and
43 deletions
Show diff stats
js/app/models/InteractiveNode.js
... | ... | @@ -28,8 +28,7 @@ Ext.define('amdaModel.InteractiveNode', { |
28 | 28 | statics: { |
29 | 29 | preloadNodes : function(node,onready) |
30 | 30 | { |
31 | - var me = this; | |
32 | - | |
31 | + var me = this; | |
33 | 32 | var nodesToLoad = new Array(); |
34 | 33 | nodesToLoad.push(node); |
35 | 34 | this.preloadTreeNode(node, nodesToLoad, function (node) |
... | ... | @@ -131,7 +130,7 @@ Ext.define('amdaModel.InteractiveNode', { |
131 | 130 | } |
132 | 131 | module.setContextNode(contextNode); |
133 | 132 | |
134 | - } else if (module.getLinkedNode() != null){ | |
133 | + } else if (module.getLinkedNode() != null){ | |
135 | 134 | //TODO the node to edit is already edited |
136 | 135 | // myDesktopApp.warningMsg('This object is being edited'); |
137 | 136 | //Sol1: msg alert: "warning this node is already edited! If you want to get the original, please press the 'reset' button"->'OK' |
... | ... | @@ -237,7 +236,7 @@ Ext.define('amdaModel.InteractiveNode', { |
237 | 236 | if (!this.get('contextNode') || (this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode') || (this.get('contextNode').data.id == 'sharedcatalog-treeRootNode')) { |
238 | 237 | // set the root node of 'Derived Parameters' tree as contextNode |
239 | 238 | this.set('contextNode',this.getRootNode()); |
240 | - } | |
239 | + } | |
241 | 240 | // call the Ext.Direct method to create parameter |
242 | 241 | AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function(res,e){ |
243 | 242 | //success |
... | ... | @@ -258,12 +257,13 @@ Ext.define('amdaModel.InteractiveNode', { |
258 | 257 | } |
259 | 258 | // set text of this node |
260 | 259 | this.set('text',this.get('object').get('name')); |
260 | + | |
261 | 261 | //set id of this node |
262 | 262 | this.set('id',res.id); |
263 | 263 | this.internalId = res.id; |
264 | + | |
264 | 265 | // set id of node's object |
265 | - this.get('object').set('id',res.id); | |
266 | - | |
266 | + this.get('object').set('id',res.id); | |
267 | 267 | if (res.created){ |
268 | 268 | // set the created date |
269 | 269 | this.get('object').set('created',res.created); |
... | ... | @@ -565,45 +565,54 @@ Ext.define('amdaModel.InteractiveNode', { |
565 | 565 | if (this.parentNode) { |
566 | 566 | if (this.isLeaf()){ |
567 | 567 | var moduleId = this.get('moduleId'); |
568 | - // if really interactive node | |
568 | + // if really interactive node | |
569 | 569 | if (moduleId) { |
570 | - var me = this; | |
571 | - myDesktopApp.getLoadedModule(moduleId, true, function (module) { | |
572 | - var editedNode = module.getLinkedNode(); | |
573 | - // file node is not linked directly to the module | |
574 | - var isThisFile = false; | |
575 | - | |
576 | - if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') | |
577 | - if (editedNode.get('fileObject').get('fileName') == me.get('text')) | |
578 | - isThisFile = true; | |
579 | - | |
580 | - if (me.$className == 'amdaModel.DerivedParamNode') | |
581 | - { | |
582 | - var obj = { | |
583 | - paramId : 'ws_'+me.get('text') | |
584 | - }; | |
585 | - AmdaAction.compilParamDelete(obj); | |
586 | - } | |
587 | - | |
588 | - if (editedNode === me || isThisFile){ | |
589 | - var newNode = Ext.ModelManager.create({leaf : true}, me.$className); | |
590 | - // several tabs could be connected to one node | |
591 | - if (moduleId === myDesktopApp.dynamicModules.plot.id) { | |
592 | - var linkedNodes = module.linkedNodes; | |
593 | - | |
594 | - if (linkedNodes) { | |
595 | - linkedNodes.each(function(key, value){ | |
596 | - if (value === me) { | |
597 | - linkedNodes.replace(key,newNode); | |
598 | - var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); | |
599 | - tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); | |
600 | - } | |
601 | - }, me); | |
602 | - } | |
603 | - } | |
604 | - newNode.editInModule(); | |
570 | + var win = myDesktopApp.getDesktop().getWindow(moduleId); | |
571 | + // if window is really open | |
572 | + if (win) { | |
573 | + var me = this; | |
574 | + myDesktopApp.getLoadedModule(moduleId, true, function (module) { | |
575 | + var editedNode = module.getLinkedNode(); | |
576 | + | |
577 | + // file node is not linked directly to the module | |
578 | + var isThisFile = false; | |
579 | + if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') | |
580 | + if (editedNode.get('fileObject').get('fileName') == me.get('text')) | |
581 | + isThisFile = true; | |
582 | + | |
583 | + // node was created BEFORE tree loading; node.id are different ; but it is the same node | |
584 | + if ( editedNode && editedNode.get('id') == me.get('id') && editedNode !== me ) { | |
585 | + module.setLinkedNode(me); | |
586 | + isThisFile = true; | |
587 | + } | |
588 | + | |
589 | + if (me.$className == 'amdaModel.DerivedParamNode') { | |
590 | + var obj = { | |
591 | + paramId : 'ws_'+me.get('text') | |
592 | + }; | |
593 | + AmdaAction.compilParamDelete(obj); | |
594 | + } | |
595 | + | |
596 | + if (editedNode === me || isThisFile ){ | |
597 | + var newNode = Ext.ModelManager.create({leaf : true}, me.$className); | |
598 | + // several tabs could be connected to one node | |
599 | + if (moduleId === myDesktopApp.dynamicModules.plot.id) { | |
600 | + var linkedNodes = module.linkedNodes; | |
601 | + | |
602 | + if (linkedNodes) { | |
603 | + linkedNodes.each(function(key, value){ | |
604 | + if (value === me) { | |
605 | + linkedNodes.replace(key,newNode); | |
606 | + var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); | |
607 | + tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); | |
608 | + } | |
609 | + }, me); | |
610 | + } | |
611 | + } | |
612 | + newNode.editInModule(); | |
613 | + } | |
614 | + }); | |
605 | 615 | } |
606 | - }); | |
607 | 616 | } |
608 | 617 | } |
609 | 618 | //update mask info in myData | ... | ... |