Commit e6065c114ec3d8f601f2bd59fd76667da131eb9f
1 parent
13ad8aca
Exists in
master
and in
109 other branches
overwrite request option for plot
Showing
2 changed files
with
170 additions
and
134 deletions
Show diff stats
js/app/models/PlotObjects/PlotRequestObject.js
... | ... | @@ -123,9 +123,11 @@ Ext.define('amdaPlotObj.PlotRequestObject', { |
123 | 123 | requestValues['file-prefix'] = this.get('file-prefix'); |
124 | 124 | requestValues['one-file-per-interval'] = this.get('one-file-per-interval'); |
125 | 125 | requestValues['last-plotted-tab'] = this.get('last-plotted-tab'); |
126 | - requestValues['name'] = this.get('name'); | |
127 | - requestValues['timesrc'] = this.get('timesrc'); | |
126 | + requestValues['name'] = this.get('name'); | |
127 | + requestValues['all-in-one'] = this.get('all-in-one'); | |
128 | 128 | |
129 | + requestValues['timesrc'] = this.get('timesrc'); | |
130 | + | |
129 | 131 | // if there's at least one timeTable name into 'timeTables' collection |
130 | 132 | if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){ |
131 | 133 | // get complete timeTables collection |
... | ... |
js/app/views/PlotUI.js
... | ... | @@ -47,85 +47,81 @@ Ext.define('amdaUI.PlotUI', { |
47 | 47 | this.plotTabs.setRequestObject(this.object); |
48 | 48 | this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate')); |
49 | 49 | this.addTTs(this.object.get('timeTables')); |
50 | + this.updateRequestOption(this.object.get('all-in-one')); | |
50 | 51 | }, |
51 | 52 | |
52 | - saveProcess : function() { | |
53 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
54 | - if (!plotModule) | |
55 | - return; | |
56 | - | |
57 | - this.updateObject(); | |
58 | - | |
59 | - this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); | |
60 | - this.object.set('all-in-one', this.allPlots); | |
61 | - | |
62 | - if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) | |
63 | - //update existing request | |
64 | - plotModule.linkedNode.update(); | |
65 | - else | |
66 | - { | |
67 | - var me = this; | |
68 | - //Request Name validation | |
69 | - plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { | |
70 | - if (!res) { | |
71 | - myDesktopApp.errorMsg('Error during object validation'); | |
72 | - return; | |
73 | - } | |
74 | - | |
75 | - if (!res.valid) { | |
76 | - if (res.error) | |
77 | - myDesktopApp.errorMsg(res.error); | |
78 | - else | |
79 | - myDesktopApp.errorMsg('Invalid object name'); | |
80 | - return; | |
81 | - } | |
82 | - | |
83 | - //Save | |
84 | - if (me.object.get('id') != '') { | |
85 | - //Duplicate request | |
86 | - plotModule.createLinkedNode(); | |
87 | - plotModule.linkedNode.set('object',me.object); | |
88 | - } | |
89 | - | |
90 | - plotModule.linkedNode.create(); | |
91 | - }); | |
92 | - } | |
53 | + updateRequestOption : function(allInOne) { | |
54 | + var requestOptionCB = this.formPanel.getForm().findField('all-in-one'); | |
55 | + requestOptionCB.setValue(allInOne); | |
93 | 56 | }, |
57 | + | |
58 | + /** | |
59 | + * overwrite metod called by Save button | |
60 | + */ | |
61 | + overwriteProcess : function(btn) | |
62 | + { | |
63 | + if (btn == 'cancel') return; | |
64 | + | |
65 | + this.saveProcess(true); | |
66 | + }, | |
67 | + | |
68 | + | |
69 | + /** | |
70 | + * save method called by Save button to launch the save process | |
71 | + */ | |
72 | + saveProcess : function(toRename) { | |
73 | + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
74 | + if (!plotModule) | |
75 | + return; | |
76 | + | |
77 | + if (toRename) { | |
78 | + plotModule.linkedNode.set('object',this.object); | |
79 | + plotModule.linkedNode.update(); | |
80 | + } | |
81 | + else { | |
82 | + //Save | |
83 | + if (this.object.get('id') != '') { | |
84 | + //Duplicate request | |
85 | + plotModule.createLinkedNode(); | |
86 | + plotModule.linkedNode.set('object',this.object); | |
87 | + } | |
88 | + plotModule.linkedNode.create(); | |
89 | + } | |
90 | + }, | |
94 | 91 | |
95 | - resetProcess : function(){ | |
96 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
92 | + resetProcess : function(){ | |
93 | + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
97 | 94 | plotModule.createLinkedNode(); |
98 | 95 | plotModule.createObject(); |
99 | 96 | this.setObject(plotModule.linkedNode.get('object')); |
100 | - }, | |
97 | + }, | |
101 | 98 | |
102 | - getDataProcess : function(){ | |
99 | + getDataProcess : function(){ | |
103 | 100 | this.updateObject(); |
104 | 101 | // plot was not called - form only |
105 | - if (this.object.get('last-plotted-tab') == 0) | |
106 | - { | |
102 | + if (this.object.get('last-plotted-tab') == 0) { | |
107 | 103 | this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); |
108 | 104 | } |
109 | - var downObject = amdaModel.DownloadNode.decodeObject(this.object); | |
110 | - amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject)); | |
111 | - amdaModel.DownloadNode.editInModule(); | |
112 | - }, | |
105 | + var downObject = amdaModel.DownloadNode.decodeObject(this.object); | |
106 | + amdaModel.DownloadNode.set('object',Ext.create('amdaModel.Download',downObject)); | |
107 | + amdaModel.DownloadNode.editInModule(); | |
108 | + }, | |
113 | 109 | |
114 | - addParameter : function(node){ | |
115 | - var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab()); | |
116 | - crtTree.dropRecord(node,null,'append'); | |
117 | - }, | |
110 | + addParameter : function(node){ | |
111 | + var crtTree = this.plotTabs.getTreeFromPlotTab(this.plotTabs.getActiveTab()); | |
112 | + crtTree.dropRecord(node,null,'append'); | |
113 | + }, | |
118 | 114 | |
119 | 115 | /** |
120 | 116 | * plot method called by 'Do Plot' button to launch the plot process |
121 | 117 | */ |
122 | - doPlot : function(){ | |
123 | - this.updateObject(); | |
124 | - this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); | |
125 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
126 | - if (plotModule) | |
127 | - plotModule.linkedNode.execute(); | |
128 | - }, | |
118 | + doPlot : function(){ | |
119 | + this.updateObject(); | |
120 | + this.object.set('last-plotted-tab', this.plotTabs.getSelectedTabId()); | |
121 | + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
122 | + if (plotModule) | |
123 | + plotModule.linkedNode.execute(); | |
124 | + }, | |
129 | 125 | |
130 | 126 | /** |
131 | 127 | * Check if changes were made before closing window |
... | ... | @@ -139,19 +135,19 @@ Ext.define('amdaUI.PlotUI', { |
139 | 135 | return this.object.isDirty(); |
140 | 136 | }, |
141 | 137 | |
142 | - /** | |
143 | - * update this.object from form | |
144 | - */ | |
145 | - updateObject : function(){ | |
146 | - var timeSource = this.timeSelector.getActiveTimeSource(); | |
147 | - // var multiPlotForm = this.multiPlotIntervalPanel.getForm(); | |
138 | + /** | |
139 | + * update time selector of this.object from form | |
140 | + */ | |
141 | + updateObject : function(){ | |
142 | + var timeSource = this.timeSelector.getActiveTimeSource(); | |
143 | + | |
148 | 144 | var multiPlotForm = this.timeSelector.getForm(); |
149 | - multiPlotForm.updateRecord(this.object); | |
150 | - this.object.set('timesrc', timeSource); | |
151 | - if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) | |
152 | - this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); | |
153 | - this.plotTabs.updateTimeObject(); | |
154 | - }, | |
145 | + multiPlotForm.updateRecord(this.object); | |
146 | + this.object.set('timesrc', timeSource); | |
147 | + if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) | |
148 | + this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items); | |
149 | + this.plotTabs.updateTimeObject(); | |
150 | + }, | |
155 | 151 | |
156 | 152 | addTT : function(newTTName,newTTid,timeSelectorId) { |
157 | 153 | var crtTimeSelector = Ext.getCmp(timeSelectorId); |
... | ... | @@ -182,8 +178,7 @@ Ext.define('amdaUI.PlotUI', { |
182 | 178 | this.timeSelector.intervalSel.setInterval(dateStart, dateStop); |
183 | 179 | }, |
184 | 180 | |
185 | - updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { | |
186 | - // this.multiPlotIntervalPanel.setVisible(isLinkedToMultiPlotMode); | |
181 | + updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { | |
187 | 182 | this.timeSelector.setVisible(isLinkedToMultiPlotMode); |
188 | 183 | }, |
189 | 184 | |
... | ... | @@ -254,44 +249,82 @@ Ext.define('amdaUI.PlotUI', { |
254 | 249 | ] |
255 | 250 | } |
256 | 251 | ], |
257 | - fbar: [ | |
258 | - { | |
259 | - xtype: 'button', | |
260 | - text: 'Plot', | |
261 | - scope: this, | |
262 | - handler: function(button) { | |
263 | - this.doPlot(); | |
264 | - } | |
265 | - }, | |
266 | - ' ', | |
267 | - { | |
268 | - xtype: 'button', | |
269 | - text: 'Get Data', | |
270 | - scope: this, | |
271 | - handler: function(button) { | |
272 | - this.getDataProcess(); | |
273 | - } | |
274 | - }, | |
275 | - ' ', | |
276 | - { | |
277 | - xtype: 'button', | |
278 | - text: 'Reset', | |
279 | - scope: this, | |
280 | - handler: function(button) { | |
281 | - this.resetProcess(); | |
282 | - } | |
283 | - }, | |
284 | - '->', | |
285 | - { | |
286 | - xtype: 'button', | |
287 | - text: 'Save Request', | |
288 | - scope: this, | |
289 | - handler: function(button) { | |
290 | - this.saveProcess(); | |
291 | - } | |
252 | + fbar: [{ | |
253 | + xtype: 'button', | |
254 | + text: 'Plot', | |
255 | + scope: this, | |
256 | + handler: function(button) { | |
257 | + this.doPlot(); | |
258 | + } | |
259 | + },' ', { | |
260 | + xtype: 'button', | |
261 | + text: 'Get Data', | |
262 | + scope: this, | |
263 | + handler: function(button) { | |
264 | + this.getDataProcess(); | |
265 | + } | |
266 | + },' ', { | |
267 | + xtype: 'button', | |
268 | + text: 'Reset', | |
269 | + scope: this, | |
270 | + handler: function(button) { | |
271 | + this.resetProcess(); | |
272 | + } | |
273 | + }, | |
274 | + '->', { | |
275 | + xtype: 'button', | |
276 | + text: 'Save Request', | |
277 | + scope: this, | |
278 | + handler: function(button) { | |
279 | + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | |
280 | + if (!plotModule) | |
281 | + return; | |
282 | + | |
283 | + this.updateObject(); | |
284 | + this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); | |
285 | + this.object.set('all-in-one', this.allPlots); | |
286 | + | |
287 | + //update existing request | |
288 | + if ((this.object.get('id') != '') && | |
289 | + (plotModule.linkedNode.get('text') == this.object.get('name'))) | |
290 | + plotModule.linkedNode.update(); | |
291 | + else { | |
292 | + var me = this; | |
293 | + plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { | |
294 | + if (!res) { | |
295 | + myDesktopApp.errorMsg('Error during object validation'); | |
296 | + return; | |
297 | + } | |
298 | + if (!res.valid) { | |
299 | + if (res.error) { | |
300 | + if (res.error.search('subtree') != -1) { | |
301 | + Ext.Msg.show( { title : 'Warning', | |
302 | + msg: res.error + '<br/>Do you want to overwrite it?', | |
303 | + width: 300, | |
304 | + buttons: Ext.Msg.OKCANCEL, | |
305 | + icon: Ext.Msg.WARNING, | |
306 | + fn : me.overwriteProcess, | |
307 | + scope : me | |
308 | + }); | |
309 | + } | |
310 | + else { | |
311 | + myDesktopApp.errorMsg(res.error); | |
312 | + } | |
313 | + } | |
314 | + else { | |
315 | + myDesktopApp.errorMsg('Invalid object name'); | |
316 | + } | |
317 | + | |
318 | + return; | |
319 | + } | |
320 | + me.saveProcess(false); | |
321 | + }) | |
322 | + } | |
323 | + } | |
292 | 324 | },' ', { |
293 | 325 | xtype: 'checkbox', |
294 | 326 | boxLabel: 'All Plot Tabs', |
327 | + name : 'all-in-one', | |
295 | 328 | listeners : { |
296 | 329 | scope: this, |
297 | 330 | change: function (cb, nv, ov) { |
... | ... | @@ -301,28 +334,29 @@ Ext.define('amdaUI.PlotUI', { |
301 | 334 | } |
302 | 335 | ] |
303 | 336 | }); |
304 | - | |
337 | + | |
305 | 338 | var myConf = { |
306 | - layout: 'border', | |
307 | - items: [ | |
308 | - this.formPanel, | |
309 | - { | |
310 | - xtype: 'panel', | |
311 | - region: 'south', | |
312 | - title: 'Information', | |
313 | - collapsible: true, | |
314 | - collapseMode: 'header', | |
315 | - height: 100, | |
316 | - autoHide: false, | |
317 | - bodyStyle: 'padding:5px', | |
318 | - iconCls: 'icon-information', | |
319 | - loader: { | |
320 | - autoLoad: true, | |
321 | - url: helpDir+'plotHOWTO' | |
322 | - } | |
323 | - } | |
324 | - ] | |
339 | + layout: 'border', | |
340 | + items: [ | |
341 | + this.formPanel, | |
342 | + { | |
343 | + xtype: 'panel', | |
344 | + region: 'south', | |
345 | + title: 'Information', | |
346 | + collapsible: true, | |
347 | + collapseMode: 'header', | |
348 | + height: 100, | |
349 | + autoHide: false, | |
350 | + bodyStyle: 'padding:5px', | |
351 | + iconCls: 'icon-information', | |
352 | + loader: { | |
353 | + autoLoad: true, | |
354 | + url: helpDir+'plotHOWTO' | |
355 | + } | |
356 | + } | |
357 | + ] | |
325 | 358 | }; |
326 | - Ext.apply (this , Ext.apply (arguments, myConf)); | |
359 | + | |
360 | + Ext.apply(this, Ext.apply(arguments, myConf)); | |
327 | 361 | } |
328 | 362 | }); |
... | ... |