From 5a009e4c90589a797c394c8feaaf0cd6331fcc1e Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 7 Jun 2019 10:29:43 +0300 Subject: [PATCH] [DE mobile] [PE mobile] [SSE mobile] Hide Collaboration when no edit users --- .../mobile/app/controller/Main.js | 8 ++++++-- .../mobile/app/controller/Settings.js | 4 ++++ .../mobile/app/controller/Toolbar.js | 17 +++++++++++++++++ .../mobile/app/template/Settings.template | 2 +- .../mobile/app/template/Toolbar.template | 2 +- .../mobile/app/controller/Main.js | 8 ++++++-- .../mobile/app/controller/Settings.js | 5 +++++ .../mobile/app/controller/Toolbar.js | 17 +++++++++++++++++ .../mobile/app/template/Settings.template | 2 +- .../mobile/app/template/Toolbar.template | 2 +- .../mobile/app/controller/Main.js | 8 ++++++-- .../mobile/app/controller/Settings.js | 5 +++++ .../mobile/app/controller/Toolbar.js | 17 +++++++++++++++++ .../mobile/app/template/Settings.template | 2 +- .../mobile/app/template/Toolbar.template | 2 +- 15 files changed, 89 insertions(+), 12 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 8e7d4837d8..deed7d3009 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -761,6 +761,8 @@ define([ if (me.api) { me.api.asc_registerCallback('asc_onSendThemeColors', _.bind(me.onSendThemeColors, me)); me.api.asc_registerCallback('asc_onDownloadUrl', _.bind(me.onDownloadUrl, me)); + me.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); + me.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); } }, @@ -778,8 +780,6 @@ define([ /** coauthoring begin **/ me.api.asc_registerCallback('asc_onCollaborativeChanges', _.bind(me.onCollaborativeChanges, me)); me.api.asc_registerCallback('asc_OnTryUndoInFastCollaborative',_.bind(me.onTryUndoInFastCollaborative, me)); - me.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); - me.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(me.onAuthParticipantsChanged, me)); /** coauthoring end **/ if (me.stackLongActions.exist({id: ApplyEditRights, type: Asc.c_oAscAsyncActionType['BlockInteraction']})) { @@ -795,6 +795,10 @@ 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 bf61922912..be2f7dcc96 100644 --- a/apps/documenteditor/mobile/app/controller/Settings.js +++ b/apps/documenteditor/mobile/app/controller/Settings.js @@ -253,6 +253,10 @@ define([ if(_stateDisplayMode == "Final" || _stateDisplayMode == "Original") { $('#settings-document').addClass('disabled'); } + var _userCount = DE.getController('Main').returnUserCount(); + if (_userCount > 0) { + $('#settings-collaboration').show(); + } } }, diff --git a/apps/documenteditor/mobile/app/controller/Toolbar.js b/apps/documenteditor/mobile/app/controller/Toolbar.js index aaaaae5538..1c32ee6c4e 100644 --- a/apps/documenteditor/mobile/app/controller/Toolbar.js +++ b/apps/documenteditor/mobile/app/controller/Toolbar.js @@ -81,6 +81,8 @@ define([ this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo')); this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this)); + this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.displayCollaboration, this)) + this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.displayCollaboration, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); }, @@ -192,6 +194,21 @@ define([ DE.getController('Settings').hideModal(); }, + displayCollaboration: function(users) { + if(users !== undefined) { + var length = 0; + _.each(users, function (item) { + if (!item.asc_getView()) + length++; + }); + if (length > 0) { + $('#toolbar-collaboration').show(); + } else { + $('#toolbar-collaboration').hide(); + } + } + }, + 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/documenteditor/mobile/app/template/Settings.template b/apps/documenteditor/mobile/app/template/Settings.template index 6cda2f06c3..45a321b3dd 100644 --- a/apps/documenteditor/mobile/app/template/Settings.template +++ b/apps/documenteditor/mobile/app/template/Settings.template @@ -57,7 +57,7 @@ <% } %> <% if(phone) {%>
  • -
    +
  • -
    +
  • -
    +