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 @@
this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks
this.onDisconnect = options.onDisconnect;
this.onFirstLoadChanges = options.onFirstLoadChanges;
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged;
this.onSetIndexUser = options.onSetIndexUser;
this.onSaveChanges = options.onSaveChanges;
......@@ -37,10 +38,11 @@
this._CoAuthoringApi.onLocksReleased = function (e, bChanges) {t.callback_OnLocksReleased(e, bChanges);};
this._CoAuthoringApi.onLocksReleasedEnd = function () {t.callback_OnLocksReleasedEnd();};
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.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
this._CoAuthoringApi.onStartCoAuthoring = function (e) {t.callback_OnStartCoAuthoring(e);};
......@@ -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) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.releaseLocks(blockId);
......@@ -151,27 +159,27 @@
CDocsCoApi.prototype.callback_OnParticipantsChanged = function (e, count) {
if (this.onParticipantsChanged)
this.onParticipantsChanged (e, count);
this.onParticipantsChanged(e, count);
};
CDocsCoApi.prototype.callback_OnMessage = function (e) {
if (this.onMessage)
this.onMessage (e);
this.onMessage(e);
};
CDocsCoApi.prototype.callback_OnLocksAcquired = function (e) {
if (this.onLocksAcquired)
this.onLocksAcquired (e);
this.onLocksAcquired(e);
};
CDocsCoApi.prototype.callback_OnLocksReleased = function (e, bChanges) {
if (this.onLocksReleased)
this.onLocksReleased (e, bChanges);
this.onLocksReleased(e, bChanges);
};
CDocsCoApi.prototype.callback_OnLocksReleasedEnd = function () {
if (this.onLocksReleasedEnd)
this.onLocksReleasedEnd ();
this.onLocksReleasedEnd();
};
/**
......@@ -182,31 +190,36 @@
*/
CDocsCoApi.prototype.callback_OnDisconnect = function (e, isDisconnectAtAll, isCloseCoAuthoring) {
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)
this.onFirstLoadChanges (e);
this.onFirstLoadChanges(e, userId);
};
CDocsCoApi.prototype.callback_OnFirstLoadChangesEnd = function () {
if (this.onFirstLoadChangesEnd)
this.onFirstLoadChangesEnd();
};
CDocsCoApi.prototype.callback_OnConnectionStateChanged = function (e) {
if (this.onConnectionStateChanged)
this.onConnectionStateChanged (e);
this.onConnectionStateChanged(e);
};
CDocsCoApi.prototype.callback_OnSetIndexUser = function (e) {
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)
this.onSaveChanges (e);
this.onSaveChanges(e, userId);
};
CDocsCoApi.prototype.callback_OnStartCoAuthoring = function (e) {
if (this.onStartCoAuthoring)
this.onStartCoAuthoring (e);
this.onStartCoAuthoring(e);
};
/** States
......@@ -227,7 +240,9 @@
this.onRelockFailed = options.onRelockFailed;
this.onDisconnect = options.onDisconnect;
this.onConnect = options.onConnect;
this.onSaveChanges = options.onSaveChanges;
this.onFirstLoadChanges = options.onFirstLoadChanges;
this.onFirstLoadChangesEnd = options.onFirstLoadChangesEnd;
this.onConnectionStateChanged = options.onConnectionStateChanged;
}
this._state = 0;
......@@ -414,6 +429,10 @@
this.onAuthParticipantsChanged(this._participants, this._countEditUsers);
};
DocsCoApi.prototype.getUser = function (userId) {
return this._participants[userId];
};
DocsCoApi.prototype.disconnect = function () {
// Отключаемся сами
this.isCloseCoAuthoring = true;
......@@ -540,7 +559,7 @@
}
if (data["changes"]) {
if (this.onSaveChanges) {
this.onSaveChanges(JSON.parse(data["changes"]));
this.onSaveChanges(JSON.parse(data["changes"]), data["user"]);
}
}
};
......@@ -579,20 +598,19 @@
var t = this;
if (allServerChanges && this.onFirstLoadChanges) {
var allChanges = [];
for (var changeId in allServerChanges) {
for (var changeId in allServerChanges) if (allServerChanges.hasOwnProperty(changeId)){
var change = allServerChanges[changeId];
if (change["skipChange"])
continue;
var changesOneUser = change["changes"];
if (changesOneUser) {
changesOneUser = JSON.parse(changesOneUser);
for (var i in changesOneUser)
allChanges.push(changesOneUser[i]);
t.onFirstLoadChanges(JSON.parse(changesOneUser), change["user"]);
}
}
// Посылать нужно всегда, т.к. на это рассчитываем при открытии
t.onFirstLoadChanges(allChanges);
if (t.onFirstLoadChangesEnd)
t.onFirstLoadChangesEnd();
// Если были изменения, то мы все еще в совместном редактировании (иначе при сохранениях мы будем затирать изменения на сервере)
if (0 < allChanges.length)
t._onStartCoAuthoring(/*isStartEvent*/ true);
......
......@@ -1572,7 +1572,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
worksheet.cellCommentator.unlockComments();
}
};
this.CoAuthoringApi.onSaveChanges = function (e, bSendEvent) {
this.CoAuthoringApi.onSaveChanges = function (e, userId, bSendEvent) {
// bSendEvent = false - это означает, что мы загружаем имеющиеся изменения при открытии
var bAddChanges = false;
var nCount = e.length;
......@@ -1608,8 +1608,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (true === bAddChanges && false !== bSendEvent && t.IsSendDocumentLoadCompleate)
t.syncCollaborativeChanges();
};
this.CoAuthoringApi.onFirstLoadChanges = function (e) {
t.CoAuthoringApi.onSaveChanges(e, false);
this.CoAuthoringApi.onFirstLoadChanges = function (e, userId) {
t.CoAuthoringApi.onSaveChanges(e, userId, false);
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded ();
};
this.CoAuthoringApi.onSetIndexUser = function (e) {
......@@ -3401,7 +3403,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_nativeApplyChanges : function(changes)
{
this.CoAuthoringApi.onSaveChanges(changes, false);
this.CoAuthoringApi.onSaveChanges(changes, null, false);
this.collaborativeEditing.applyChanges();
},
......
......@@ -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 - это означает, что мы загружаем имеющиеся изменения при открытии
var Count = e.length;
for ( var Index = 0; Index < Count; Index++ )
......@@ -472,11 +472,13 @@ asc_docs_api.prototype._coAuthoringInit = function () {
if ( Count > 0 && false != bSendEvent && t.bInit_word_control )
t.sync_CollaborativeChanges();
};
this.CoAuthoringApi.onFirstLoadChanges = function (e) {
t.CoAuthoringApi.onSaveChanges(e,false);
t.asyncServerIdEndLoaded ();
this.CoAuthoringApi.onFirstLoadChanges = function (e, userId) {
t.CoAuthoringApi.onSaveChanges(e, userId, false);
//CollaborativeEditing.Apply_Changes();
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded ();
};
this.CoAuthoringApi.onSetIndexUser = function (e) {
g_oIdCounter.Set_UserId("" + e);
};
......
......@@ -1570,8 +1570,12 @@ asc_docs_api.prototype._coAuthoringInit = function()
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;
for ( var Index = 0; Index < Count; Index++ )
{
......@@ -1585,12 +1589,14 @@ asc_docs_api.prototype._coAuthoringInit = function()
if ( Count > 0 && false != bSendEvent && t.bInit_word_control )
t.sync_CollaborativeChanges();
};
this.CoAuthoringApi.onFirstLoadChanges = function (e)
this.CoAuthoringApi.onFirstLoadChanges = function (e, userId)
{
t.CoAuthoringApi.onSaveChanges(e,false);
t.asyncServerIdEndLoaded ();
t.CoAuthoringApi.onSaveChanges(e, userId, false);
//CollaborativeEditing.Apply_Changes();
};
this.CoAuthoringApi.onFirstLoadChangesEnd = function () {
t.asyncServerIdEndLoaded ();
};
this.CoAuthoringApi.onSetIndexUser = function (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