Commit bab40211c5476186b37aea65a0d38f5d473f03ee

Authored by Benjamin Renard
1 parent 02a4cc4d

Test time selection validity before run plot request + Fix bug with source selector

js/app/views/IntervalUI.js
... ... @@ -159,6 +159,21 @@ Ext.define('amdaUI.IntervalUI', {
159 159 );
160 160 },
161 161  
  162 + isValid: function() {
  163 + var form = this.findParentByType('form').getForm();
  164 + var startField = form.findField('startDate');
  165 + var stopField = form.findField('stopDate');
  166 + if (!startField.isValid() || !stopField.isValid())
  167 + return false;
  168 + var start = this.getStartTime();
  169 + var stop = this.getStopTime();
  170 + if ( stop <= start ) {
  171 + form.findField('stopDate').markInvalid('Stop Time must be after Start Time');
  172 + return false;
  173 + }
  174 + return true;
  175 + },
  176 +
162 177 updateStop: function() {
163 178 var form = this.findParentByType('form').getForm();
164 179 var start = form.findField('startDate').getValue();
... ...
js/app/views/PlotComponents/PlotTabContent.js
... ... @@ -146,11 +146,27 @@ Ext.define(&#39;amdaPlotComp.PlotTabContent&#39;, {
146 146 }
147 147 },
148 148  
  149 + getDataProcess : function() {
  150 + var downObject = amdaModel.DownloadNode.decodeObject(this.plotNode.get('object'));
  151 + amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject));
  152 + amdaModel.DownloadNode.editInModule();
  153 + },
  154 +
  155 + isValidRequest : function(acceptEmptyTTList = true) {
  156 + this.updateTimeObject();
  157 + if (!this.timeSelector.isValid(acceptEmptyTTList)) {
  158 + myDesktopApp.errorMsg('Error in Time definition');
  159 + return false;
  160 + }
  161 + return true;
  162 + },
  163 +
149 164 updateUI : function() {
150 165 this.plotOutput.setObject(this.plotNode.get('object'));
151 166 this.timeSelector.intervalSel.setInterval(this.plotNode.get('object').get('startDate'), this.plotNode.get('object').get('stopDate'));
152 167 this.timeSelector.intervalSel.updateStop();
153 168 this.timeSelector.setTTTab(this.plotNode.get('object').get('timeTables'));
  169 + this.timeSelector.timeSrc.setActiveTab(this.plotNode.get('object').get('timesrc'));
154 170 this.treePlot.buildTree(this.plotNode.get('object'));
155 171 },
156 172  
... ...
js/app/views/PlotUI.js
... ... @@ -53,9 +53,7 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
53 53 var plotTab = this.plotTabs.getCurrentPlotTabContent();
54 54 if (!plotTab || !plotTab.plotNode)
55 55 return;
56   - var downObject = amdaModel.DownloadNode.decodeObject(plotTab.plotNode.get('object'));
57   - amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject));
58   - amdaModel.DownloadNode.editInModule();
  56 + plotTab.getDataProcess();
59 57 }
60 58 },
61 59  
... ... @@ -83,7 +81,7 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
83 81 * plot method called by 'Do Plot' button to launch the plot process
84 82 */
85 83 doPlot : function(){
86   - if ( this.updateObject() ) {
  84 + if ( this.updateObject(false) ) {
87 85 var plotTab = this.plotTabs.getCurrentPlotTabContent();
88 86 if (plotTab)
89 87 plotTab.doPlot();
... ... @@ -105,15 +103,11 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
105 103 /**
106 104 * update time selector of this.object from form
107 105 */
108   - updateObject : function(){
109   - this.plotTabs.updateTimeObjects();
110   - var basicForm = this.formPanel.getForm();
111   - if (basicForm && ! basicForm.hasInvalidField()) {
112   - return true;
113   - }
114   - else {
115   - return false;
116   - }
  106 + updateObject : function(acceptEmptyTTList = true){
  107 + var plotTab = this.plotTabs.getCurrentPlotTabContent();
  108 + if (plotTab)
  109 + return plotTab.isValidRequest(acceptEmptyTTList);
  110 + return false;
117 111 },
118 112  
119 113 updateTabs : function() {
... ... @@ -145,9 +139,11 @@ Ext.define(&#39;amdaUI.PlotUI&#39;, {
145 139 },
146 140  
147 141 savePlotRequest : function() {
148   - var plotTab = this.plotTabs.getCurrentPlotTabContent();
149   - if (plotTab)
150   - plotTab.savePlot();
  142 + if (this.updateObject(true)) {
  143 + var plotTab = this.plotTabs.getCurrentPlotTabContent();
  144 + if (plotTab)
  145 + plotTab.savePlot();
  146 + }
151 147 },
152 148  
153 149 init : function(config) {
... ...
js/app/views/TimeSelectorUI.js
... ... @@ -61,6 +61,20 @@ Ext.define(&#39;amdaUI.TimeSelectorUI&#39;, {
61 61 getActiveTimeSource: function() {
62 62 return this.timeSrc.getActiveTab().getItemId();
63 63 },
  64 +
  65 + isValid: function(acceptEmptyTTList = true) {
  66 + if (this.getActiveTimeSource() === amdaModel.AmdaTimeObject.inputTimeSrc[0]) {
  67 + //TimeTables
  68 + if (acceptEmptyTTList)
  69 + return true;
  70 + return (this.TTGrid.getStore().count() > 0);
  71 + }
  72 + else {
  73 + //Interval
  74 + return this.intervalSel.isValid();
  75 + }
  76 + return true;
  77 + },
64 78  
65 79 initComponent: function() {
66 80 this.activeField = null;
... ...