Commit 0ead0129ba3bf0d7c8c556639d18cce4290afeba
1 parent
3efc6401
Exists in
master
and in
103 other branches
Modify save plot tabs
Showing
4 changed files
with
98 additions
and
86 deletions
Show diff stats
js/app/models/PlotNode.js
@@ -27,28 +27,29 @@ Ext.define('amdaModel.PlotNode', { | @@ -27,28 +27,29 @@ Ext.define('amdaModel.PlotNode', { | ||
27 | this.set('moduleId',myDesktopApp.dynamicModules.plot.id); | 27 | this.set('moduleId',myDesktopApp.dynamicModules.plot.id); |
28 | this.set('objectDataModel','amdaPlotObj.PlotRequestObject'); | 28 | this.set('objectDataModel','amdaPlotObj.PlotRequestObject'); |
29 | this.set('nodeType',this.self.nodeType); | 29 | this.set('nodeType',this.self.nodeType); |
30 | - this.updateTabs(); | 30 | + this.updateTabs(this.get('tabs')); |
31 | }, | 31 | }, |
32 | 32 | ||
33 | - updateTabs : function() { | ||
34 | - if (this.get('tabs')) { | ||
35 | - var isFolder = !this.get('leaf'); | ||
36 | - if (!isFolder) { | ||
37 | - var oneTab = (this.get('tabs').length == 1); | ||
38 | - this.set('leaf', oneTab); | ||
39 | - this.set('iconCls', oneTab ? 'icon-plot-page' : 'icon-plot-pages'); | ||
40 | - this.removeAll(); | ||
41 | - if (this.get('tabs').length > 1) { | ||
42 | - var me = this; | ||
43 | - Ext.Array.each(this.get('tabs'), function(tab) { | ||
44 | - var tabNode = new amdaModel.PlotTabNode({text: tab.name, tabid: tab.id}); | ||
45 | - me.appendChild(tabNode); | ||
46 | - }); | ||
47 | - } | 33 | + updateTabs : function(tabs) { |
34 | + if (tabs) { | ||
35 | + var oneTab = (tabs.length == 1); | ||
36 | + this.set('leaf', oneTab); | ||
37 | + this.set('iconCls', oneTab ? 'icon-plot-page' : 'icon-plot-pages'); | ||
38 | + this.removeAll(); | ||
39 | + if (tabs.length > 1) { | ||
40 | + var me = this; | ||
41 | + Ext.Array.each(tabs, function(tab) { | ||
42 | + var tabNode = new amdaModel.PlotTabNode({text: tab.name, tabid: tab.id}); | ||
43 | + me.appendChild(tabNode); | ||
44 | + }); | ||
48 | } | 45 | } |
49 | } | 46 | } |
50 | }, | 47 | }, |
51 | 48 | ||
49 | + specialUpdate : function(res) { | ||
50 | + this.updateTabs(res.tabs); | ||
51 | + }, | ||
52 | + | ||
52 | allMenuItems : function() { | 53 | allMenuItems : function() { |
53 | var menuItems = | 54 | var menuItems = |
54 | [{ | 55 | [{ |
js/app/views/PlotUI.js
@@ -32,8 +32,6 @@ Ext.define('amdaUI.PlotUI', { | @@ -32,8 +32,6 @@ Ext.define('amdaUI.PlotUI', { | ||
32 | 32 | ||
33 | plotElement : null, | 33 | plotElement : null, |
34 | 34 | ||
35 | - allPlots : false, | ||
36 | - | ||
37 | constructor: function(config) { | 35 | constructor: function(config) { |
38 | this.init(config); | 36 | this.init(config); |
39 | this.callParent(arguments); | 37 | this.callParent(arguments); |
@@ -47,12 +45,6 @@ Ext.define('amdaUI.PlotUI', { | @@ -47,12 +45,6 @@ Ext.define('amdaUI.PlotUI', { | ||
47 | this.plotTabs.setRequestObject(this.object); | 45 | this.plotTabs.setRequestObject(this.object); |
48 | this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate')); | 46 | this.timeSelector.intervalSel.setInterval(this.object.get('startDate'), this.object.get('stopDate')); |
49 | this.addTTs(this.object.get('timeTables')); | 47 | this.addTTs(this.object.get('timeTables')); |
50 | - this.updateRequestOption(this.object.get('all-in-one')); | ||
51 | - }, | ||
52 | - | ||
53 | - updateRequestOption : function(allInOne) { | ||
54 | - var requestOptionCB = this.formPanel.getForm().findField('all-in-one'); | ||
55 | - requestOptionCB.setValue(allInOne); | ||
56 | }, | 48 | }, |
57 | 49 | ||
58 | /** | 50 | /** |
@@ -184,6 +176,52 @@ Ext.define('amdaUI.PlotUI', { | @@ -184,6 +176,52 @@ Ext.define('amdaUI.PlotUI', { | ||
184 | updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { | 176 | updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { |
185 | this.timeSelector.setVisible(isLinkedToMultiPlotMode); | 177 | this.timeSelector.setVisible(isLinkedToMultiPlotMode); |
186 | }, | 178 | }, |
179 | + | ||
180 | + savePlotRequest : function(allTabs = false) { | ||
181 | + var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | ||
182 | + if (!plotModule) | ||
183 | + return; | ||
184 | + this.updateObject(); | ||
185 | + this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); | ||
186 | + this.object.set('all-in-one', allTabs); | ||
187 | + | ||
188 | + if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) { | ||
189 | + //update existing request | ||
190 | + plotModule.linkedNode.update(); | ||
191 | + return; | ||
192 | + } | ||
193 | + | ||
194 | + //save new request | ||
195 | + var me = this; | ||
196 | + plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { | ||
197 | + if (!res) { | ||
198 | + myDesktopApp.errorMsg('Error during object validation'); | ||
199 | + return; | ||
200 | + } | ||
201 | + if (!res.valid) { | ||
202 | + if (res.error) { | ||
203 | + if (res.error.search('subtree') != -1) { | ||
204 | + Ext.Msg.show( { title : 'Warning', | ||
205 | + msg: res.error + '<br/>Do you want to overwrite it?', | ||
206 | + width: 300, | ||
207 | + buttons: Ext.Msg.OKCANCEL, | ||
208 | + icon: Ext.Msg.WARNING, | ||
209 | + fn : me.overwriteProcess, | ||
210 | + scope : me | ||
211 | + }); | ||
212 | + } | ||
213 | + else { | ||
214 | + myDesktopApp.errorMsg(res.error); | ||
215 | + } | ||
216 | + } | ||
217 | + else { | ||
218 | + myDesktopApp.errorMsg('Invalid object name'); | ||
219 | + } | ||
220 | + return; | ||
221 | + } | ||
222 | + me.saveProcess(false); | ||
223 | + }); | ||
224 | + }, | ||
187 | 225 | ||
188 | init : function(config) { | 226 | init : function(config) { |
189 | this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'multiPlotTimeSelector' + config.id, title : 'MultiPlot Time Selection', border : false, collapsible : true, collapseDirection : 'bottom', visible : false, flex: 2 } ); | 227 | this.timeSelector = new amdaUI.TimeSelectorUI( { id: 'multiPlotTimeSelector' + config.id, title : 'MultiPlot Time Selection', border : false, collapsible : true, collapseDirection : 'bottom', visible : false, flex: 2 } ); |
@@ -252,7 +290,8 @@ Ext.define('amdaUI.PlotUI', { | @@ -252,7 +290,8 @@ Ext.define('amdaUI.PlotUI', { | ||
252 | ] | 290 | ] |
253 | } | 291 | } |
254 | ], | 292 | ], |
255 | - fbar: [{ | 293 | + fbar: [ |
294 | + { | ||
256 | xtype: 'button', | 295 | xtype: 'button', |
257 | text: 'Plot', | 296 | text: 'Plot', |
258 | scope: this, | 297 | scope: this, |
@@ -275,68 +314,24 @@ Ext.define('amdaUI.PlotUI', { | @@ -275,68 +314,24 @@ Ext.define('amdaUI.PlotUI', { | ||
275 | } | 314 | } |
276 | }, | 315 | }, |
277 | '->', '-', { | 316 | '->', '-', { |
278 | - xtype: 'button', | ||
279 | - text: 'Save Request', | 317 | + xtype: 'splitbutton', |
318 | + text: 'Save All Tabs', | ||
319 | + menu: { | ||
320 | + items: [ | ||
321 | + { | ||
322 | + text: 'Save Current Tab', | ||
323 | + scope: this, | ||
324 | + handler: function() { | ||
325 | + this.savePlotRequest(false); | ||
326 | + } | ||
327 | + }, | ||
328 | + ] | ||
329 | + }, | ||
280 | scope: this, | 330 | scope: this, |
281 | handler: function(button) { | 331 | handler: function(button) { |
282 | - var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id); | ||
283 | - if (!plotModule) | ||
284 | - return; | ||
285 | - | ||
286 | - this.updateObject(); | ||
287 | - this.object.set('active-tab-id', this.plotTabs.getSelectedTabId()); | ||
288 | - this.object.set('all-in-one', this.allPlots); | ||
289 | - | ||
290 | - //update existing request | ||
291 | - if ((this.object.get('id') != '') && | ||
292 | - (plotModule.linkedNode.get('text') == this.object.get('name'))) | ||
293 | - plotModule.linkedNode.update(); | ||
294 | - else { | ||
295 | - var me = this; | ||
296 | - plotModule.linkedNode.isValidName(this.object.get('name'), function (res) { | ||
297 | - if (!res) { | ||
298 | - myDesktopApp.errorMsg('Error during object validation'); | ||
299 | - return; | ||
300 | - } | ||
301 | - if (!res.valid) { | ||
302 | - if (res.error) { | ||
303 | - if (res.error.search('subtree') != -1) { | ||
304 | - Ext.Msg.show( { title : 'Warning', | ||
305 | - msg: res.error + '<br/>Do you want to overwrite it?', | ||
306 | - width: 300, | ||
307 | - buttons: Ext.Msg.OKCANCEL, | ||
308 | - icon: Ext.Msg.WARNING, | ||
309 | - fn : me.overwriteProcess, | ||
310 | - scope : me | ||
311 | - }); | ||
312 | - } | ||
313 | - else { | ||
314 | - myDesktopApp.errorMsg(res.error); | ||
315 | - } | ||
316 | - } | ||
317 | - else { | ||
318 | - myDesktopApp.errorMsg('Invalid object name'); | ||
319 | - } | ||
320 | - | ||
321 | - return; | ||
322 | - } | ||
323 | - me.saveProcess(false); | ||
324 | - }) | ||
325 | - } | ||
326 | - } | ||
327 | - }, ' ', | ||
328 | - myDesktopApp.addAmdaInfo('plotSaveRequest'), | ||
329 | - ' ', { | ||
330 | - xtype: 'checkbox', | ||
331 | - boxLabel: 'All Plot Tabs', | ||
332 | - name : 'all-in-one', | ||
333 | - listeners : { | ||
334 | - scope: this, | ||
335 | - change: function (cb, nv, ov) { | ||
336 | - this.allPlots = nv; | ||
337 | - } | 332 | + this.savePlotRequest(true); |
338 | } | 333 | } |
339 | - } | 334 | + } |
340 | ] | 335 | ] |
341 | }); | 336 | }); |
342 | 337 |
php/classes/AmdaAction.php
@@ -151,7 +151,7 @@ class AmdaAction | @@ -151,7 +151,7 @@ class AmdaAction | ||
151 | $isParameter = false; | 151 | $isParameter = false; |
152 | $isAddable = false; | 152 | $isAddable = false; |
153 | $isSimulation = false; | 153 | $isSimulation = false; |
154 | - $plotTabs = array(); | 154 | + $plotTabs = FALSE; |
155 | $rank = null; | 155 | $rank = null; |
156 | $skip = FALSE; | 156 | $skip = FALSE; |
157 | 157 | ||
@@ -188,6 +188,7 @@ class AmdaAction | @@ -188,6 +188,7 @@ class AmdaAction | ||
188 | 188 | ||
189 | $isLeaf = isset($objplot->tabs); | 189 | $isLeaf = isset($objplot->tabs); |
190 | if ($isLeaf) { | 190 | if ($isLeaf) { |
191 | + $plotTabs = array(); | ||
191 | foreach ($objplot->tabs as $index => $tab) { | 192 | foreach ($objplot->tabs as $index => $tab) { |
192 | $plotTabs[$index] = array( | 193 | $plotTabs[$index] = array( |
193 | "name" => "Plot ".($index+1), | 194 | "name" => "Plot ".($index+1), |
@@ -195,6 +196,8 @@ class AmdaAction | @@ -195,6 +196,8 @@ class AmdaAction | ||
195 | ); | 196 | ); |
196 | } | 197 | } |
197 | } | 198 | } |
199 | + else | ||
200 | + $plotTabs = FALSE; | ||
198 | break; | 201 | break; |
199 | 202 | ||
200 | case 'alias': | 203 | case 'alias': |
php/classes/RequestMgr.php
@@ -177,6 +177,19 @@ class RequestMgr extends AmdaObjectMgr | @@ -177,6 +177,19 @@ class RequestMgr extends AmdaObjectMgr | ||
177 | } | 177 | } |
178 | } | 178 | } |
179 | } | 179 | } |
180 | + | ||
181 | + $additional = array(); | ||
182 | + if ($this->type == 'request') { | ||
183 | + $additional['tabs'] = array(); | ||
184 | + if (isset($p->tabs)) { | ||
185 | + foreach ($p->tabs as $index => $tab) { | ||
186 | + $additional['tabs'][$index] = array( | ||
187 | + "name" => "Plot ".($index+1), | ||
188 | + "id" => $tab->id, | ||
189 | + ); | ||
190 | + } | ||
191 | + } | ||
192 | + } | ||
180 | 193 | ||
181 | $this->descFileName = USERREQDIR.$this->id; | 194 | $this->descFileName = USERREQDIR.$this->id; |
182 | $p->id = $this->id; | 195 | $p->id = $this->id; |
@@ -187,7 +200,7 @@ class RequestMgr extends AmdaObjectMgr | @@ -187,7 +200,7 @@ class RequestMgr extends AmdaObjectMgr | ||
187 | 200 | ||
188 | $this -> addToContent($p, $folder); | 201 | $this -> addToContent($p, $folder); |
189 | 202 | ||
190 | - return array('id' => $this->id, 'info' => $info); | 203 | + return array('id' => $this->id, 'info' => $info) + $additional; |
191 | } | 204 | } |
192 | 205 | ||
193 | public static function checkRequest($obj) | 206 | public static function checkRequest($obj) |