From 0ead0129ba3bf0d7c8c556639d18cce4290afeba Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 3 May 2019 14:42:20 +0200 Subject: [PATCH] Modify save plot tabs --- js/app/models/PlotNode.js | 33 +++++++++++++++++---------------- js/app/views/PlotUI.js | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------- php/classes/AmdaAction.php | 5 ++++- php/classes/RequestMgr.php | 15 ++++++++++++++- 4 files changed, 98 insertions(+), 86 deletions(-) diff --git a/js/app/models/PlotNode.js b/js/app/models/PlotNode.js index 3dc8cc3..ec52b4f 100644 --- a/js/app/models/PlotNode.js +++ b/js/app/models/PlotNode.js @@ -27,28 +27,29 @@ Ext.define('amdaModel.PlotNode', { this.set('moduleId',myDesktopApp.dynamicModules.plot.id); this.set('objectDataModel','amdaPlotObj.PlotRequestObject'); this.set('nodeType',this.self.nodeType); - this.updateTabs(); + this.updateTabs(this.get('tabs')); }, - updateTabs : function() { - if (this.get('tabs')) { - var isFolder = !this.get('leaf'); - if (!isFolder) { - var oneTab = (this.get('tabs').length == 1); - this.set('leaf', oneTab); - this.set('iconCls', oneTab ? 'icon-plot-page' : 'icon-plot-pages'); - this.removeAll(); - if (this.get('tabs').length > 1) { - var me = this; - Ext.Array.each(this.get('tabs'), function(tab) { - var tabNode = new amdaModel.PlotTabNode({text: tab.name, tabid: tab.id}); - me.appendChild(tabNode); - }); - } + updateTabs : function(tabs) { + if (tabs) { + var oneTab = (tabs.length == 1); + this.set('leaf', oneTab); + this.set('iconCls', oneTab ? 'icon-plot-page' : 'icon-plot-pages'); + this.removeAll(); + if (tabs.length > 1) { + var me = this; + Ext.Array.each(tabs, function(tab) { + var tabNode = new amdaModel.PlotTabNode({text: tab.name, tabid: tab.id}); + me.appendChild(tabNode); + }); } } }, + specialUpdate : function(res) { + this.updateTabs(res.tabs); + }, + allMenuItems : function() { var menuItems = [{ diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index e604eae..f872777 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -32,8 +32,6 @@ Ext.define('amdaUI.PlotUI', { plotElement : null, - allPlots : false, - constructor: function(config) { this.init(config); this.callParent(arguments); @@ -47,12 +45,6 @@ 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')); - }, - - updateRequestOption : function(allInOne) { - var requestOptionCB = this.formPanel.getForm().findField('all-in-one'); - requestOptionCB.setValue(allInOne); }, /** @@ -184,6 +176,52 @@ Ext.define('amdaUI.PlotUI', { updateLinkedToMultiPlotMode : function(isLinkedToMultiPlotMode) { this.timeSelector.setVisible(isLinkedToMultiPlotMode); }, + + savePlotRequest : function(allTabs = false) { + 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', allTabs); + + if ((this.object.get('id') != '') && (plotModule.linkedNode.get('text') == this.object.get('name'))) { + //update existing request + plotModule.linkedNode.update(); + return; + } + + //save new request + 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 + '
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); + }); + }, init : function(config) { 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', { ] } ], - fbar: [{ + fbar: [ + { xtype: 'button', text: 'Plot', scope: this, @@ -275,68 +314,24 @@ Ext.define('amdaUI.PlotUI', { } }, '->', '-', { - xtype: 'button', - text: 'Save Request', + xtype: 'splitbutton', + text: 'Save All Tabs', + menu: { + items: [ + { + text: 'Save Current Tab', + scope: this, + handler: function() { + this.savePlotRequest(false); + } + }, + ] + }, 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 + '
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); - }) - } - } - }, ' ', - myDesktopApp.addAmdaInfo('plotSaveRequest'), - ' ', { - xtype: 'checkbox', - boxLabel: 'All Plot Tabs', - name : 'all-in-one', - listeners : { - scope: this, - change: function (cb, nv, ov) { - this.allPlots = nv; - } + this.savePlotRequest(true); } - } + } ] }); diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index c82b529..2da38d5 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -151,7 +151,7 @@ class AmdaAction $isParameter = false; $isAddable = false; $isSimulation = false; - $plotTabs = array(); + $plotTabs = FALSE; $rank = null; $skip = FALSE; @@ -188,6 +188,7 @@ class AmdaAction $isLeaf = isset($objplot->tabs); if ($isLeaf) { + $plotTabs = array(); foreach ($objplot->tabs as $index => $tab) { $plotTabs[$index] = array( "name" => "Plot ".($index+1), @@ -195,6 +196,8 @@ class AmdaAction ); } } + else + $plotTabs = FALSE; break; case 'alias': diff --git a/php/classes/RequestMgr.php b/php/classes/RequestMgr.php index 60844a3..c3d0e25 100644 --- a/php/classes/RequestMgr.php +++ b/php/classes/RequestMgr.php @@ -177,6 +177,19 @@ class RequestMgr extends AmdaObjectMgr } } } + + $additional = array(); + if ($this->type == 'request') { + $additional['tabs'] = array(); + if (isset($p->tabs)) { + foreach ($p->tabs as $index => $tab) { + $additional['tabs'][$index] = array( + "name" => "Plot ".($index+1), + "id" => $tab->id, + ); + } + } + } $this->descFileName = USERREQDIR.$this->id; $p->id = $this->id; @@ -187,7 +200,7 @@ class RequestMgr extends AmdaObjectMgr $this -> addToContent($p, $folder); - return array('id' => $this->id, 'info' => $info); + return array('id' => $this->id, 'info' => $info) + $additional; } public static function checkRequest($obj) -- libgit2 0.21.2