diff --git a/js/app/models/PlotObjects/MultiplotRequestObject.js b/js/app/models/PlotObjects/MultiplotRequestObject.js index af7a41c..6fcad09 100644 --- a/js/app/models/PlotObjects/MultiplotRequestObject.js +++ b/js/app/models/PlotObjects/MultiplotRequestObject.js @@ -18,7 +18,8 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { idProperty: 'id', requires: [ - 'amdaModel.PlotNode' + 'amdaModel.PlotNode', + 'amdaPlotObj.PlotRequestObject' ], hasMany: { @@ -44,11 +45,25 @@ Ext.define('amdaPlotObj.MultiplotRequestObject', { }, createNewPlot: function() { + var plotObject = Ext.create('amdaPlotObj.PlotRequestObject'); + return this.createNewPlotFromObject(plotObject); + }, + + duplicatePlot: function(plotNode) { + var clonedObject = plotNode.get('object').copy(); + console.log(plotNode); + this.plots().each(function(node) { + console.log(node); + }); + //this.plots().store.removeAt(index); + //store.insert(index, newValue); + }, + + createNewPlotFromObject: function(plotObject) { var plotNode = Ext.create('amdaModel.PlotNode', { leaf : true, contextNode : this }); - var plotObject = Ext.create(plotNode.get('objectDataModel')); plotNode.set('object',plotObject); this.plots().add(plotNode); return this.plots().getAt(this.plots().count()-1); diff --git a/js/app/models/PlotObjects/PlotRequestObject.js b/js/app/models/PlotObjects/PlotRequestObject.js index b3162c0..1b5192b 100644 --- a/js/app/models/PlotObjects/PlotRequestObject.js +++ b/js/app/models/PlotObjects/PlotRequestObject.js @@ -233,6 +233,7 @@ Ext.define('amdaPlotObj.PlotRequestObject', { var requestValues = new Object(); requestValues['nodeType'] = 'request'; + requestValues['leaf'] = true; requestValues['id'] = this.get('id'); diff --git a/js/app/views/PlotComponents/PlotTabContent.js b/js/app/views/PlotComponents/PlotTabContent.js index b7c6161..a3154d1 100644 --- a/js/app/views/PlotComponents/PlotTabContent.js +++ b/js/app/views/PlotComponents/PlotTabContent.js @@ -49,11 +49,82 @@ Ext.define('amdaPlotComp.PlotTabContent', { this.plotNode.execute(); }, - init : function(config) { + savePlot : function() { + var object = this.plotNode.get('object'); + if (!object) + return; + + if ((object.get('id') != '') && (this.plotNode.get('text') == object.get('name'))) { + //update existing request + this.plotNode.update(); + return; + } + + //save new request var me = this; - me.plotNode = config.plotNode; + this.plotNode.isValidName(object.get('name'), function (res) { + if (!res) { + myDesktopApp.errorMsg('Error during object validation'); + return; + } + if (!res.valid) { + if (res.error) { + if (res.error.search('subtree') != -1) { + Ext.Msg.show( { title : 'Warning', + msg: res.error + '
Do you want to overwrite it?', + width: 300, + buttons: Ext.Msg.OKCANCEL, + icon: Ext.Msg.WARNING, + fn : me.overwritePlot, + scope : me + }); + } + else { + myDesktopApp.errorMsg(res.error); + } + } + else { + myDesktopApp.errorMsg('Invalid object name'); + } + return; + } + me.saveProcess(false); + }); + }, + + overwritePlot : function(btn) { + if (btn == 'cancel') return; + this.saveProcess(true); + }, + + saveProcess : function(toRename) { + if (toRename) { + this.plotNode.update(); + } + else { + if (this.plotNode.get('object').get('id') != '') { + //Duplicate request + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); + if (!plotModule) + return; + this.plotNode = plotModule.linkedNode.get('object').duplicatePlot(this.plotNode); + this.updateUI(); + } + this.plotNode.create(); + } + }, + + updateUI : function() { + this.plotOutput.setObject(this.plotNode.get('object')); + this.timeSelector.intervalSel.setInterval(this.plotNode.get('object').get('startDate'), this.plotNode.get('object').get('stopDate')); + this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables')); + this.treePlot.buildTree(this.plotNode.get('object')); + }, + + init : function(config) { + this.plotNode = config.plotNode; - this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'plotTimeSelectorTab' + me.plotNode.id, border : false, flex: 6, collapsible: true, collapseDirection : 'bottom'} ); + 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}); this.treePlot = new amdaPlotComp.PlotTree({flex: 11, plotElementPanel: this.plotElement}); this.plotOutput = new amdaPlotComp.PlotOutputForm({flex: 6, collapseDirection : 'bottom', collapsible : true }); @@ -110,10 +181,7 @@ Ext.define('amdaPlotComp.PlotTabContent', { ], listeners: { afterrender: function(comp, eOpts) { - this.plotOutput.setObject(this.plotNode.get('object')); - this.timeSelector.intervalSel.setInterval(this.plotNode.get('object').get('startDate'), this.plotNode.get('object').get('stopDate')); - this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables')); - this.treePlot.buildTree(this.plotNode.get('object')); + this.updateUI(); }, scope: this } diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index 927bb67..7880f75 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -37,39 +37,6 @@ Ext.define('amdaUI.PlotUI', { this.plotTabs.setMultiplotObject(this.object); }, - /** - * overwrite metod called by Save button - */ - overwriteProcess : function(btn) - { - if (btn == 'cancel') return; - this.saveProcess(true); - }, - - - /** - * save method called by Save button to launch the save process - */ - saveProcess : function(toRename) { - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); - if (!plotModule) - return; - - if (toRename) { - plotModule.linkedNode.set('object',this.object); - plotModule.linkedNode.update(); - } - else { - //Save - if (this.object.get('id') != '') { - //Duplicate request - plotModule.createLinkedNode(); - plotModule.linkedNode.set('object',this.object); - } - plotModule.linkedNode.create(); - } - }, - resetProcess : function(){ var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); plotModule.createLinkedNode(); @@ -209,66 +176,11 @@ Ext.define('amdaUI.PlotUI', { }); }, - savePlotRequest : function(allTabs) { - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); - if (!plotModule) - return; - this.updateObject(); - this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); - var me = this; - - if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) { - //update existing request - if (!allTabs) { - this.keepOnlySelectedTabInObject(true, function() { - plotModule.linkedNode.update(); - }); - } - else { - plotModule.linkedNode.update(); - } - return; - } - - //save new request - var me = this; - plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { - if (!res) { - myDesktopApp.errorMsg('Error during object validation'); - return; - } - if (!res.valid) { - if (res.error) { - if (res.error.search('subtree') != -1) { - Ext.Msg.show( { title : 'Warning', - msg: res.error + '
Do you want to overwrite it?', - width: 300, - buttons: Ext.Msg.OKCANCEL, - icon: Ext.Msg.WARNING, - fn : me.overwriteProcess, - scope : me - }); - } - else { - myDesktopApp.errorMsg(res.error); - } - } - else { - myDesktopApp.errorMsg('Invalid object name'); - } - return; - } - if (!allTabs) { - me.keepOnlySelectedTabInObject((me.object.get('id') == ''), function() { - me.saveProcess(false); - me.setObject(me.object); - }); - } - else { - me.saveProcess(false); - } - }); - }, + savePlotRequest : function() { + var plotTab = this.plotTabs.getCurrentPlotTabContent(); + if (plotTab) + plotTab.savePlot(); + }, init : function(config) { this.plotTabs = new amdaPlotComp.PlotTabPanel({plotUI : this}); @@ -306,22 +218,11 @@ Ext.define('amdaUI.PlotUI', { this.resetProcess(); } },'->', '-', { - xtype: 'splitbutton', - text: 'Save All Tabs', - menu: { - items: [ - { - text: 'Save Current Tab', - scope: this, - handler: function() { - this.savePlotRequest(false); - } - }, - ] - }, + xtype: 'button', + text: 'Save', scope: this, handler: function(button) { - this.savePlotRequest(true); + this.savePlotRequest(); } } ] diff --git a/php/classes/RequestMgr.php b/php/classes/RequestMgr.php index 9b962e2..c8c5bde 100644 --- a/php/classes/RequestMgr.php +++ b/php/classes/RequestMgr.php @@ -258,17 +258,12 @@ class RequestMgr extends AmdaObjectMgr switch ($obj->nodeType) { case 'request' : - foreach ($obj->tabs as $tab) - { - $timesrc = $tab->{'multi-plot-linked'} ? $obj->timesrc : $tab->timesrc; - + //TODO check TT as well (first start and last stop ?) - if ($timesrc != 'Interval') continue; - // select active tab - if (!$tab->{'multi-plot-linked'} && $tab->id != $obj->{'last-plotted-tab'}) continue; + if ($obj->timesrc != 'Interval') continue; $argsTab = array(); - foreach ($tab->panels as $panel) + foreach ($obj->panels as $panel) { $params = array(); foreach ($panel->params as $param) @@ -283,12 +278,11 @@ class RequestMgr extends AmdaObjectMgr if (count($params) > 0) { $argsTab['param'] = array_unique($params); - $argsTab['startTime'] = $tab->{'multi-plot-linked'} ? $obj->startDate : $tab->startDate; - $argsTab['stopTime'] = $tab->{'multi-plot-linked'} ? $obj->stopDate : $tab->stopDate; + $argsTab['startTime'] = $obj->startDate; + $argsTab['stopTime'] = $$obj->stopDate; } } if (count($argsTab) > 0) $args[] = $argsTab; - } break; case 'condition' : //$argsTab = array(); -- libgit2 0.21.2