From a39018a72e6f23593e6e6290969a2843e165c2ae Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 16 Mar 2016 15:58:13 +0100 Subject: [PATCH] ext6migrate: prepare panels for lazyitems since we want to make some tabpanels lazyitems, we have to change the behaviour of the configpanel and the subconfigpanel in the configpanel, we have to manually fire the hide event for the tabs which are lazyitems, because they will not be direct children of our tabpanel and thus their hide event will not fire in the subconfigpanel we have to manually save the to be active tab, since at this point, the subtabs are not there yet (and cannot be activated) also in the afterrender event, we only want to set the activetab when we have none, and we only set the first, if we have none saved Signed-off-by: Dominik Csapak --- www/manager6/panel/ConfigPanel.js | 8 ++++++++ www/manager6/panel/SubConfigPanel.js | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/www/manager6/panel/ConfigPanel.js b/www/manager6/panel/ConfigPanel.js index 94f8fbec..d78cd152 100644 --- a/www/manager6/panel/ConfigPanel.js +++ b/www/manager6/panel/ConfigPanel.js @@ -87,6 +87,14 @@ Ext.define('PVE.panel.Config', { sp.set(stateid, { value: ntab }); } } + + // if we have a tabpanel which we declared lazy (with ptype: lazyitems) + // then we have the actual item in items.items[0] + // and there we need to fire the event hide + // because some tabs use this event (which is not fired in this case) + if (oldcard.plugins && oldcard.plugins[0] && oldcard.plugins[0].ptype == 'lazyitems') { + oldcard.items.items[0].fireEvent('hide'); + } } } }); diff --git a/www/manager6/panel/SubConfigPanel.js b/www/manager6/panel/SubConfigPanel.js index e0a76192..5aa83bdd 100644 --- a/www/manager6/panel/SubConfigPanel.js +++ b/www/manager6/panel/SubConfigPanel.js @@ -5,12 +5,16 @@ Ext.define('PVE.panel.SubConfig', { configPrefix: undefined, tabPosition: 'left', tabRotation: 0, + savedTab: undefined, getHState: function(itemId) { /*jslint confusion: true */ var me = this; if (!itemId) { + if (me.getActiveTab() === undefined) { + me.setActiveTab(0); + } itemId = me.getActiveTab().itemId; } @@ -42,16 +46,21 @@ Ext.define('PVE.panel.SubConfig', { if (state && state.value) { var res = hsregex.exec(state.value); if (res && res[1] && res[2] && res[1] === me.configPrefix) { - me.activeTab = res[2]; + me.activeTab = res[2]; // if we have lazy items, this does nothing + me.savedTab = res[2]; // so we save it here } } Ext.apply(me, { listeners: { afterrender: function(tp) { - var first = tp.items.get(0); - if (first) { - first.fireEvent('show', first); + // if we have lazy items, + // we saved the tabname in savedTab + if (me.activeTab === undefined && me.savedTab) { + me.setActiveTab(me.savedTab); + } else if (me.activeTab === undefined) { + // if we have nothing else, we set 0 as active + me.setActiveTab(0); } }, tabchange: function(tp, newcard, oldcard) {