Commit 19f512ef authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил функцию окончания первой загрузки изменений.

Добавил id пользователя для изменения.
Добавил получение пользователя по id.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55593 954022d7-b5bf-4e40-9824-e11837661b57
parent 784ab498
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks
this.onDisconnect = options.onDisconnect; this.onDisconnect = options.onDisconnect;
this.onFirstLoadChanges = options.onFirstLoadChanges; this.onFirstLoadChanges = options.onFirstLoadChanges;
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged; this.onConnectionStateChanged = options.onConnectionStateChanged;
this.onSetIndexUser = options.onSetIndexUser; this.onSetIndexUser = options.onSetIndexUser;
this.onSaveChanges = options.onSaveChanges; this.onSaveChanges = options.onSaveChanges;
...@@ -37,10 +38,11 @@ ...@@ -37,10 +38,11 @@
this._CoAuthoringApi.onLocksReleased = function (e, bChanges) {t.callback_OnLocksReleased(e, bChanges);}; this._CoAuthoringApi.onLocksReleased = function (e, bChanges) {t.callback_OnLocksReleased(e, bChanges);};
this._CoAuthoringApi.onLocksReleasedEnd = function () {t.callback_OnLocksReleasedEnd();}; this._CoAuthoringApi.onLocksReleasedEnd = function () {t.callback_OnLocksReleasedEnd();};
this._CoAuthoringApi.onDisconnect = function (e, isDisconnectAtAll, isCloseCoAuthoring) {t.callback_OnDisconnect(e, isDisconnectAtAll, isCloseCoAuthoring);}; this._CoAuthoringApi.onDisconnect = function (e, isDisconnectAtAll, isCloseCoAuthoring) {t.callback_OnDisconnect(e, isDisconnectAtAll, isCloseCoAuthoring);};
this._CoAuthoringApi.onFirstLoadChanges = function (e) {t.callback_OnFirstLoadChanges(e);}; this._CoAuthoringApi.onFirstLoadChanges = function (e, userId) {t.callback_OnFirstLoadChanges(e, userId);};
this._CoAuthoringApi.onFirstLoadChangesEnd = function () {t.callback_OnFirstLoadChangesEnd();};
this._CoAuthoringApi.onConnectionStateChanged = function (e) {t.callback_OnConnectionStateChanged(e);}; this._CoAuthoringApi.onConnectionStateChanged = function (e) {t.callback_OnConnectionStateChanged(e);};
this._CoAuthoringApi.onSetIndexUser = function (e) {t.callback_OnSetIndexUser(e);}; this._CoAuthoringApi.onSetIndexUser = function (e) {t.callback_OnSetIndexUser(e);};
this._CoAuthoringApi.onSaveChanges = function (e) {t.callback_OnSaveChanges(e);}; this._CoAuthoringApi.onSaveChanges = function (e, userId) {t.callback_OnSaveChanges(e, userId);};
// Callback есть пользователей больше 1 // Callback есть пользователей больше 1
this._CoAuthoringApi.onStartCoAuthoring = function (e) {t.callback_OnStartCoAuthoring(e);}; this._CoAuthoringApi.onStartCoAuthoring = function (e) {t.callback_OnStartCoAuthoring(e);};
...@@ -132,6 +134,12 @@ ...@@ -132,6 +134,12 @@
} }
}; };
CDocsCoApi.prototype.getUser = function (userId) {
if (this._CoAuthoringApi && this._onlineWork)
return this._CoAuthoringApi.getUser(userId);
return null;
};
CDocsCoApi.prototype.releaseLocks = function (blockId) { CDocsCoApi.prototype.releaseLocks = function (blockId) {
if (this._CoAuthoringApi && this._onlineWork) { if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.releaseLocks(blockId); this._CoAuthoringApi.releaseLocks(blockId);
...@@ -151,27 +159,27 @@ ...@@ -151,27 +159,27 @@
CDocsCoApi.prototype.callback_OnParticipantsChanged = function (e, count) { CDocsCoApi.prototype.callback_OnParticipantsChanged = function (e, count) {
if (this.onParticipantsChanged) if (this.onParticipantsChanged)
this.onParticipantsChanged (e, count); this.onParticipantsChanged(e, count);
}; };
CDocsCoApi.prototype.callback_OnMessage = function (e) { CDocsCoApi.prototype.callback_OnMessage = function (e) {
if (this.onMessage) if (this.onMessage)
this.onMessage (e); this.onMessage(e);
}; };
CDocsCoApi.prototype.callback_OnLocksAcquired = function (e) { CDocsCoApi.prototype.callback_OnLocksAcquired = function (e) {
if (this.onLocksAcquired) if (this.onLocksAcquired)
this.onLocksAcquired (e); this.onLocksAcquired(e);
}; };
CDocsCoApi.prototype.callback_OnLocksReleased = function (e, bChanges) { CDocsCoApi.prototype.callback_OnLocksReleased = function (e, bChanges) {
if (this.onLocksReleased) if (this.onLocksReleased)
this.onLocksReleased (e, bChanges); this.onLocksReleased(e, bChanges);
}; };
CDocsCoApi.prototype.callback_OnLocksReleasedEnd = function () { CDocsCoApi.prototype.callback_OnLocksReleasedEnd = function () {
if (this.onLocksReleasedEnd) if (this.onLocksReleasedEnd)
this.onLocksReleasedEnd (); this.onLocksReleasedEnd();
}; };
/** /**
...@@ -182,31 +190,36 @@ ...@@ -182,31 +190,36 @@
*/ */
CDocsCoApi.prototype.callback_OnDisconnect = function (e, isDisconnectAtAll, isCloseCoAuthoring) { CDocsCoApi.prototype.callback_OnDisconnect = function (e, isDisconnectAtAll, isCloseCoAuthoring) {
if (this.onDisconnect) if (this.onDisconnect)
this.onDisconnect (e, isDisconnectAtAll, isCloseCoAuthoring); this.onDisconnect(e, isDisconnectAtAll, isCloseCoAuthoring);
}; };
CDocsCoApi.prototype.callback_OnFirstLoadChanges = function (e) { CDocsCoApi.prototype.callback_OnFirstLoadChanges = function (e, userId) {
if (this.onFirstLoadChanges) if (this.onFirstLoadChanges)
this.onFirstLoadChanges (e); this.onFirstLoadChanges(e, userId);
};
CDocsCoApi.prototype.callback_OnFirstLoadChangesEnd = function () {
if (this.onFirstLoadChangesEnd)
this.onFirstLoadChangesEnd();
}; };
CDocsCoApi.prototype.callback_OnConnectionStateChanged = function (e) { CDocsCoApi.prototype.callback_OnConnectionStateChanged = function (e) {
if (this.onConnectionStateChanged) if (this.onConnectionStateChanged)
this.onConnectionStateChanged (e); this.onConnectionStateChanged(e);
}; };
CDocsCoApi.prototype.callback_OnSetIndexUser = function (e) { CDocsCoApi.prototype.callback_OnSetIndexUser = function (e) {
if (this.onSetIndexUser) if (this.onSetIndexUser)
this.onSetIndexUser (e); this.onSetIndexUser(e);
}; };
CDocsCoApi.prototype.callback_OnSaveChanges = function (e) { CDocsCoApi.prototype.callback_OnSaveChanges = function (e, userId) {
if (this.onSaveChanges) if (this.onSaveChanges)
this.onSaveChanges (e); this.onSaveChanges(e, userId);
}; };
CDocsCoApi.prototype.callback_OnStartCoAuthoring = function (e) { CDocsCoApi.prototype.callback_OnStartCoAuthoring = function (e) {
if (this.onStartCoAuthoring) if (this.onStartCoAuthoring)
this.onStartCoAuthoring (e); this.onStartCoAuthoring(e);
}; };
/** States /** States
...@@ -227,7 +240,9 @@ ...@@ -227,7 +240,9 @@
this.onRelockFailed = options.onRelockFailed; this.onRelockFailed = options.onRelockFailed;
this.onDisconnect = options.onDisconnect; this.onDisconnect = options.onDisconnect;
this.onConnect = options.onConnect; this.onConnect = options.onConnect;
this.onSaveChanges = options.onSaveChanges;
this.onFirstLoadChanges = options.onFirstLoadChanges; this.onFirstLoadChanges = options.onFirstLoadChanges;
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged; this.onConnectionStateChanged = options.onConnectionStateChanged;
} }
this._state = 0; this._state = 0;
...@@ -414,6 +429,10 @@ ...@@ -414,6 +429,10 @@
this.onAuthParticipantsChanged(this._participants, this._countEditUsers); this.onAuthParticipantsChanged(this._participants, this._countEditUsers);
}; };
DocsCoApi.prototype.getUser = function (userId) {
return this._participants[userId];
};
DocsCoApi.prototype.disconnect = function () { DocsCoApi.prototype.disconnect = function () {
// Отключаемся сами // Отключаемся сами
this.isCloseCoAuthoring = true; this.isCloseCoAuthoring = true;
...@@ -540,7 +559,7 @@ ...@@ -540,7 +559,7 @@
} }
if (data["changes"]) { if (data["changes"]) {
if (this.onSaveChanges) { if (this.onSaveChanges) {
this.onSaveChanges(JSON.parse(data["changes"])); this.onSaveChanges(JSON.parse(data["changes"]), data["user"]);
} }
} }
}; };
...@@ -579,20 +598,19 @@ ...@@ -579,20 +598,19 @@
var t = this; var t = this;
if (allServerChanges && this.onFirstLoadChanges) { if (allServerChanges && this.onFirstLoadChanges) {
var allChanges = []; var allChanges = [];
for (var changeId in allServerChanges) { for (var changeId in allServerChanges) if (allServerChanges.hasOwnProperty(changeId)){
var change = allServerChanges[changeId]; var change = allServerChanges[changeId];
if (change["skipChange"]) if (change["skipChange"])
continue; continue;
var changesOneUser = change["changes"]; var changesOneUser = change["changes"];
if (changesOneUser) { if (changesOneUser) {
changesOneUser = JSON.parse(changesOneUser); t.onFirstLoadChanges(JSON.parse(changesOneUser), change["user"]);
for (var i in changesOneUser)
allChanges.push(changesOneUser[i]);
} }
} }
// Посылать нужно всегда, т.к. на это рассчитываем при открытии // Посылать нужно всегда, т.к. на это рассчитываем при открытии
t.onFirstLoadChanges(allChanges); if (t.onFirstLoadChangesEnd)
t.onFirstLoadChangesEnd();
// Если были изменения, то мы все еще в совместном редактировании (иначе при сохранениях мы будем затирать изменения на сервере) // Если были изменения, то мы все еще в совместном редактировании (иначе при сохранениях мы будем затирать изменения на сервере)
if (0 < allChanges.length) if (0 < allChanges.length)
t._onStartCoAuthoring(/*isStartEvent*/ true); t._onStartCoAuthoring(/*isStartEvent*/ true);
......
...@@ -1572,7 +1572,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1572,7 +1572,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
worksheet.cellCommentator.unlockComments(); worksheet.cellCommentator.unlockComments();
} }
}; };
this.CoAuthoringApi.onSaveChanges = function (e, bSendEvent) { this.CoAuthoringApi.onSaveChanges = function (e, userId, bSendEvent) {
// bSendEvent = false - это означает, что мы загружаем имеющиеся изменения при открытии // bSendEvent = false - это означает, что мы загружаем имеющиеся изменения при открытии
var bAddChanges = false; var bAddChanges = false;
var nCount = e.length; var nCount = e.length;
...@@ -1608,8 +1608,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1608,8 +1608,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (true === bAddChanges && false !== bSendEvent && t.IsSendDocumentLoadCompleate) if (true === bAddChanges && false !== bSendEvent && t.IsSendDocumentLoadCompleate)
t.syncCollaborativeChanges(); t.syncCollaborativeChanges();
}; };
this.CoAuthoringApi.onFirstLoadChanges = function (e) { this.CoAuthoringApi.onFirstLoadChanges = function (e, userId) {
t.CoAuthoringApi.onSaveChanges(e, false); t.CoAuthoringApi.onSaveChanges(e, userId, false);
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded (); t.asyncServerIdEndLoaded ();
}; };
this.CoAuthoringApi.onSetIndexUser = function (e) { this.CoAuthoringApi.onSetIndexUser = function (e) {
...@@ -3401,7 +3403,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -3401,7 +3403,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_nativeApplyChanges : function(changes) asc_nativeApplyChanges : function(changes)
{ {
this.CoAuthoringApi.onSaveChanges(changes, false); this.CoAuthoringApi.onSaveChanges(changes, null, false);
this.collaborativeEditing.applyChanges(); this.collaborativeEditing.applyChanges();
}, },
......
...@@ -457,7 +457,7 @@ asc_docs_api.prototype._coAuthoringInit = function () { ...@@ -457,7 +457,7 @@ asc_docs_api.prototype._coAuthoringInit = function () {
} }
} }
}; };
this.CoAuthoringApi.onSaveChanges = function (e, bSendEvent) { this.CoAuthoringApi.onSaveChanges = function (e, userId, bSendEvent) {
// bSendEvent = false - это означает, что мы загружаем имеющиеся изменения при открытии // bSendEvent = false - это означает, что мы загружаем имеющиеся изменения при открытии
var Count = e.length; var Count = e.length;
for ( var Index = 0; Index < Count; Index++ ) for ( var Index = 0; Index < Count; Index++ )
...@@ -472,11 +472,13 @@ asc_docs_api.prototype._coAuthoringInit = function () { ...@@ -472,11 +472,13 @@ asc_docs_api.prototype._coAuthoringInit = function () {
if ( Count > 0 && false != bSendEvent && t.bInit_word_control ) if ( Count > 0 && false != bSendEvent && t.bInit_word_control )
t.sync_CollaborativeChanges(); t.sync_CollaborativeChanges();
}; };
this.CoAuthoringApi.onFirstLoadChanges = function (e) { this.CoAuthoringApi.onFirstLoadChanges = function (e, userId) {
t.CoAuthoringApi.onSaveChanges(e,false); t.CoAuthoringApi.onSaveChanges(e, userId, false);
t.asyncServerIdEndLoaded ();
//CollaborativeEditing.Apply_Changes(); //CollaborativeEditing.Apply_Changes();
}; };
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded ();
};
this.CoAuthoringApi.onSetIndexUser = function (e) { this.CoAuthoringApi.onSetIndexUser = function (e) {
g_oIdCounter.Set_UserId("" + e); g_oIdCounter.Set_UserId("" + e);
}; };
......
...@@ -1570,8 +1570,12 @@ asc_docs_api.prototype._coAuthoringInit = function() ...@@ -1570,8 +1570,12 @@ asc_docs_api.prototype._coAuthoringInit = function()
CollaborativeEditing.Remove_NeedLock(Id); CollaborativeEditing.Remove_NeedLock(Id);
} }
}; };
this.CoAuthoringApi.onSaveChanges = function (e, bSendEvent) this.CoAuthoringApi.onSaveChanges = function (e, userId, bSendEvent)
{ {
var oUser = t.CoAuthoringApi.getUser(userId);
var oColor = oUser ? oUser.asc_getColor() : null;
// ToDo add select changes color
var Count = e.length; var Count = e.length;
for ( var Index = 0; Index < Count; Index++ ) for ( var Index = 0; Index < Count; Index++ )
{ {
...@@ -1585,12 +1589,14 @@ asc_docs_api.prototype._coAuthoringInit = function() ...@@ -1585,12 +1589,14 @@ asc_docs_api.prototype._coAuthoringInit = function()
if ( Count > 0 && false != bSendEvent && t.bInit_word_control ) if ( Count > 0 && false != bSendEvent && t.bInit_word_control )
t.sync_CollaborativeChanges(); t.sync_CollaborativeChanges();
}; };
this.CoAuthoringApi.onFirstLoadChanges = function (e) this.CoAuthoringApi.onFirstLoadChanges = function (e, userId)
{ {
t.CoAuthoringApi.onSaveChanges(e,false); t.CoAuthoringApi.onSaveChanges(e, userId, false);
t.asyncServerIdEndLoaded ();
//CollaborativeEditing.Apply_Changes(); //CollaborativeEditing.Apply_Changes();
}; };
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded ();
};
this.CoAuthoringApi.onSetIndexUser = function (e) this.CoAuthoringApi.onSetIndexUser = function (e)
{ {
g_oIdCounter.Set_UserId("" + e); g_oIdCounter.Set_UserId("" + e);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment