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 <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2016-03-16 15:58:13 +01:00 committed by Dietmar Maurer
parent 50c3086016
commit a39018a72e
2 changed files with 21 additions and 4 deletions

View File

@ -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');
}
}
}
});

View File

@ -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) {