diff --git a/js/app/models/PlotObjects/MultiplotRequestObject.js b/js/app/models/PlotObjects/MultiplotRequestObject.js index 1d10dbd..edf19ba 100644 --- a/js/app/models/PlotObjects/MultiplotRequestObject.js +++ b/js/app/models/PlotObjects/MultiplotRequestObject.js @@ -50,18 +50,27 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { }, duplicatePlot: function(plotNode) { + var me = this; var clonedObject = plotNode.get('object').copy(); - console.log(plotNode); - this.plots().each(function(node) { - console.log(node); + var newPlotNode = null; + this.plots().each(function(node, index) { + if (node == plotNode) { + plotNode.get('object').reject(); + newPlotNode = Ext.create('amdaModel.PlotNode', { + leaf : true + }); + newPlotNode.set('object',clonedObject); + me.plots().removeAt(index); + me.plots().insert(index, newPlotNode); + return false; + } }); - //this.plots().store.removeAt(index); - //store.insert(index, newValue); + return newPlotNode; }, createNewPlotFromObject: function(plotObject) { var plotNode = Ext.create('amdaModel.PlotNode', { - leaf : true, + leaf : true }); plotNode.set('object',plotObject); this.plots().add(plotNode); diff --git a/js/app/models/PlotObjects/PlotRequestObject.js b/js/app/models/PlotObjects/PlotRequestObject.js index b5ed4ce..df384f8 100644 --- a/js/app/models/PlotObjects/PlotRequestObject.js +++ b/js/app/models/PlotObjects/PlotRequestObject.js @@ -27,7 +27,6 @@ Ext.define('amdaPlotObj.PlotRequestObject', { ], fields : [ - {name: 'id', type: 'int'}, {name: 'tab-index', type: 'int', defaultValue: 0, persist: false}, {name: 'tab-title', type: 'string', defaultValue: '', persist: false}, diff --git a/js/app/views/PlotComponents/PlotTabContent.js b/js/app/views/PlotComponents/PlotTabContent.js index 15556f3..da0fbda 100644 --- a/js/app/views/PlotComponents/PlotTabContent.js +++ b/js/app/views/PlotComponents/PlotTabContent.js @@ -27,6 +27,7 @@ Ext.define('amdaPlotComp.PlotTabContent', { plotOutput: null, tabIndex: 0, + plotTabPanel: null, constructor: function(config) { this.init(config); @@ -114,11 +115,15 @@ Ext.define('amdaPlotComp.PlotTabContent', { var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); if (!plotModule) return; - this.plotNode = plotModule.linkedNode.get('object').duplicatePlot(this.plotNode); - this.updateUI(); + var newPlotNode = plotModule.linkedNode.get('object').duplicatePlot(this.plotNode); + if (newPlotNode) { + this.plotNode = newPlotNode; + this.updateUI(); + } } this.plotNode.create(); } + this.plotTabPanel.updatePlotTabs(); }, updateUI : function() { @@ -131,6 +136,7 @@ Ext.define('amdaPlotComp.PlotTabContent', { init : function(config) { this.plotNode = config.plotNode; this.tabIndex = config.tabIndex; + this.plotTabPanel = config.plotTabPanel; this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + this.plotNode.id, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} ); this.plotElement = new amdaPlotComp.PlotElementPanel({flex: 11}); diff --git a/js/app/views/PlotComponents/PlotTabPanel.js b/js/app/views/PlotComponents/PlotTabPanel.js index 9e01550..10b1c61 100644 --- a/js/app/views/PlotComponents/PlotTabPanel.js +++ b/js/app/views/PlotComponents/PlotTabPanel.js @@ -61,7 +61,7 @@ Ext.define('amdaPlotComp.PlotTabPanel', { } var tabNumber = this.getTabBar().items.getCount(); - var tabContent = new amdaPlotComp.PlotTabContent({plotNode: plotNode, tabIndex: tabNumber-1}); + var tabContent = new amdaPlotComp.PlotTabContent({plotNode: plotNode, tabIndex: tabNumber-1, plotTabPanel: this}); var me = this; var tabComp = this.add({ title: tabContent.getPlotTitle(), -- libgit2 0.21.2