From e81967d1b4d3a4bc273dc829960922113032bd42 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 10 Nov 2020 23:33:06 +0300 Subject: [PATCH] Fix Bug 47191 --- apps/documenteditor/mobile/app/controller/Main.js | 4 ---- apps/documenteditor/mobile/app/controller/Settings.js | 5 +---- apps/documenteditor/mobile/app/controller/Toolbar.js | 11 +++++++---- apps/presentationeditor/mobile/app/controller/Main.js | 4 ---- .../mobile/app/controller/Settings.js | 5 +---- .../mobile/app/controller/Toolbar.js | 11 +++++++---- apps/spreadsheeteditor/mobile/app/controller/Main.js | 4 ---- .../mobile/app/controller/Settings.js | 5 +---- .../mobile/app/controller/Toolbar.js | 11 +++++++---- 9 files changed, 24 insertions(+), 36 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index d423fa118..4657f1289 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -886,10 +886,6 @@ define([ } }, - returnUserCount: function() { - return this._state.usersCount; - }, - onExternalMessage: function(msg) { if (msg && msg.msg) { msg.msg = (msg.msg).toString(); diff --git a/apps/documenteditor/mobile/app/controller/Settings.js b/apps/documenteditor/mobile/app/controller/Settings.js index d476fae33..e34275107 100644 --- a/apps/documenteditor/mobile/app/controller/Settings.js +++ b/apps/documenteditor/mobile/app/controller/Settings.js @@ -269,10 +269,7 @@ define([ if(_stateDisplayMode == "final" || _stateDisplayMode == "original") { $('#settings-document').addClass('disabled'); } - var _userCount = DE.getController('Main').returnUserCount(); - if (_userCount > 0) { - $('#settings-collaboration').show(); - } + DE.getController('Toolbar').getDisplayCollaboration() && $('#settings-collaboration').show(); } }, diff --git a/apps/documenteditor/mobile/app/controller/Toolbar.js b/apps/documenteditor/mobile/app/controller/Toolbar.js index da1b50097..44b967b7e 100644 --- a/apps/documenteditor/mobile/app/controller/Toolbar.js +++ b/apps/documenteditor/mobile/app/controller/Toolbar.js @@ -53,6 +53,7 @@ define([ // private var stateDisplayMode = false; var _users = []; + var _displayCollaboration = false; return { models: [], @@ -201,10 +202,8 @@ define([ if ((item.asc_getState()!==false) && !item.asc_getView()) length++; }); - if (length < 1 && this.mode && !this.mode.canViewComments && !this.mode.canReview && !this.mode.canViewReview) - $('#toolbar-collaboration').hide(); - else - $('#toolbar-collaboration').show(); + _displayCollaboration = (length >= 1 || !this.mode || this.mode.canViewComments || this.mode.canReview || this.mode.canViewReview); + _displayCollaboration ? $('#toolbar-collaboration').show() : $('#toolbar-collaboration').hide(); } }, @@ -228,6 +227,10 @@ define([ this.displayCollaboration(); }, + getDisplayCollaboration: function() { + return _displayCollaboration; + }, + dlgLeaveTitleText : 'You leave the application', dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', leaveButtonText : 'Leave this Page', diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index e41a58137..0206def08 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -1242,10 +1242,6 @@ define([ this._state.usersCount = length; }, - returnUserCount: function() { - return this._state.usersCount; - }, - onDocumentName: function(name) { // this.getApplication().getController('Viewport').getView('Common.Views.Header').setDocumentCaption(name); this.updateWindowTitle(true); diff --git a/apps/presentationeditor/mobile/app/controller/Settings.js b/apps/presentationeditor/mobile/app/controller/Settings.js index ee921a5bb..171bb0d26 100644 --- a/apps/presentationeditor/mobile/app/controller/Settings.js +++ b/apps/presentationeditor/mobile/app/controller/Settings.js @@ -166,10 +166,7 @@ define([ $('#settings-print').single('click', _.bind(me._onPrint, me)); $('#settings-collaboration').single('click', _.bind(me.onCollaboration, me)); - var _userCount = PE.getController('Main').returnUserCount(); - if (_userCount > 0) { - $('#settings-collaboration').show(); - } + PE.getController('Toolbar').getDisplayCollaboration() && $('#settings-collaboration').show(); Common.Utils.addScrollIfNeed('.page[data-page=settings-setup-view]', '.page[data-page=settings-setup-view] .page-content'); Common.Utils.addScrollIfNeed('.page[data-page=settings-download-view]', '.page[data-page=settings-download-view] .page-content'); diff --git a/apps/presentationeditor/mobile/app/controller/Toolbar.js b/apps/presentationeditor/mobile/app/controller/Toolbar.js index 2d1c9f527..7deeb4077 100644 --- a/apps/presentationeditor/mobile/app/controller/Toolbar.js +++ b/apps/presentationeditor/mobile/app/controller/Toolbar.js @@ -52,6 +52,7 @@ define([ PE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() { // private var _users = []; + var _displayCollaboration = false; return { models: [], @@ -210,10 +211,8 @@ define([ if ((item.asc_getState()!==false) && !item.asc_getView()) length++; }); - if (length < 1 && this.mode && !this.mode.canViewComments) - $('#toolbar-collaboration').hide(); - else - $('#toolbar-collaboration').show(); + _displayCollaboration = (length >= 1 || !this.mode || this.mode.canViewComments); + _displayCollaboration ? $('#toolbar-collaboration').show() : $('#toolbar-collaboration').hide(); } }, @@ -237,6 +236,10 @@ define([ this.displayCollaboration(); }, + getDisplayCollaboration: function() { + return _displayCollaboration; + }, + dlgLeaveTitleText : 'You leave the application', dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', leaveButtonText : 'Leave this Page', diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 880b2bd1f..690167f16 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -1449,10 +1449,6 @@ define([ this._state.usersCount = length; }, - returnUserCount: function() { - return this._state.usersCount; - }, - applySettings: function() { if (this.appOptions.isEdit && this.appOptions.canLicense && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) { var value = Common.localStorage.getItem("sse-settings-coauthmode"), diff --git a/apps/spreadsheeteditor/mobile/app/controller/Settings.js b/apps/spreadsheeteditor/mobile/app/controller/Settings.js index ab7d32a02..4012bd658 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Settings.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Settings.js @@ -261,10 +261,7 @@ define([ } else if ('#settings-macros-view' == pageId) { me.initPageMacrosSettings(); } else { - var _userCount = SSE.getController('Main').returnUserCount(); - if (_userCount > 0) { - $('#settings-collaboration').show(); - } + SSE.getController('Toolbar').getDisplayCollaboration() && $('#settings-collaboration').show(); } }, diff --git a/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js b/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js index 74a778ffb..de9bf41cf 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js @@ -56,6 +56,7 @@ define([ sheet: false }; var _users = []; + var _displayCollaboration = false; return { models: [], @@ -229,10 +230,8 @@ define([ if ((item.asc_getState()!==false) && !item.asc_getView()) length++; }); - if (length < 1 && this.mode && !this.mode.canViewComments) - $('#toolbar-collaboration').hide(); - else - $('#toolbar-collaboration').show(); + _displayCollaboration = (length >= 1 || !this.mode || this.mode.canViewComments); + _displayCollaboration ? $('#toolbar-collaboration').show() : $('#toolbar-collaboration').hide(); } }, @@ -256,6 +255,10 @@ define([ this.displayCollaboration(); }, + getDisplayCollaboration: function() { + return _displayCollaboration; + }, + dlgLeaveTitleText : 'You leave the application', dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', leaveButtonText : 'Leave this Page',