From 3df19a665989934b50647904513b8bb9b48b93fb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 6 Dec 2024 19:25:53 +0300 Subject: [PATCH] Fix Bug 71888 --- apps/common/main/lib/view/ReviewChanges.js | 7 +++- .../main/app/controller/Toolbar.js | 30 ++++++++++------- .../main/app/controller/ViewTab.js | 3 ++ apps/pdfeditor/main/app/controller/Toolbar.js | 30 ++++++++++------- apps/pdfeditor/main/app/controller/ViewTab.js | 3 ++ .../main/app/controller/Toolbar.js | 33 +++++++++++-------- .../main/app/view/ViewTab.js | 3 ++ .../main/app/controller/Toolbar.js | 31 ++++++++++------- .../main/app/view/ViewTab.js | 3 ++ .../main/app/controller/Toolbar.js | 31 ++++++++++------- apps/visioeditor/main/app/view/ViewTab.js | 3 ++ 11 files changed, 118 insertions(+), 59 deletions(-) diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index c8769ce2fb..bd646f5b30 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -779,7 +779,12 @@ define([ if ((!me.btnMailRecepients || !Common.UI.LayoutManager.isElementVisible('toolbar-collaboration-mailmerge')) && separator_last) me.$el.find(separator_last).hide(); - Common.NotificationCenter.trigger('tab:visible', 'review', (config.isEdit || config.canViewReview || me.canComments) && Common.UI.LayoutManager.isElementVisible('toolbar-collaboration')); + var visible = (config.isEdit || config.canViewReview || me.canComments) && Common.UI.LayoutManager.isElementVisible('toolbar-collaboration'); + Common.NotificationCenter.trigger('tab:visible', 'review', visible); + if (Common.Utils.InternalSettings.get('toolbar-active-tab') && visible) { // collaboration tab has hign priority in view mode + Common.Utils.InternalSettings.set('toolbar-active-tab', null); + Common.NotificationCenter.trigger('tab:set-active', 'review'); + } setEvents.call(me); }); }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 7af25be297..e169092a13 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -236,6 +236,10 @@ define([ Common.NotificationCenter.on('toolbar:collapse', _.bind(function () { this.toolbar.collapse(); }, this)); + Common.NotificationCenter.on('tab:set-active', _.bind(function(action){ + this.toolbar.setTab(action); + this.onChangeCompactView(null, false, true); + }, this)); }, onLaunch: function() { @@ -507,12 +511,14 @@ define([ Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this)); }, - onChangeCompactView: function(view, compact) { + onChangeCompactView: function(view, compact, suppressSave) { this.toolbar.setFolded(compact); this.toolbar.fireEvent('view:compact', [this, compact]); compact && this.onTabCollapse(); - Common.localStorage.setBool('de-compact-toolbar', compact); + var editmode = this.mode.isEdit || this.mode.isRestrictedEdit && this.mode.canFillForms && this.mode.isFormCreator; + !suppressSave && Common.localStorage.setBool(editmode ? "de-compact-toolbar" : "de-view-compact-toolbar", compact); + Common.NotificationCenter.trigger('layout:changed', 'toolbar'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, @@ -3547,16 +3553,16 @@ define([ var me = this, application = this.getApplication(); - var compactview = !(config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator); - if ( config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator) { - if ( Common.localStorage.itemExists("de-compact-toolbar") ) { - compactview = Common.localStorage.getBool("de-compact-toolbar"); - } else - if ( config.customization && config.customization.compactToolbar ) - compactview = true; + var editmode = config.isEdit || config.isRestrictedEdit && config.canFillForms && config.isFormCreator, + compactview = !editmode; + if ( Common.localStorage.itemExists(editmode ? "de-compact-toolbar" : "de-view-compact-toolbar") ) { + compactview = Common.localStorage.getBool(editmode ? "de-compact-toolbar" : "de-view-compact-toolbar"); + } else if (config.customization) { + compactview = editmode ? !!config.customization.compactToolbar : config.customization.compactToolbar!==false; } + Common.Utils.InternalSettings.set('toolbar-active-tab', !editmode && !compactview); - me.toolbar.render(_.extend({isCompactView: compactview}, config)); + me.toolbar.render(_.extend({isCompactView: editmode ? compactview : true}, config)); var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, dataHintTitle: 'U', layoutname: 'toolbar-collaboration'}; var $panel = me.application.getController('Common.Controllers.ReviewChanges').createToolbarPanel(); @@ -3665,8 +3671,10 @@ define([ viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); $panel = viewtab.createToolbarPanel(); if ($panel) { + var visible = Common.UI.LayoutManager.isElementVisible('toolbar-view'); me.toolbar.addTab(tab, $panel, 8); - me.toolbar.setVisible('view', Common.UI.LayoutManager.isElementVisible('toolbar-view')); + me.toolbar.setVisible('view', visible); + !editmode && !compactview && visible && Common.Utils.InternalSettings.set('toolbar-active-tab', 'view'); // need to activate later } config.isEdit && Array.prototype.push.apply(me.toolbar.lockControls, viewtab.getView('ViewTab').getButtons()); }, diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 7fe0f8128e..debfaeebca 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -252,6 +252,9 @@ define([ }, 0); } } + + if (Common.Utils.InternalSettings.get('toolbar-active-tab')==='view') + Common.NotificationCenter.trigger('tab:set-active', 'view'); }); } }, diff --git a/apps/pdfeditor/main/app/controller/Toolbar.js b/apps/pdfeditor/main/app/controller/Toolbar.js index 9206b56731..efc3d74801 100644 --- a/apps/pdfeditor/main/app/controller/Toolbar.js +++ b/apps/pdfeditor/main/app/controller/Toolbar.js @@ -158,6 +158,10 @@ define([ this.toolbar.collapse(); }, this)); Common.NotificationCenter.on('comments:tryshowcomments', _.bind(this.turnOnShowComments, this)); + Common.NotificationCenter.on('tab:set-active', _.bind(function(action){ + this.toolbar.setTab(action); + this.onChangeCompactView(null, false, true); + }, this)); }, onLaunch: function() { @@ -427,13 +431,15 @@ define([ this.attachRestrictedEditApiEvents(); }, - onChangeCompactView: function(view, compact) { + onChangeCompactView: function(view, compact, suppressSave) { this.toolbar.setFolded(compact); this.toolbar.fireEvent('view:compact', [this, compact]); compact && this.onTabCollapse(); - Common.localStorage.setBool('pdfe-compact-toolbar', compact); + var editmode = this.mode.isEdit || this.mode.isRestrictedEdit; + !suppressSave && Common.localStorage.setBool(editmode ? "pdfe-compact-toolbar" : "pdfe-view-compact-toolbar", compact); + Common.NotificationCenter.trigger('layout:changed', 'toolbar'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, @@ -1253,16 +1259,16 @@ define([ onAppShowed: function (config) { var me = this; - var compactview = !(config.isEdit || config.isRestrictedEdit); - if ( config.isEdit || config.isRestrictedEdit) { - if ( Common.localStorage.itemExists("pdfe-compact-toolbar") ) { - compactview = Common.localStorage.getBool("pdfe-compact-toolbar"); - } else - if ( config.customization && config.customization.compactToolbar ) - compactview = true; + var editmode = config.isEdit || config.isRestrictedEdit, + compactview = !editmode; + if ( Common.localStorage.itemExists(editmode ? "pdfe-compact-toolbar" : "pdfe-view-compact-toolbar") ) { + compactview = Common.localStorage.getBool(editmode ? "pdfe-compact-toolbar" : "pdfe-view-compact-toolbar"); + } else if (config.customization) { + compactview = editmode ? !!config.customization.compactToolbar : config.customization.compactToolbar!==false; } + Common.Utils.InternalSettings.set('toolbar-active-tab', !editmode && !compactview); - me.toolbar.render(_.extend({isCompactView: compactview}, config)); + me.toolbar.render(_.extend({isCompactView: editmode ? compactview : true}, config)); if ( config.isEdit || config.isRestrictedEdit) { me.toolbar.setMode(config); @@ -1300,8 +1306,10 @@ define([ viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); var $panel = viewtab.createToolbarPanel(); if ($panel) { + var visible = Common.UI.LayoutManager.isElementVisible('toolbar-view'); me.toolbar.addTab(tab, $panel, 8); - me.toolbar.setVisible('view', Common.UI.LayoutManager.isElementVisible('toolbar-view')); + me.toolbar.setVisible('view', visible); + !editmode && !compactview && visible && Common.Utils.InternalSettings.set('toolbar-active-tab', 'view'); // need to activate later } if (config.isPDFEdit) { diff --git a/apps/pdfeditor/main/app/controller/ViewTab.js b/apps/pdfeditor/main/app/controller/ViewTab.js index ee37a8f8a4..90f2164640 100644 --- a/apps/pdfeditor/main/app/controller/ViewTab.js +++ b/apps/pdfeditor/main/app/controller/ViewTab.js @@ -243,6 +243,9 @@ define([ }, 0); } } + + if (Common.Utils.InternalSettings.get('toolbar-active-tab')==='view') + Common.NotificationCenter.trigger('tab:set-active', 'view'); }); } }, diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 6cb5d7aa90..4e2e8f6bf0 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -202,7 +202,11 @@ define([ Common.NotificationCenter.on('toolbar:collapse', _.bind(function () { this.toolbar.collapse(); }, this)); - + Common.NotificationCenter.on('tab:set-active', _.bind(function(action){ + this.toolbar.setTab(action); + this.onChangeCompactView(null, false, true); + }, this)); + var me = this; var checkInsertAutoshape = function(e) { @@ -475,13 +479,14 @@ define([ Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this)); }, - onChangeCompactView: function(view, compact) { + onChangeCompactView: function(view, compact, suppressSave) { this.toolbar.setFolded(compact); this.toolbar.fireEvent('view:compact', [this.toolbar, compact]); compact && this.onTabCollapse(); - Common.localStorage.setBool('pe-compact-toolbar', compact); + !suppressSave && Common.localStorage.setBool(this.mode.isEdit ? "pe-compact-toolbar" : "pe-view-compact-toolbar", compact); + Common.NotificationCenter.trigger('layout:changed', 'toolbar'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, @@ -2718,16 +2723,16 @@ define([ onAppShowed: function (config) { var me = this; - var compactview = !config.isEdit; - if ( config.isEdit ) { - if ( Common.localStorage.itemExists("pe-compact-toolbar") ) { - compactview = Common.localStorage.getBool("pe-compact-toolbar"); - } else - if ( config.customization && config.customization.compactToolbar ) - compactview = true; - + var editmode = config.isEdit, + compactview = !editmode; + if ( Common.localStorage.itemExists(editmode ? "pe-compact-toolbar" : "pe-view-compact-toolbar") ) { + compactview = Common.localStorage.getBool(editmode ? "pe-compact-toolbar" : "pe-view-compact-toolbar"); + } else if (config.customization) { + compactview = editmode ? !!config.customization.compactToolbar : config.customization.compactToolbar!==false; } - me.toolbar.render(_.extend({compactview: compactview}, config)); + Common.Utils.InternalSettings.set('toolbar-active-tab', !editmode && !compactview); + + me.toolbar.render(_.extend({compactview: editmode ? compactview : true}, config)); var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, layoutname: 'toolbar-collaboration', dataHintTitle: 'U'}; var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel(); @@ -2790,8 +2795,10 @@ define([ viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); $panel = viewtab.createToolbarPanel(); if ($panel) { + var visible = Common.UI.LayoutManager.isElementVisible('toolbar-view'); me.toolbar.addTab(tab, $panel, 7); - me.toolbar.setVisible('view', Common.UI.LayoutManager.isElementVisible('toolbar-view')); + me.toolbar.setVisible('view', visible); + !editmode && !compactview && visible && Common.Utils.InternalSettings.set('toolbar-active-tab', 'view'); // need to activate later } }, diff --git a/apps/presentationeditor/main/app/view/ViewTab.js b/apps/presentationeditor/main/app/view/ViewTab.js index 32dbed2968..7a81c536b9 100644 --- a/apps/presentationeditor/main/app/view/ViewTab.js +++ b/apps/presentationeditor/main/app/view/ViewTab.js @@ -621,6 +621,9 @@ define([ me.chRightMenu.setValue(!Common.localStorage.getBool("pe-hidden-rightmenu", value)); me.setEvents(); + + if (Common.Utils.InternalSettings.get('toolbar-active-tab')==='view') + Common.NotificationCenter.trigger('tab:set-active', 'view'); }); }, diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index e1d8217091..3da65e93f0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -152,6 +152,10 @@ define([ this.toolbar.collapse(); }, this)); Common.NotificationCenter.on('oleedit:close', _.bind(this.onOleEditClose, this)); + Common.NotificationCenter.on('tab:set-active', _.bind(function(action){ + this.toolbar.setTab(action); + this.onChangeViewMode(null, false, true); + }, this)); this.editMode = true; this._isAddingShape = false; @@ -2201,12 +2205,13 @@ define([ Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this)); }, - onChangeViewMode: function(item, compact) { + onChangeViewMode: function(item, compact, suppressSave) { this.toolbar.setFolded(compact); this.toolbar.fireEvent('view:compact', [this, compact]); compact && this.onTabCollapse(); - Common.localStorage.setBool('sse-compact-toolbar', compact); + !suppressSave && Common.localStorage.setBool(this.mode.isEdit ? "sse-compact-toolbar" : "sse-view-compact-toolbar", compact); + Common.NotificationCenter.trigger('layout:changed', 'toolbar'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, @@ -4514,16 +4519,18 @@ define([ var me = this; me.appConfig = config; - var compactview = !config.isEdit; - if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { - if ( Common.localStorage.itemExists("sse-compact-toolbar") ) { - compactview = Common.localStorage.getBool("sse-compact-toolbar"); - } else - if ( config.customization && config.customization.compactToolbar ) - compactview = true; + var editmode = config.isEdit, + compactview = !editmode; + if (!config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle) { + if ( Common.localStorage.itemExists(editmode ? "sse-compact-toolbar" : "sse-view-compact-toolbar") ) { + compactview = Common.localStorage.getBool(editmode ? "sse-compact-toolbar" : "sse-view-compact-toolbar"); + } else if (config.customization) { + compactview = editmode ? !!config.customization.compactToolbar : config.customization.compactToolbar!==false; + } + Common.Utils.InternalSettings.set('toolbar-active-tab', !editmode && !compactview); } - me.toolbar.render(_.extend({isCompactView: compactview}, config)); + me.toolbar.render(_.extend({isCompactView: editmode ? compactview : true}, config)); if ( !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, layoutname: 'toolbar-collaboration', dataHintTitle: 'U'}; @@ -4621,8 +4628,10 @@ define([ viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); var $panel = viewtab.createToolbarPanel(); if ($panel) { + var visible = Common.UI.LayoutManager.isElementVisible('toolbar-view'); me.toolbar.addTab(tab, $panel, 8); - me.toolbar.setVisible('view', Common.UI.LayoutManager.isElementVisible('toolbar-view')); + me.toolbar.setVisible('view', visible); + !editmode && !compactview && visible && Common.Utils.InternalSettings.set('toolbar-active-tab', 'view'); // need to activate later } config.isEdit && Array.prototype.push.apply(me.toolbar.lockControls, viewtab.getView('ViewTab').getButtons()); } diff --git a/apps/spreadsheeteditor/main/app/view/ViewTab.js b/apps/spreadsheeteditor/main/app/view/ViewTab.js index a9b58c423c..2fe0f1ea84 100644 --- a/apps/spreadsheeteditor/main/app/view/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/view/ViewTab.js @@ -585,6 +585,9 @@ define([ me.chRightMenu.setValue(!Common.localStorage.getBool("sse-hidden-rightmenu", value)); setEvents.call(me); + + if (Common.Utils.InternalSettings.get('toolbar-active-tab')==='view') + Common.NotificationCenter.trigger('tab:set-active', 'view'); }); }, diff --git a/apps/visioeditor/main/app/controller/Toolbar.js b/apps/visioeditor/main/app/controller/Toolbar.js index 8237dc502a..fa3f818374 100644 --- a/apps/visioeditor/main/app/controller/Toolbar.js +++ b/apps/visioeditor/main/app/controller/Toolbar.js @@ -111,6 +111,10 @@ define([ Common.NotificationCenter.on('toolbar:collapse', _.bind(function () { this.toolbar.collapse(); }, this)); + Common.NotificationCenter.on('tab:set-active', _.bind(function(action){ + this.toolbar.setTab(action); + this.onChangeCompactView(null, false, true); + }, this)); }, onLaunch: function() { @@ -175,13 +179,14 @@ define([ } }, - onChangeCompactView: function(view, compact) { + onChangeCompactView: function(view, compact, suppressSave) { this.toolbar.setFolded(compact); this.toolbar.fireEvent('view:compact', [this, compact]); compact && this.onTabCollapse(); - Common.localStorage.setBool('ve-compact-toolbar', compact); + !suppressSave && Common.localStorage.setBool(this.mode.isEdit ? "ve-compact-toolbar" : "ve-view-compact-toolbar", compact); + Common.NotificationCenter.trigger('layout:changed', 'toolbar'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, @@ -284,16 +289,16 @@ define([ onAppShowed: function (config) { var me = this; - var compactview = !config.isEdit; - if ( config.isEdit ) { - if ( Common.localStorage.itemExists("ve-compact-toolbar") ) { - compactview = Common.localStorage.getBool("ve-compact-toolbar"); - } else - if ( config.customization && config.customization.compactToolbar ) - compactview = true; - + var editmode = config.isEdit, + compactview = !editmode; + if ( Common.localStorage.itemExists(editmode ? "ve-compact-toolbar" : "ve-view-compact-toolbar") ) { + compactview = Common.localStorage.getBool(editmode ? "ve-compact-toolbar" : "ve-view-compact-toolbar"); + } else if (config.customization) { + compactview = editmode ? !!config.customization.compactToolbar : config.customization.compactToolbar!==false; } - me.toolbar.render(_.extend({compactview: compactview}, config)); + Common.Utils.InternalSettings.set('toolbar-active-tab', !editmode && !compactview); + + me.toolbar.render(_.extend({compactview: editmode ? compactview : true}, config)); if ( config.isEdit) { me.toolbar.setMode(config); @@ -306,8 +311,10 @@ define([ viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); var $panel = viewtab.createToolbarPanel(); if ($panel) { + var visible = Common.UI.LayoutManager.isElementVisible('toolbar-view'); me.toolbar.addTab(tab, $panel, 8); - me.toolbar.setVisible('view', Common.UI.LayoutManager.isElementVisible('toolbar-view')); + me.toolbar.setVisible('view', visible); + !editmode && !compactview && visible && Common.Utils.InternalSettings.set('toolbar-active-tab', 'view'); // need to activate later } }, diff --git a/apps/visioeditor/main/app/view/ViewTab.js b/apps/visioeditor/main/app/view/ViewTab.js index fb6eb1765e..460f5e6d25 100644 --- a/apps/visioeditor/main/app/view/ViewTab.js +++ b/apps/visioeditor/main/app/view/ViewTab.js @@ -333,6 +333,9 @@ define([ me.chLeftMenu.setValue(!Common.localStorage.getBool("ve-hidden-leftmenu", value)); me.setEvents(); + + if (Common.Utils.InternalSettings.get('toolbar-active-tab')==='view') + Common.NotificationCenter.trigger('tab:set-active', 'view'); }); },