diff --git a/js/app/models/PlotObjects/PlotRequestObject.js b/js/app/models/PlotObjects/PlotRequestObject.js index 905da57..dd0961a 100644 --- a/js/app/models/PlotObjects/PlotRequestObject.js +++ b/js/app/models/PlotObjects/PlotRequestObject.js @@ -123,9 +123,11 @@ Ext.define('amdaPlotObj.PlotRequestObject', { requestValues['file-prefix'] = this.get('file-prefix'); requestValues['one-file-per-interval'] = this.get('one-file-per-interval'); requestValues['last-plotted-tab'] = this.get('last-plotted-tab'); - requestValues['name'] = this.get('name'); - requestValues['timesrc'] = this.get('timesrc'); + requestValues['name'] = this.get('name'); + requestValues['all-in-one'] = this.get('all-in-one'); + requestValues['timesrc'] = this.get('timesrc'); + // if there's at least one timeTable name into 'timeTables' collection if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){ // get complete timeTables collection diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index 16a74cd..5e38a67 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -47,85 +47,81 @@ Ext.define('amdaUI.PlotUI', { this.plotTabs.setRequestObject(this.object); this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate')); this.addTTs(this.object.get('timeTables')); + this.updateRequestOption(this.object.get('all-in-one')); }, - saveProcess : function() { - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); - if (!plotModule) - return; - - this.updateObject(); - - this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); - this.object.set('all-in-one', this.allPlots); - - if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) - //update existing request - plotModule.linkedNode.update(); - else - { - var me = this; - //Request Name validation - plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { - if (!res) { - myDesktopApp.errorMsg('Error during object validation'); - return; - } - - if (!res.valid) { - if (res.error) - myDesktopApp.errorMsg(res.error); - else - myDesktopApp.errorMsg('Invalid object name'); - return; - } - - //Save - if (me.object.get('id') != '') { - //Duplicate request - plotModule.createLinkedNode(); - plotModule.linkedNode.set('object',me.object); - } - - plotModule.linkedNode.create(); - }); - } + updateRequestOption : function(allInOne) { + var requestOptionCB = this.formPanel.getForm().findField('all-in-one'); + requestOptionCB.setValue(allInOne); }, + + /** + * 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); + resetProcess : function(){ + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); plotModule.createLinkedNode(); plotModule.createObject(); this.setObject(plotModule.linkedNode.get('object')); - }, + }, - getDataProcess : function(){ + getDataProcess : function(){ this.updateObject(); // plot was not called - form only - if (this.object.get('last-plotted-tab') == 0) - { + if (this.object.get('last-plotted-tab') == 0) { this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); } - var downObject = amdaModel.DownloadNode.decodeObject(this.object); - amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject)); - amdaModel.DownloadNode.editInModule(); - }, + var downObject = amdaModel.DownloadNode.decodeObject(this.object); + amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject)); + amdaModel.DownloadNode.editInModule(); + }, - addParameter : function(node){ - var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab()); - crtTree.dropRecord(node,null,'append'); - }, + addParameter : function(node){ + var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab()); + crtTree.dropRecord(node,null,'append'); + }, /** * plot method called by 'Do Plot' button to launch the plot process */ - doPlot : function(){ - this.updateObject(); - this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); - if (plotModule) - plotModule.linkedNode.execute(); - }, + doPlot : function(){ + this.updateObject(); + this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); + if (plotModule) + plotModule.linkedNode.execute(); + }, /** * Check if changes were made before closing window @@ -139,19 +135,19 @@ Ext.define('amdaUI.PlotUI', { return this.object.isDirty(); }, - /** - * update this.object from form - */ - updateObject : function(){ - var timeSource = this.timeSelector.getActiveTimeSource(); - // var multiPlotForm = this.multiPlotIntervalPanel.getForm(); + /** + * update time selector of this.object from form + */ + updateObject : function(){ + var timeSource = this.timeSelector.getActiveTimeSource(); + var multiPlotForm = this.timeSelector.getForm(); - multiPlotForm.updateRecord(this.object); - this.object.set('timesrc', timeSource); - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) - this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); - this.plotTabs.updateTimeObject(); - }, + multiPlotForm.updateRecord(this.object); + this.object.set('timesrc', timeSource); + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) + this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); + this.plotTabs.updateTimeObject(); + }, addTT : function(newTTName,newTTid,timeSelectorId) { var crtTimeSelector = Ext.getCmp(timeSelectorId); @@ -182,8 +178,7 @@ Ext.define('amdaUI.PlotUI', { this.timeSelector.intervalSel.setInterval(dateStart, dateStop); }, - updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { - // this.multiPlotIntervalPanel.setVisible(isLinkedToMultiPlotMode); + updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { this.timeSelector.setVisible(isLinkedToMultiPlotMode); }, @@ -254,44 +249,82 @@ Ext.define('amdaUI.PlotUI', { ] } ], - fbar: [ - { - xtype: 'button', - text: 'Plot', - scope: this, - handler: function(button) { - this.doPlot(); - } - }, - ' ', - { - xtype: 'button', - text: 'Get Data', - scope: this, - handler: function(button) { - this.getDataProcess(); - } - }, - ' ', - { - xtype: 'button', - text: 'Reset', - scope: this, - handler: function(button) { - this.resetProcess(); - } - }, - '->', - { - xtype: 'button', - text: 'Save Request', - scope: this, - handler: function(button) { - this.saveProcess(); - } + fbar: [{ + xtype: 'button', + text: 'Plot', + scope: this, + handler: function(button) { + this.doPlot(); + } + },' ', { + xtype: 'button', + text: 'Get Data', + scope: this, + handler: function(button) { + this.getDataProcess(); + } + },' ', { + xtype: 'button', + text: 'Reset', + scope: this, + handler: function(button) { + this.resetProcess(); + } + }, + '->', { + xtype: 'button', + text: 'Save Request', + scope: this, + handler: function(button) { + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); + if (!plotModule) + return; + + this.updateObject(); + this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); + this.object.set('all-in-one', this.allPlots); + + //update existing request + if ((this.object.get('id') != '') && + (plotModule.linkedNode.get('text') == this.object.get('name'))) + plotModule.linkedNode.update(); + else { + 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 + '<br/>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; + } + me.saveProcess(false); + }) + } + } },' ', { xtype: 'checkbox', boxLabel: 'All Plot Tabs', + name : 'all-in-one', listeners : { scope: this, change: function (cb, nv, ov) { @@ -301,28 +334,29 @@ Ext.define('amdaUI.PlotUI', { } ] }); - + var myConf = { - layout: 'border', - items: [ - this.formPanel, - { - xtype: 'panel', - region: 'south', - title: 'Information', - collapsible: true, - collapseMode: 'header', - height: 100, - autoHide: false, - bodyStyle: 'padding:5px', - iconCls: 'icon-information', - loader: { - autoLoad: true, - url: helpDir+'plotHOWTO' - } - } - ] + layout: 'border', + items: [ + this.formPanel, + { + xtype: 'panel', + region: 'south', + title: 'Information', + collapsible: true, + collapseMode: 'header', + height: 100, + autoHide: false, + bodyStyle: 'padding:5px', + iconCls: 'icon-information', + loader: { + autoLoad: true, + url: helpDir+'plotHOWTO' + } + } + ] }; - Ext.apply (this , Ext.apply (arguments, myConf)); + + Ext.apply(this, Ext.apply(arguments, myConf)); } }); -- libgit2 0.21.2