Merge pull request #547 from ONLYOFFICE/fix/bugfix

Fix/bugfix
This commit is contained in:
Julia Radzhabova 2020-11-01 14:35:02 +03:00 committed by GitHub
commit 0ca0c83dd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 136 additions and 35 deletions

View file

@ -88,6 +88,7 @@ define([
this.api = api;
this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onChangeEditUsers, this));
this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onChangeEditUsers, this));
this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
this.api.asc_registerCallback('asc_onAddComment', _.bind(this.onApiAddComment, this));
this.api.asc_registerCallback('asc_onAddComments', _.bind(this.onApiAddComments, this));
this.api.asc_registerCallback('asc_onChangeCommentData', _.bind(this.onApiChangeCommentData, this));
@ -229,6 +230,13 @@ define([
me.initComments();
Common.Utils.addScrollIfNeed('.page[data-page=comments-view]', '.page[data-page=comments-view] .page-content');
} else {
var length = 0;
_.each(editUsers, function (item) {
if ((item.asc_getState()!==false) && !item.asc_getView())
length++;
});
(length<1) && $('#item-edit-users').hide();
if(editor === 'DE' && !this.appConfig.canReview && !canViewReview) {
$('#reviewing-settings').hide();
}
@ -241,6 +249,20 @@ define([
editUsers = users;
},
onUserConnection: function(change){
var changed = false;
for (var uid in editUsers) {
if (undefined !== uid) {
var user = editUsers[uid];
if (user && user.asc_getId() == change.asc_getId()) {
editUsers[uid] = change;
changed = true;
}
}
}
!changed && change && (editUsers[change.asc_getId()] = change);
},
getUsersInfo: function() {
var usersArray = [];
_.each(editUsers, function(item){
@ -250,7 +272,7 @@ define([
if (fio.length > 1) {
initials += fio[fio.length - 1].substring(0, 1).toUpperCase();
}
if(!item.asc_getView()) {
if((item.asc_getState()!==false) && !item.asc_getView()) {
var userAttr = {
color: item.asc_getColor(),
id: item.asc_getId(),

View file

@ -11,7 +11,7 @@
<div class="page-content">
<div class="list-block">
<ul>
<li>
<li id="item-edit-users">
<a id="list-edit-users" class="item-link" data-page="#edit-users-view">
<div class="item-content">
<div class="item-media">

View file

@ -91,12 +91,16 @@ DE.ApplicationController = new(function(){
permissions = $.extend(permissions, docConfig.permissions);
var _permissions = $.extend({}, docConfig.permissions),
docInfo = new Asc.asc_CDocInfo();
docInfo = new Asc.asc_CDocInfo(),
_user = new Asc.asc_CUserInfo();
_user.put_Id(config.user && config.user.id ? config.user.id : ('uid-' + Date.now()));
docInfo.put_Id(docConfig.key);
docInfo.put_Url(docConfig.url);
docInfo.put_Title(docConfig.title);
docInfo.put_Format(docConfig.fileType);
docInfo.put_VKey(docConfig.vkey);
docInfo.put_UserInfo(_user);
docInfo.put_Token(docConfig.token);
docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(config.encryptionKeys);

View file

@ -638,9 +638,9 @@ define([
$(document).on('contextmenu', _.bind(me.onContextMenu, me));
if (!me.appOptions.canReview) {
var canViewReview = me.appOptions.isEdit || me.api.asc_HaveRevisionsChanges(true);
DE.getController('Common.Controllers.Collaboration').setCanViewReview(canViewReview);
if (canViewReview) {
me.appOptions.canViewReview = me.appOptions.isEdit || me.api.asc_HaveRevisionsChanges(true);
DE.getController('Common.Controllers.Collaboration').setCanViewReview(me.appOptions.canViewReview);
if (me.appOptions.canViewReview) {
var viewReviewMode = Common.localStorage.getItem("de-view-review-mode");
if (viewReviewMode===null)
viewReviewMode = me.appOptions.customization && /^(original|final|markup)$/i.test(me.appOptions.customization.reviewDisplay) ? me.appOptions.customization.reviewDisplay.toLocaleLowerCase() : 'original';
@ -648,6 +648,7 @@ define([
DE.getController('Common.Controllers.Collaboration').turnDisplayMode(viewReviewMode);
}
}
DE.getController('Toolbar').displayCollaboration();
Common.Gateway.documentReady();

View file

@ -52,6 +52,7 @@ define([
DE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
var stateDisplayMode = false;
var _users = [];
return {
models: [],
@ -78,12 +79,14 @@ 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));
this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
},
setMode: function (mode) {
this.mode = mode;
this.getView('Toolbar').setMode(mode);
},
@ -191,19 +194,38 @@ define([
DE.getController('Settings').hideModal();
},
displayCollaboration: function(users) {
if(users !== undefined) {
displayCollaboration: function() {
if(_users !== undefined) {
var length = 0;
_.each(users, function (item) {
if (!item.asc_getView())
_.each(_users, function (item) {
if ((item.asc_getState()!==false) && !item.asc_getView())
length++;
});
if (length > 0) {
$('#toolbar-collaboration').show();
} else {
if (length < 1 && this.mode && !this.mode.canViewComments && !this.mode.canReview && !this.mode.canViewReview)
$('#toolbar-collaboration').hide();
else
$('#toolbar-collaboration').show();
}
},
onUsersChanged: function(users) {
_users = users;
this.displayCollaboration();
},
onUserConnection: function(change){
var changed = false;
for (var uid in _users) {
if (undefined !== uid) {
var user = _users[uid];
if (user && user.asc_getId() == change.asc_getId()) {
_users[uid] = change;
changed = true;
}
}
}
!changed && change && (_users[change.asc_getId()] = change);
this.displayCollaboration();
},
dlgLeaveTitleText : 'You leave the application',

View file

@ -92,12 +92,16 @@ PE.ApplicationController = new(function(){
permissions = $.extend(permissions, docConfig.permissions);
var _permissions = $.extend({}, docConfig.permissions),
docInfo = new Asc.asc_CDocInfo();
docInfo = new Asc.asc_CDocInfo(),
_user = new Asc.asc_CUserInfo();
_user.put_Id(config.user && config.user.id ? config.user.id : ('uid-' + Date.now()));
docInfo.put_Id(docConfig.key);
docInfo.put_Url(docConfig.url);
docInfo.put_Title(docConfig.title);
docInfo.put_Format(docConfig.fileType);
docInfo.put_VKey(docConfig.vkey);
docInfo.put_UserInfo(_user);
docInfo.put_Token(docConfig.token);
docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(config.encryptionKeys);

View file

@ -51,6 +51,7 @@ define([
PE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
var _users = [];
return {
models: [],
@ -77,13 +78,15 @@ 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));
this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
},
setMode: function (mode) {
this.mode = mode;
this.getView('Toolbar').setMode(mode);
},
@ -200,19 +203,38 @@ define([
PE.getController('Settings').hideModal();
},
displayCollaboration: function(users) {
if(users !== undefined) {
displayCollaboration: function() {
if(_users !== undefined) {
var length = 0;
_.each(users, function (item) {
if (!item.asc_getView())
_.each(_users, function (item) {
if ((item.asc_getState()!==false) && !item.asc_getView())
length++;
});
if (length > 0) {
$('#toolbar-collaboration').show();
} else {
if (length < 1 && this.mode && !this.mode.canViewComments)
$('#toolbar-collaboration').hide();
else
$('#toolbar-collaboration').show();
}
},
onUsersChanged: function(users) {
_users = users;
this.displayCollaboration();
},
onUserConnection: function(change){
var changed = false;
for (var uid in _users) {
if (undefined !== uid) {
var user = _users[uid];
if (user && user.asc_getId() == change.asc_getId()) {
_users[uid] = change;
changed = true;
}
}
}
!changed && change && (_users[change.asc_getId()] = change);
this.displayCollaboration();
},
dlgLeaveTitleText : 'You leave the application',

View file

@ -90,12 +90,16 @@ SSE.ApplicationController = new(function(){
permissions = $.extend(permissions, docConfig.permissions);
var _permissions = $.extend({}, docConfig.permissions),
docInfo = new Asc.asc_CDocInfo();
docInfo = new Asc.asc_CDocInfo(),
_user = new Asc.asc_CUserInfo();
_user.put_Id(config.user && config.user.id ? config.user.id : ('uid-' + Date.now()));
docInfo.put_Id(docConfig.key);
docInfo.put_Url(docConfig.url);
docInfo.put_Title(docConfig.title);
docInfo.put_Format(docConfig.fileType);
docInfo.put_VKey(docConfig.vkey);
docInfo.put_UserInfo(_user);
docInfo.put_Token(docConfig.token);
docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(config.encryptionKeys);

View file

@ -55,6 +55,7 @@ define([
book: false,
sheet: false
};
var _users = [];
return {
models: [],
@ -84,14 +85,16 @@ define([
this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onApiWorksheetLocked, this));
this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onApiActiveSheetChanged, 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));
this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('sheet:active', this.onApiActiveSheetChanged.bind(this));
},
setMode: function (mode) {
this.mode = mode;
this.getView('Toolbar').setMode(mode);
},
@ -219,19 +222,38 @@ define([
SSE.getController('Settings').hideModal();
},
displayCollaboration: function(users) {
if(users !== undefined) {
displayCollaboration: function() {
if(_users !== undefined) {
var length = 0;
_.each(users, function (item) {
if (!item.asc_getView())
_.each(_users, function (item) {
if ((item.asc_getState()!==false) && !item.asc_getView())
length++;
});
if (length > 0) {
$('#toolbar-collaboration').show();
} else {
if (length < 1 && this.mode && !this.mode.canViewComments)
$('#toolbar-collaboration').hide();
else
$('#toolbar-collaboration').show();
}
},
onUsersChanged: function(users) {
_users = users;
this.displayCollaboration();
},
onUserConnection: function(change){
var changed = false;
for (var uid in _users) {
if (undefined !== uid) {
var user = _users[uid];
if (user && user.asc_getId() == change.asc_getId()) {
_users[uid] = change;
changed = true;
}
}
}
!changed && change && (_users[change.asc_getId()] = change);
this.displayCollaboration();
},
dlgLeaveTitleText : 'You leave the application',