From 87dcaf0151c7f2bf89071629fe30a21775d8bc48 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 9 May 2019 10:57:48 +0200 Subject: [PATCH] Rename plot name in PlotUI --- js/app/views/PlotComponents/PlotTabPanel.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/js/app/views/PlotComponents/PlotTabPanel.js b/js/app/views/PlotComponents/PlotTabPanel.js index 5fa631b..111bdef 100644 --- a/js/app/views/PlotComponents/PlotTabPanel.js +++ b/js/app/views/PlotComponents/PlotTabPanel.js @@ -53,6 +53,7 @@ Ext.define('amdaPlotComp.PlotTabPanel', { var tabNumber = this.getTabBar().items.getCount(); var tabContent = new amdaPlotComp.PlotTabContent({plotElementPanel: this.plotElementPanel, plotTabPanel : this, tabId : tabObject.get('id')}); tabContent.setTabObject(tabObject); + var me = this; var tabComp = this.add({ title: (tabObject.get('tab-name') != '') ? tabObject.get('tab-name') : 'Plot '+tabNumber, closable: true, @@ -79,8 +80,31 @@ Ext.define('amdaPlotComp.PlotTabPanel', { this.object.removeTabById(tab.items.getAt(0).object.get('id')); }, destroy: function(tab, eOpts) { + this.updatePlotTabs(); - } + }, + afterrender: function(tab, e0pts) { + tab.tab.el.on('contextmenu', function(e, t, eOpts) { + var menu = new Ext.menu.Menu({ + items: [ + { + text: 'Rename', + handler: function() { + Ext.Msg.prompt('Rename', 'Please enter new plot tab name:', function(btn, text){ + if (btn == 'ok'){ + tabObject.set('tab-name',text); + me.updatePlotTabs(); + } + }, me); + } + } + ] + }); + var position = e.getXY(); + e.stopEvent(); + menu.showAt(position); + },this); + } } }); @@ -165,13 +189,7 @@ Ext.define('amdaPlotComp.PlotTabPanel', { handler:function(btn,e){ var tabContent = me.addPlotTab(me.object.createNewTab(), true); } - }], - listeners: { - click: function(tabBar, e, eOpts) { - console.log('click'); - }, - scope: me - } + }] }, listeners: { -- libgit2 0.21.2