diff --git a/js/app/views/IntervalUI.js b/js/app/views/IntervalUI.js index 8f41b98..264b5d6 100644 --- a/js/app/views/IntervalUI.js +++ b/js/app/views/IntervalUI.js @@ -159,6 +159,21 @@ Ext.define('amdaUI.IntervalUI', { ); }, + isValid: function() { + var form = this.findParentByType('form').getForm(); + var startField = form.findField('startDate'); + var stopField = form.findField('stopDate'); + if (!startField.isValid() || !stopField.isValid()) + return false; + var start = this.getStartTime(); + var stop = this.getStopTime(); + if ( stop <= start ) { + form.findField('stopDate').markInvalid('Stop Time must be after Start Time'); + return false; + } + return true; + }, + updateStop: function() { var form = this.findParentByType('form').getForm(); var start = form.findField('startDate').getValue(); diff --git a/js/app/views/PlotComponents/PlotTabContent.js b/js/app/views/PlotComponents/PlotTabContent.js index a87849a..1e21df2 100644 --- a/js/app/views/PlotComponents/PlotTabContent.js +++ b/js/app/views/PlotComponents/PlotTabContent.js @@ -146,11 +146,27 @@ Ext.define('amdaPlotComp.PlotTabContent', { } }, + getDataProcess : function() { + var downObject = amdaModel.DownloadNode.decodeObject(this.plotNode.get('object')); + amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject)); + amdaModel.DownloadNode.editInModule(); + }, + + isValidRequest : function(acceptEmptyTTList = true) { + this.updateTimeObject(); + if (!this.timeSelector.isValid(acceptEmptyTTList)) { + myDesktopApp.errorMsg('Error in Time definition'); + return false; + } + return true; + }, + 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.intervalSel.updateStop(); this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables')); + this.timeSelector.timeSrc.setActiveTab(this.plotNode.get('object').get('timesrc')); this.treePlot.buildTree(this.plotNode.get('object')); }, diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index 0fe6c9a..9ea0a0b 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -53,9 +53,7 @@ Ext.define('amdaUI.PlotUI', { var plotTab = this.plotTabs.getCurrentPlotTabContent(); if (!plotTab || !plotTab.plotNode) return; - var downObject = amdaModel.DownloadNode.decodeObject(plotTab.plotNode.get('object')); - amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject)); - amdaModel.DownloadNode.editInModule(); + plotTab.getDataProcess(); } }, @@ -83,7 +81,7 @@ Ext.define('amdaUI.PlotUI', { * plot method called by 'Do Plot' button to launch the plot process */ doPlot : function(){ - if ( this.updateObject() ) { + if ( this.updateObject(false) ) { var plotTab = this.plotTabs.getCurrentPlotTabContent(); if (plotTab) plotTab.doPlot(); @@ -105,15 +103,11 @@ Ext.define('amdaUI.PlotUI', { /** * update time selector of this.object from form */ - updateObject : function(){ - this.plotTabs.updateTimeObjects(); - var basicForm = this.formPanel.getForm(); - if (basicForm && ! basicForm.hasInvalidField()) { - return true; - } - else { - return false; - } + updateObject : function(acceptEmptyTTList = true){ + var plotTab = this.plotTabs.getCurrentPlotTabContent(); + if (plotTab) + return plotTab.isValidRequest(acceptEmptyTTList); + return false; }, updateTabs : function() { @@ -145,9 +139,11 @@ Ext.define('amdaUI.PlotUI', { }, savePlotRequest : function() { - var plotTab = this.plotTabs.getCurrentPlotTabContent(); - if (plotTab) - plotTab.savePlot(); + if (this.updateObject(true)) { + var plotTab = this.plotTabs.getCurrentPlotTabContent(); + if (plotTab) + plotTab.savePlot(); + } }, init : function(config) { diff --git a/js/app/views/TimeSelectorUI.js b/js/app/views/TimeSelectorUI.js index 2fad39a..08c74db 100644 --- a/js/app/views/TimeSelectorUI.js +++ b/js/app/views/TimeSelectorUI.js @@ -61,6 +61,20 @@ Ext.define('amdaUI.TimeSelectorUI', { getActiveTimeSource: function() { return this.timeSrc.getActiveTab().getItemId(); }, + + isValid: function(acceptEmptyTTList = true) { + if (this.getActiveTimeSource() === amdaModel.AmdaTimeObject.inputTimeSrc[0]) { + //TimeTables + if (acceptEmptyTTList) + return true; + return (this.TTGrid.getStore().count() > 0); + } + else { + //Interval + return this.intervalSel.isValid(); + } + return true; + }, initComponent: function() { this.activeField = null; -- libgit2 0.21.2