From 1a3aee6fdd23460ad7993139af2cf44339293ccc Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 2 Mar 2021 15:28:11 +0100 Subject: [PATCH] Fix extra tabs opened not keeping their orders after reload --- api/js/framework/fw_base.js | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/api/js/framework/fw_base.js b/api/js/framework/fw_base.js index cc64f58beb..5631e692bc 100644 --- a/api/js/framework/fw_base.js +++ b/api/js/framework/fw_base.js @@ -39,6 +39,10 @@ var fw_base = (function(){ "use strict"; return Class.extend( this.applications = new Object(); this.activeApp = null; + this.apps = null; + + this.tabApps = JSON.parse(egw.getSessionItem('api', 'fw_tab_apps')||null) || {}; + //Register the resize handler jQuery(window).resize(function(){window.framework.resizeHandler();}); @@ -70,6 +74,11 @@ var fw_base = (function(){ "use strict"; return Class.extend( //Close all open tabs, remove all applications from the application list this.sidemenuUi.clean(); this.tabsUi.clean(); + if (Object.keys(this.tabApps).length > 0) + { + apps = apps.concat(Object.values(this.tabApps)); + } + this.apps = apps; var defaultApp = null; var restore = new Object; @@ -435,7 +444,7 @@ var fw_base = (function(){ "use strict"; return Class.extend( if (serialized != this.serializedTabState) { this.serializedTabState = serialized; - + if (this.tabApps) this._setTabAppsSession(this.tabApps); egw.jsonq('EGroupware\\Api\\Framework\\Ajax::ajax_tab_changed_state', [data]); } }, @@ -567,6 +576,9 @@ var fw_base = (function(){ "use strict"; return Class.extend( { app.destroy(); } + + delete(this.tag.parentFw.tabApps[this.tag.appName]); + this.tag.parentFw._setTabAppsSession(this.tag.parentFw.tabApps); }, /** @@ -675,6 +687,14 @@ var fw_base = (function(){ "use strict"; return Class.extend( } }, + _setTabAppsSession: function(_tabApps) + { + if (_tabApps) + { + egw.setSessionItem('api', 'fw_tab_apps', JSON.stringify(_tabApps)); + } + }, + tabLinkHandler: function(_link, _extra) { var app = this.parseAppFromUrl(_link); @@ -707,6 +727,17 @@ var fw_base = (function(){ "use strict"; return Class.extend( this.applicationTabNavigate(this.applications[appname], _link, false, -1, null); + this.tabApps[appname] = (jQuery.extend(true, this.apps.filter(a=>{if (a.name == app.appName) return a})[0], { + title: _extra.displayName, + icon:_extra.icon, + name: appname, + opened: this.tabsUi.tabs.length+1, + url: _link, + internalName: app.appName, + active: true + })); + + this._setTabAppsSession(this.tabApps); } else { @@ -818,7 +849,13 @@ var fw_base = (function(){ "use strict"; return Class.extend( if (_app.tab) { this.tabsUi.showTab(_app.tab); - + if (this.tabApps && this.tabApps[_app.appName]) + { + for (let t in this.tabApps) + { + this.tabApps[t]['active'] = t == _app.appName; + } + } //Going to a new tab changes the tab state this.notifyTabChange(); }