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

View file

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

View file

@ -91,12 +91,16 @@ DE.ApplicationController = new(function(){
permissions = $.extend(permissions, docConfig.permissions); permissions = $.extend(permissions, docConfig.permissions);
var _permissions = $.extend({}, 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_Id(docConfig.key);
docInfo.put_Url(docConfig.url); docInfo.put_Url(docConfig.url);
docInfo.put_Title(docConfig.title); docInfo.put_Title(docConfig.title);
docInfo.put_Format(docConfig.fileType); docInfo.put_Format(docConfig.fileType);
docInfo.put_VKey(docConfig.vkey); docInfo.put_VKey(docConfig.vkey);
docInfo.put_UserInfo(_user);
docInfo.put_Token(docConfig.token); docInfo.put_Token(docConfig.token);
docInfo.put_Permissions(_permissions); docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(config.encryptionKeys); docInfo.put_EncryptedInfo(config.encryptionKeys);

View file

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

View file

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

View file

@ -92,12 +92,16 @@ PE.ApplicationController = new(function(){
permissions = $.extend(permissions, docConfig.permissions); permissions = $.extend(permissions, docConfig.permissions);
var _permissions = $.extend({}, 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_Id(docConfig.key);
docInfo.put_Url(docConfig.url); docInfo.put_Url(docConfig.url);
docInfo.put_Title(docConfig.title); docInfo.put_Title(docConfig.title);
docInfo.put_Format(docConfig.fileType); docInfo.put_Format(docConfig.fileType);
docInfo.put_VKey(docConfig.vkey); docInfo.put_VKey(docConfig.vkey);
docInfo.put_UserInfo(_user);
docInfo.put_Token(docConfig.token); docInfo.put_Token(docConfig.token);
docInfo.put_Permissions(_permissions); docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(config.encryptionKeys); docInfo.put_EncryptedInfo(config.encryptionKeys);

View file

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

View file

@ -90,12 +90,16 @@ SSE.ApplicationController = new(function(){
permissions = $.extend(permissions, docConfig.permissions); permissions = $.extend(permissions, docConfig.permissions);
var _permissions = $.extend({}, 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_Id(docConfig.key);
docInfo.put_Url(docConfig.url); docInfo.put_Url(docConfig.url);
docInfo.put_Title(docConfig.title); docInfo.put_Title(docConfig.title);
docInfo.put_Format(docConfig.fileType); docInfo.put_Format(docConfig.fileType);
docInfo.put_VKey(docConfig.vkey); docInfo.put_VKey(docConfig.vkey);
docInfo.put_UserInfo(_user);
docInfo.put_Token(docConfig.token); docInfo.put_Token(docConfig.token);
docInfo.put_Permissions(_permissions); docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(config.encryptionKeys); docInfo.put_EncryptedInfo(config.encryptionKeys);

View file

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