From 644c8f2bd29eaf663cb2b189616b683411a62586 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 27 Mar 2020 16:46:09 +0300 Subject: [PATCH] [SSE] Remember active panel selected by user (for pivot and format tables) --- .../main/app/controller/PivotTable.js | 1 + .../main/app/controller/RightMenu.js | 33 +++++++++++++++++-- .../main/app/view/RightMenu.js | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/PivotTable.js b/apps/spreadsheeteditor/main/app/controller/PivotTable.js index ae385a981..1d7ea91e9 100644 --- a/apps/spreadsheeteditor/main/app/controller/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/controller/PivotTable.js @@ -163,6 +163,7 @@ define([ api: me.api, handler: function(result, settings) { if (result == 'ok' && settings) { + me.view && me.view.fireEvent('insertpivot', me.view); if (settings.destination) me.api.asc_insertPivotExistingWorksheet(settings.source, settings.destination); else diff --git a/apps/spreadsheeteditor/main/app/controller/RightMenu.js b/apps/spreadsheeteditor/main/app/controller/RightMenu.js index c9f186f55..7ea0ce290 100644 --- a/apps/spreadsheeteditor/main/app/controller/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/RightMenu.js @@ -66,6 +66,9 @@ define([ }, 'RightMenu': { 'rightmenuclick': this.onRightMenuClick + }, + 'PivotTable': { + 'insertpivot': this.onInsertPivot } }); }, @@ -103,8 +106,21 @@ define([ this.editMode = mode.isEdit; }, - onRightMenuClick: function(menu, type, minimized) { + onRightMenuClick: function(menu, type, minimized, event) { if (!minimized && this.editMode) { + if (event) { // user click event + if (type == Common.Utils.documentSettingsType.Table) + Common.Utils.InternalSettings.set("sse-rightpanel-active-table", 1); + else if (type == Common.Utils.documentSettingsType.Pivot) + Common.Utils.InternalSettings.set("sse-rightpanel-active-pivot", 1); + else if (Common.Utils.documentSettingsType.Cell) { + if (!this._settings[Common.Utils.documentSettingsType.Table].hidden) + Common.Utils.InternalSettings.set("sse-rightpanel-active-table", 0); + if (!this._settings[Common.Utils.documentSettingsType.Pivot].hidden) + Common.Utils.InternalSettings.set("sse-rightpanel-active-pivot", 0); + } + } + var panel = this._settings[type].panel; var props = this._settings[type].props; if (props && panel) @@ -239,6 +255,14 @@ define([ if (!this.rightmenu.minimizedMode || this._openRightMenu) { var active; + if (priorityactive<0 && !this._settings[Common.Utils.documentSettingsType.Cell].hidden && + (!this._settings[Common.Utils.documentSettingsType.Table].hidden || !this._settings[Common.Utils.documentSettingsType.Pivot].hidden)) { + if (!this._settings[Common.Utils.documentSettingsType.Table].hidden) + priorityactive = Common.Utils.InternalSettings.get("sse-rightpanel-active-table")==0 ? Common.Utils.documentSettingsType.Cell : Common.Utils.documentSettingsType.Table; + if (!this._settings[Common.Utils.documentSettingsType.Pivot].hidden) + priorityactive = Common.Utils.InternalSettings.get("sse-rightpanel-active-pivot")==0 ? Common.Utils.documentSettingsType.Cell : Common.Utils.documentSettingsType.Pivot; + } + if (priorityactive>-1) active = priorityactive; else if (lastactive>=0 && currentactive<0) active = lastactive; else if (currentactive>=0) active = currentactive; @@ -259,6 +283,7 @@ define([ this._settings[Common.Utils.documentSettingsType.Image].needShow = false; this._settings[Common.Utils.documentSettingsType.Chart].needShow = false; this._settings[Common.Utils.documentSettingsType.Table].needShow = false; + this._settings[Common.Utils.documentSettingsType.Pivot].needShow = false; }, onCoAuthoringDisconnect: function() { @@ -283,7 +308,11 @@ define([ }, onInsertTable: function() { - this._settings[Common.Utils.documentSettingsType.Table].needShow = true; + // this._settings[Common.Utils.documentSettingsType.Table].needShow = true; + }, + + onInsertPivot: function() { + // this._settings[Common.Utils.documentSettingsType.Pivot].needShow = true; }, UpdateThemeColors: function() { diff --git a/apps/spreadsheeteditor/main/app/view/RightMenu.js b/apps/spreadsheeteditor/main/app/view/RightMenu.js index a7595f7fe..99e2e1bd4 100644 --- a/apps/spreadsheeteditor/main/app/view/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/view/RightMenu.js @@ -277,7 +277,7 @@ define([ Common.localStorage.setItem("sse-hide-right-settings", 1); } - this.fireEvent('rightmenuclick', [this, btn.options.asctype, this.minimizedMode]); + this.fireEvent('rightmenuclick', [this, btn.options.asctype, this.minimizedMode, e]); }, SetActivePane: function(type, open) {