Add setSharingSettings api method: update sharing settings when add mention for users

This commit is contained in:
Julia Radzhabova 2019-07-11 18:00:11 +03:00
parent 3f985b6622
commit 04b3651fd0
6 changed files with 54 additions and 11 deletions

View file

@ -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
}
};

View file

@ -106,6 +106,10 @@ if (Common === undefined) {
'showSharingSettings': function(data) {
$me.trigger('showsharingsettings', data);
},
'setSharingSettings': function(data) {
$me.trigger('setsharingsettings', data);
}
};

View file

@ -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);
}

View file

@ -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)

View file

@ -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)

View file

@ -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)