diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index e291dc5c0..713d32d30 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -101,6 +101,8 @@ define([ Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this)); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this)); + Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this)); this.userCollection.on('reset', _.bind(this.onUpdateUsers, this)); this.userCollection.on('add', _.bind(this.onUpdateUsers, this)); @@ -112,6 +114,7 @@ define([ this.currentUserId = data.config.user.id; this.sdkViewName = data['sdkviewname'] || this.sdkViewName; } + return this; }, setApi: function (api) { if (api) { @@ -130,9 +133,16 @@ define([ this.popoverChanges = new Common.Collections.ReviewChanges(); this.view = this.createView('Common.Views.ReviewChanges', { mode: mode }); + !!this.appConfig.sharingSettingsUrl && this.appConfig.sharingSettingsUrl.length && Common.Gateway.on('showsharingsettings', _.bind(this.changeAccessRights, this)); + !!this.appConfig.sharingSettingsUrl && this.appConfig.sharingSettingsUrl.length && Common.Gateway.on('setsharingsettings', _.bind(this.setSharingSettings, this)); + return this; }, + loadDocument: function(data) { + this.document = data.doc; + }, + SetDisabled: function(state) { if (this.dlgChanges) this.dlgChanges.close(); @@ -724,9 +734,34 @@ define([ }, onLostEditRights: function() { + this._readonlyRights = true; this.view && this.view.onLostEditRights(); }, + changeAccessRights: function(btn,event,opts) { + if (this._docAccessDlg || this._readonlyRights) return; + + var me = this; + me._docAccessDlg = new Common.Views.DocumentAccessDialog({ + settingsurl: this.appConfig.sharingSettingsUrl + }); + me._docAccessDlg.on('accessrights', function(obj, rights){ + me.setSharingSettings({sharingSettings: rights}); + }).on('close', function(obj){ + me._docAccessDlg = undefined; + }); + + me._docAccessDlg.show(); + }, + + setSharingSettings: function(data) { + if (data) { + this.document.info.sharingSettings = data.sharingSettings; + Common.NotificationCenter.trigger('collaboration:sharingupdate', data.sharingSettings); + Common.NotificationCenter.trigger('mentions:clearusers', this); + } + }, + onCoAuthoringDisconnect: function() { this.SetDisabled(true); }, diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 0e2a7619d..6f3333034 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -190,7 +190,7 @@ define([ function onUsersClick(e) { if ( !$btnUsers.menu ) { $panelUsers.removeClass('open'); - this.fireEvent('click:users', this); + Common.NotificationCenter.trigger('collaboration:sharing'); } else { var usertip = $btnUsers.data('bs.tooltip'); if ( usertip ) { @@ -245,7 +245,7 @@ define([ var $labelChangeRights = $panelUsers.find('#tlb-change-rights'); $labelChangeRights.on('click', function(e) { $panelUsers.removeClass('open'); - me.fireEvent('click:users', me); + Common.NotificationCenter.trigger('collaboration:sharing'); }); $labelChangeRights[(!mode.isOffline && !mode.isReviewOnly && mode.sharingSettingsUrl && mode.sharingSettingsUrl.length)?'show':'hide'](); diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index fd86037ef..d8d17f7f6 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -62,7 +62,6 @@ define([ 'hide': _.bind(this.onHideChat, this) }, 'Common.Views.Header': { - 'click:users': _.bind(this.clickStatusbarUsers, this), 'file:settings': _.bind(this.clickToolbarSettings,this), 'history:show': function () { if ( !this.leftMenu.panelHistory.isVisible() ) @@ -532,10 +531,6 @@ define([ }, /** coauthoring begin **/ - clickStatusbarUsers: function() { - this.leftMenu.menuFile.panels['rights'].changeAccessRights(); - }, - onHideChat: function() { $(this.leftMenu.btnChat.el).blur(); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 26e80101a..c17bb472a 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1260,7 +1260,7 @@ define([ var me = this, application = this.getApplication(), reviewController = application.getController('Common.Controllers.ReviewChanges'); - reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); + reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api).loadDocument({doc:me.document}); if (this.appOptions.isEdit || this.appOptions.isRestrictedEdit) { // set api events for toolbar in the Restricted Editing mode var toolbarController = application.getController('Toolbar'); @@ -2074,6 +2074,7 @@ define([ var filemenu = this.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file'); filemenu.loadDocument({doc:this.document}); filemenu.panels && filemenu.panels['info'] && filemenu.panels['info'].updateInfo(this.document); + this.getApplication().getController('Common.Controllers.ReviewChanges').loadDocument({doc:this.document}); Common.Gateway.metaChange(meta); }, diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 7bb76a0ab..94fe0584d 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -1192,7 +1192,7 @@ define([ this.updateInfo(this.doc); - Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this)); + Common.NotificationCenter.on('collaboration:sharingupdate', this.updateSharingSettings.bind(this)); Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this)); this.$el = $(node).html($markup); @@ -1245,36 +1245,16 @@ define([ setMode: function(mode) { this.sharingSettingsUrl = mode.sharingSettingsUrl; - !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && Common.Gateway.on('showsharingsettings', _.bind(this.changeAccessRights, this)); - !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && Common.Gateway.on('setsharingsettings', _.bind(this.setSharingSettings, this)); return this; }, changeAccessRights: function(btn,event,opts) { - if (this._docAccessDlg || this._readonlyRights) return; - - var me = this; - me._docAccessDlg = new Common.Views.DocumentAccessDialog({ - settingsurl: this.sharingSettingsUrl - }); - me._docAccessDlg.on('accessrights', function(obj, rights){ - me.updateSharingSettings(rights); - }).on('close', function(obj){ - me._docAccessDlg = undefined; - }); - - me._docAccessDlg.show(); - }, - - setSharingSettings: function(data) { - data && this.updateSharingSettings(data.sharingSettings); + Common.NotificationCenter.trigger('collaboration:sharing'); }, updateSharingSettings: function(rights) { - this.doc.info.sharingSettings = rights; this._ShowHideInfoItem('rights', this.doc.info.sharingSettings!==undefined && this.doc.info.sharingSettings!==null && this.doc.info.sharingSettings.length>0); this.cntRights.html(this.templateRights({users: this.doc.info.sharingSettings})); - Common.NotificationCenter.trigger('mentions:clearusers', this); }, onLostEditRights: function() { diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index be73ae8fa..0efddeeb9 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -62,8 +62,7 @@ define([ 'hide': _.bind(this.onHideChat, this) }, 'Common.Views.Header': { - 'file:settings': _.bind(this.clickToolbarSettings,this), - 'click:users': _.bind(this.clickStatusbarUsers, this) + 'file:settings': _.bind(this.clickToolbarSettings,this) }, 'Common.Views.Plugins': { 'plugin:open': _.bind(this.onPluginOpen, this), @@ -368,10 +367,6 @@ define([ }, /** coauthoring begin **/ - clickStatusbarUsers: function() { - this.leftMenu.menuFile.panels['rights'].changeAccessRights(); - }, - onHideChat: function() { $(this.leftMenu.btnChat.el).blur(); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index ec6d0c662..4f255de6c 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -970,22 +970,21 @@ define([ commentsController.setConfig({config: this.editorConfig, sdkviewname: '#id_main_parent'}, this.api); } /** coauthoring end **/ + var me = this, + application = this.getApplication(), + reviewController = application.getController('Common.Controllers.ReviewChanges'); + reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api).loadDocument({doc:me.document}); + if (this.appOptions.isEdit) { - var me = this, - application = this.getApplication(), - toolbarController = application.getController('Toolbar'), + var toolbarController = application.getController('Toolbar'), rightmenuController = application.getController('RightMenu'), - fontsControllers = application.getController('Common.Controllers.Fonts'), - reviewController = application.getController('Common.Controllers.ReviewChanges'); + fontsControllers = application.getController('Common.Controllers.Fonts'); // me.getStore('SlideLayouts'); fontsControllers && fontsControllers.setApi(me.api); toolbarController && toolbarController.setApi(me.api); - rightmenuController && rightmenuController.setApi(me.api); - reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); - if (me.appOptions.canProtect) application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); @@ -1766,6 +1765,7 @@ define([ var filemenu = this.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file'); filemenu.loadDocument({doc:this.document}); filemenu.panels && filemenu.panels['info'] && filemenu.panels['info'].updateInfo(this.document); + this.getApplication().getController('Common.Controllers.ReviewChanges').loadDocument({doc:this.document}); Common.Gateway.metaChange(meta); }, diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index b3fa8c872..c5276c27f 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -1010,7 +1010,7 @@ define([ }); } - Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this)); + Common.NotificationCenter.on('collaboration:sharingupdate', this.updateSharingSettings.bind(this)); Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this)); return this; @@ -1051,36 +1051,16 @@ define([ setMode: function(mode) { this.sharingSettingsUrl = mode.sharingSettingsUrl; - !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && Common.Gateway.on('showsharingsettings', _.bind(this.changeAccessRights, this)); - !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && Common.Gateway.on('setsharingsettings', _.bind(this.setSharingSettings, this)); return this; }, changeAccessRights: function(btn,event,opts) { - if (this._docAccessDlg || this._readonlyRights) return; - - var me = this; - me._docAccessDlg = new Common.Views.DocumentAccessDialog({ - settingsurl: this.sharingSettingsUrl - }); - me._docAccessDlg.on('accessrights', function(obj, rights){ - me.updateSharingSettings(rights); - }).on('close', function(obj){ - me._docAccessDlg = undefined; - }); - - me._docAccessDlg.show(); - }, - - setSharingSettings: function(data) { - data && this.updateSharingSettings(data.sharingSettings); + Common.NotificationCenter.trigger('collaboration:sharing'); }, updateSharingSettings: function(rights) { - this.doc.info.sharingSettings = rights; this._ShowHideInfoItem('rights', this.doc.info.sharingSettings!==undefined && this.doc.info.sharingSettings!==null && this.doc.info.sharingSettings.length>0); this.cntRights.html(this.templateRights({users: this.doc.info.sharingSettings})); - Common.NotificationCenter.trigger('mentions:clearusers', this); }, onLostEditRights: function() { diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 340faedd8..4b1221e53 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -56,8 +56,7 @@ define([ 'hide': _.bind(this.onHidePlugins, this) }, 'Common.Views.Header': { - 'file:settings': _.bind(this.clickToolbarSettings,this), - 'click:users': _.bind(this.clickStatusbarUsers, this) + 'file:settings': _.bind(this.clickToolbarSettings,this) }, 'LeftMenu': { 'file:show': _.bind(this.fileShowHide, this, true), @@ -432,10 +431,6 @@ define([ }, /** coauthoring begin **/ - clickStatusbarUsers: function() { - this.leftMenu.menuFile.panels['rights'].changeAccessRights(); - }, - onHideChat: function() { $(this.leftMenu.btnChat.el).blur(); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a3f7d91ed..389584204 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1044,24 +1044,22 @@ define([ this.api); } /** coauthoring end **/ + var me = this, + application = this.getApplication(), + reviewController = application.getController('Common.Controllers.ReviewChanges'); + reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api).loadDocument({doc:me.appOptions.spreadsheet}); if (this.appOptions.isEdit) { - var me = this, - application = this.getApplication(), - toolbarController = application.getController('Toolbar'), + var toolbarController = application.getController('Toolbar'), statusbarController = application.getController('Statusbar'), rightmenuController = application.getController('RightMenu'), - fontsControllers = application.getController('Common.Controllers.Fonts'), - reviewController = application.getController('Common.Controllers.ReviewChanges'); + fontsControllers = application.getController('Common.Controllers.Fonts'); fontsControllers && fontsControllers.setApi(me.api); toolbarController && toolbarController.setApi(me.api); // statusbarController && statusbarController.setApi(me.api); - rightmenuController && rightmenuController.setApi(me.api); - reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); - if (me.appOptions.canProtect) application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); @@ -2046,6 +2044,7 @@ define([ this.appOptions.spreadsheet.title = meta.title; filemenu.loadDocument({doc:this.appOptions.spreadsheet}); filemenu.panels && filemenu.panels['info'] && filemenu.panels['info'].updateInfo(this.appOptions.spreadsheet); + app.getController('Common.Controllers.ReviewChanges').loadDocument({doc:this.appOptions.spreadsheet}); Common.Gateway.metaChange(meta); }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 4ff2ef89e..268dbfb15 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1461,7 +1461,7 @@ define([ }); } - Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this)); + Common.NotificationCenter.on('collaboration:sharingupdate', this.updateSharingSettings.bind(this)); Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this)); return this; @@ -1501,36 +1501,16 @@ define([ setMode: function(mode) { this.sharingSettingsUrl = mode.sharingSettingsUrl; - !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && Common.Gateway.on('showsharingsettings', _.bind(this.changeAccessRights, this)); - !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && Common.Gateway.on('setsharingsettings', _.bind(this.setSharingSettings, this)); return this; }, changeAccessRights: function(btn,event,opts) { - if (this._docAccessDlg || this._readonlyRights) return; - - var me = this; - me._docAccessDlg = new Common.Views.DocumentAccessDialog({ - settingsurl: this.sharingSettingsUrl - }); - me._docAccessDlg.on('accessrights', function(obj, rights){ - me.updateSharingSettings(rights); - }).on('close', function(obj){ - me._docAccessDlg = undefined; - }); - - me._docAccessDlg.show(); - }, - - setSharingSettings: function(data) { - data && this.updateSharingSettings(data.sharingSettings); + Common.NotificationCenter.trigger('collaboration:sharing'); }, updateSharingSettings: function(rights) { - this.doc.info.sharingSettings = rights; this._ShowHideInfoItem('rights', this.doc.info.sharingSettings!==undefined && this.doc.info.sharingSettings!==null && this.doc.info.sharingSettings.length>0); this.cntRights.html(this.templateRights({users: this.doc.info.sharingSettings})); - Common.NotificationCenter.trigger('mentions:clearusers', this); }, onLostEditRights: function() {