diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 00c4688e4..8d8dfbbec 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -554,6 +554,15 @@ }); }; + var _setSharingSettings = function(data) { + _sendCommand({ + command: 'setSharingSettings', + data: { + data: data + } + }); + }; + var _processMouse = function(evt) { var r = iframe.getBoundingClientRect(); var data = { @@ -595,7 +604,8 @@ detachMouseEvents : _detachMouseEvents, destroyEditor : _destroyEditor, setUsers : _setUsers, - showSharingSettings : _showSharingSettings + showSharingSettings : _showSharingSettings, + setSharingSettings : _setSharingSettings } }; diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index 2d2a9e169..373c41e58 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -106,6 +106,10 @@ if (Common === undefined) { 'showSharingSettings': function(data) { $me.trigger('showsharingsettings', data); + }, + + 'setSharingSettings': function(data) { + $me.trigger('setsharingsettings', data); } }; diff --git a/apps/common/main/lib/view/DocumentAccessDialog.js b/apps/common/main/lib/view/DocumentAccessDialog.js index 2d6c0fcfd..f19aefc89 100644 --- a/apps/common/main/lib/view/DocumentAccessDialog.js +++ b/apps/common/main/lib/view/DocumentAccessDialog.js @@ -122,7 +122,6 @@ define([ if (msg && msg.Referer == "onlyoffice") { if (msg.needUpdate) { this.trigger('accessrights', this, msg.sharingSettings); - Common.NotificationCenter.trigger('mentions:clearusers', this); } Common.NotificationCenter.trigger('window:close', this); } diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 45dafae27..2cae0016c 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -989,6 +989,7 @@ 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; }, @@ -1000,9 +1001,7 @@ define([ settingsurl: this.sharingSettingsUrl }); me._docAccessDlg.on('accessrights', function(obj, rights){ - me.doc.info.sharingSettings = rights; - me._ShowHideInfoItem('rights', me.doc.info.sharingSettings!==undefined && me.doc.info.sharingSettings!==null && me.doc.info.sharingSettings.length>0); - me.cntRights.html(me.templateRights({users: me.doc.info.sharingSettings})); + me.updateSharingSettings(rights); }).on('close', function(obj){ me._docAccessDlg = undefined; }); @@ -1010,6 +1009,17 @@ define([ me._docAccessDlg.show(); }, + setSharingSettings: function(data) { + data && data.data && this.updateSharingSettings(data.data); + }, + + 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() { this._readonlyRights = true; if (!this.rendered) diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index cc0bada8e..cec2bd672 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -802,6 +802,7 @@ 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; }, @@ -813,9 +814,7 @@ define([ settingsurl: this.sharingSettingsUrl }); me._docAccessDlg.on('accessrights', function(obj, rights){ - me.doc.info.sharingSettings = rights; - me._ShowHideInfoItem('rights', me.doc.info.sharingSettings!==undefined && me.doc.info.sharingSettings!==null && me.doc.info.sharingSettings.length>0); - me.cntRights.html(me.templateRights({users: me.doc.info.sharingSettings})); + me.updateSharingSettings(rights); }).on('close', function(obj){ me._docAccessDlg = undefined; }); @@ -823,6 +822,17 @@ define([ me._docAccessDlg.show(); }, + setSharingSettings: function(data) { + data && data.data && this.updateSharingSettings(data.data); + }, + + 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() { this._readonlyRights = true; if (!this.rendered) diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 03a50af6e..fe226c362 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1256,6 +1256,7 @@ 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; }, @@ -1267,9 +1268,7 @@ define([ settingsurl: this.sharingSettingsUrl }); me._docAccessDlg.on('accessrights', function(obj, rights){ - me.doc.info.sharingSettings = rights; - me._ShowHideInfoItem('rights', me.doc.info.sharingSettings!==undefined && me.doc.info.sharingSettings!==null && me.doc.info.sharingSettings.length>0); - me.cntRights.html(me.templateRights({users: me.doc.info.sharingSettings})); + me.updateSharingSettings(rights); }).on('close', function(obj){ me._docAccessDlg = undefined; }); @@ -1277,6 +1276,17 @@ define([ me._docAccessDlg.show(); }, + setSharingSettings: function(data) { + data && data.data && this.updateSharingSettings(data.data); + }, + + 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() { this._readonlyRights = true; if (!this.rendered)