From 3ae1941af291d2b90ef57f8ea92e2e3bd63d69d4 Mon Sep 17 00:00:00 2001 From: oxixes Date: Mon, 17 Jun 2024 12:47:32 +0200 Subject: [PATCH] Fix sidebars resetting their active state on window resize --- src/wirecloud/commons/middleware.py | 2 ++ .../platform/static/js/wirecloud/ui/SidebarLayout.js | 11 ++++++++--- .../js/wirecloud/ui/WorkspaceTabViewDragboard.js | 8 ++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/wirecloud/commons/middleware.py b/src/wirecloud/commons/middleware.py index 5103b8c30e..5daffbe695 100644 --- a/src/wirecloud/commons/middleware.py +++ b/src/wirecloud/commons/middleware.py @@ -157,6 +157,8 @@ class LocaleMiddleware(MiddlewareMixin): def process_request(self, request): if 'lang' in request.GET and translation.check_for_language(request.GET['lang']): language = request.GET['lang'] + elif 'lang' in request.COOKIES and translation.check_for_language(request.COOKIES['lang']): + language = request.COOKIES['lang'] else: language = translation.get_language_from_request(request, check_path=False) translation.activate(language) diff --git a/src/wirecloud/platform/static/js/wirecloud/ui/SidebarLayout.js b/src/wirecloud/platform/static/js/wirecloud/ui/SidebarLayout.js index 118b25b58e..3e1284bb3c 100644 --- a/src/wirecloud/platform/static/js/wirecloud/ui/SidebarLayout.js +++ b/src/wirecloud/platform/static/js/wirecloud/ui/SidebarLayout.js @@ -79,7 +79,8 @@ constructor(dragboard, options) { options = utils.merge({ - position: "left" + position: "left", + active: false }, options); if (POSITIONS.indexOf(options.position) === -1) { @@ -97,7 +98,7 @@ ); privates.set(this, { - active: false + active: options.active }); Object.defineProperties(this, { @@ -115,7 +116,7 @@ this.handle = document.createElement("div"); this.handleicon = document.createElement("i"); - this.handleicon.className = "fas fa-caret-" + OPPOSITE[this.position]; + this.handleicon.className = "fas fa-caret-" + (this.active ? ICON[this.position] : OPPOSITE[this.position]); this.handle.appendChild(this.handleicon); this.handle.addEventListener("click", () => { this.active = !this.active; @@ -245,6 +246,10 @@ } } + isActive() { + return this.active; + } + } })(Wirecloud.ui, Wirecloud.Utils); diff --git a/src/wirecloud/platform/static/js/wirecloud/ui/WorkspaceTabViewDragboard.js b/src/wirecloud/platform/static/js/wirecloud/ui/WorkspaceTabViewDragboard.js index c6ada260f1..65a1f7f6d2 100644 --- a/src/wirecloud/platform/static/js/wirecloud/ui/WorkspaceTabViewDragboard.js +++ b/src/wirecloud/platform/static/js/wirecloud/ui/WorkspaceTabViewDragboard.js @@ -217,10 +217,10 @@ this.fulldragboardLayout = new Wirecloud.ui.FullDragboardLayout(this); this.baseLayout = this._buildLayoutFromPreferences(); this.freeLayout = new Wirecloud.ui.FreeLayout(this); - this.leftLayout = new Wirecloud.ui.SidebarLayout(this); - this.rightLayout = new Wirecloud.ui.SidebarLayout(this, {position: "right"}); - this.bottomLayout = new Wirecloud.ui.SidebarLayout(this, {position: "bottom"}); - this.topLayout = new Wirecloud.ui.SidebarLayout(this, {position: "top"}); + this.leftLayout = new Wirecloud.ui.SidebarLayout(this, {active: (this.leftLayout) ? this.leftLayout.isActive() : false}); + this.rightLayout = new Wirecloud.ui.SidebarLayout(this, {position: "right", active: (this.rightLayout) ? this.rightLayout.isActive() : false}); + this.bottomLayout = new Wirecloud.ui.SidebarLayout(this, {position: "bottom", active: (this.bottomLayout) ? this.bottomLayout.isActive() : false}); + this.topLayout = new Wirecloud.ui.SidebarLayout(this, {position: "top", active: (this.topLayout) ? this.topLayout.isActive() : false}); } updateWidgetScreenSize(screenSize) {