Fix issue after closing a tab app next available tab wont get selected properly

This commit is contained in:
Hadi Nategh 2021-03-10 11:56:34 +01:00
parent 81d5574fff
commit 864b896ad6
2 changed files with 16 additions and 9 deletions

View File

@ -128,7 +128,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
this.appData = new egw_fw_class_application(this, this.appData = new egw_fw_class_application(this,
app.name, app.title, app.icon, app.url, app.sideboxwidth, app.name, app.title, app.icon, app.url, app.sideboxwidth,
baseUrl, internalName); baseUrl, internalName);
if (app.isTabApp) this.appData['isTabApp'] = true;
//Create a sidebox menu entry for each application //Create a sidebox menu entry for each application
if (!app.noNavbar && app.status != 5) if (!app.noNavbar && app.status != 5)
{ {
@ -517,7 +517,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
//Set the tab closeable if there's more than one tab //Set the tab closeable if there's more than one tab
this.tabsUi.setCloseable(this.tabsUi._isNotTheLastTab()); this.tabsUi.setCloseable(this.tabsUi._isNotTheLastTab());
// Do not show tab header if the app is with status 5, means run in background // Do not show tab header if the app is with status 5, means run in background
if (_status == 5 && !this.tabApps[_app.appName]) _app.tab.hideTabHeader(true); if (_status == 5 && !_app.isTabApp) _app.tab.hideTabHeader(true);
} }
}, },
@ -746,7 +746,8 @@ var fw_base = (function(){ "use strict"; return Class.extend(
opened: this.tabsUi.tabs.length+1, opened: this.tabsUi.tabs.length+1,
url: _link, url: _link,
internalName: app.appName, internalName: app.appName,
active: true active: true,
isTabApp: true
})); }));
this._setTabAppsSession(this.tabApps); this._setTabAppsSession(this.tabApps);
@ -863,7 +864,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
if (_app.tab) if (_app.tab)
{ {
this.tabsUi.showTab(_app.tab); this.tabsUi.showTab(_app.tab);
if (this.tabApps && this.tabApps[_app.appName]) if (this.tabApps)
{ {
for (let t in this.tabApps) for (let t in this.tabApps)
{ {

View File

@ -665,7 +665,13 @@ egw_fw_ui_tabs.prototype.removeTab = function(_tab)
//Delete entries in the histroy which might be double //Delete entries in the histroy which might be double
this.cleanHistory(); this.cleanHistory();
// lookup for next available tab
var lookUpTheNextTab = function(_tab){
for(var t in this.tabs)
{
if (_tab != this.tabs[t] && (this.tabs[t]['status'] != '5' || this.tabs[t]['tag']['isTabApp'])) return this.tabs[t];
}
}.bind(this);
//Special treatement if the currently active tab gets deleted //Special treatement if the currently active tab gets deleted
if (_tab == this.activeTab) if (_tab == this.activeTab)
{ {
@ -673,8 +679,8 @@ egw_fw_ui_tabs.prototype.removeTab = function(_tab)
if (this.tabs.length > 0) if (this.tabs.length > 0)
{ {
//Check whether there is another tab in the tab history, //Check whether there is another tab in the tab history,
//if not, simply show the first (or next, if tab is first) tab in the list. //if not, look up for the next available tab.
var tab = _tab == this.tabs[0] ? this.tabs[1] : this.tabs[0]; var tab = lookUpTheNextTab(_tab);
if (typeof this.tabHistory[this.tabHistory.length - 1] != 'undefined') if (typeof this.tabHistory[this.tabHistory.length - 1] != 'undefined')
{ {
tab = this.tabHistory[this.tabHistory.length - 1]; tab = this.tabHistory[this.tabHistory.length - 1];
@ -700,7 +706,7 @@ egw_fw_ui_tabs.prototype.removeTab = function(_tab)
*/ */
egw_fw_ui_tabs.prototype.showTab = function(_tab) egw_fw_ui_tabs.prototype.showTab = function(_tab)
{ {
if (this.activeTab != _tab) if (this.activeTab != _tab && (_tab.status != '5' || _tab.tag.isTabApp))
{ {
for (var i = 0; i < this.tabs.length; i++) for (var i = 0; i < this.tabs.length; i++)
{ {
@ -768,7 +774,7 @@ egw_fw_ui_tabs.prototype._isNotTheLastTab = function()
for (var i in this.tabs) for (var i in this.tabs)
{ {
//exclude open tabs with status 5, e.g. status app //exclude open tabs with status 5, e.g. status app
if (this.tabs[i]['status'] != '5') n++; if (this.tabs[i]['status'] != '5' || this.tabs[i]['tag']['isTabApp']) n++;
} }
return n > 1 ? true : false; return n > 1 ? true : false;
}; };