Commit d0dfeed5 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил понятие lock для документа (если подключился второй пользователь)


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56650 954022d7-b5bf-4e40-9824-e11837661b57
parent 9bcc6007
......@@ -112,7 +112,7 @@
window.setTimeout(function () {
if (callback && _.isFunction(callback)) {
// Фиктивные вызовы
callback({"savelock": false});
callback({"saveLock": false});
}
}, 100);
}
......@@ -129,6 +129,12 @@
this._CoAuthoringApi.saveChanges(arrayChanges, null, deleteIndex);
}
};
CDocsCoApi.prototype.unLockDocument = function () {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.unLockDocument();
}
};
CDocsCoApi.prototype.getUsers = function () {
if (this._CoAuthoringApi && this._onlineWork) {
......@@ -360,11 +366,11 @@
}, 5000);//5 sec to signal lock failure
}
if (this._isExcel)
this._send({"type": "getlockrange", "block": arrayBlockId});
this._send({"type": "getLockRange", "block": arrayBlockId});
else if (this._isPresentation)
this._send({"type": "getlockpresentation", "block": arrayBlockId});
this._send({"type": "getLockPresentation", "block": arrayBlockId});
else
this._send({"type": "getlock", "block": arrayBlockId});
this._send({"type": "getLock", "block": arrayBlockId});
} else {
// Вернем ошибку, т.к. залочены элементы
window.setTimeout(function () {
......@@ -411,11 +417,11 @@
}
}, 5000);//5 sec to signal lock failure
}
this._send({"type": "issavelock"});
this._send({"type": "isSaveLock"});
};
DocsCoApi.prototype.unSaveChanges = function () {
this._send({"type": "unsavelock"});
this._send({"type": "unSaveLock"});
};
DocsCoApi.prototype.releaseLocks = function (blockId) {
......@@ -442,11 +448,15 @@
}
}
this._send({"type": "savechanges", "changes": JSON.stringify(arrayChanges.slice(startIndex, endIndex)),
this._send({"type": "saveChanges", "changes": JSON.stringify(arrayChanges.slice(startIndex, endIndex)),
"startSaveChanges": (startIndex === 0), "endSaveChanges": (endIndex === arrayChanges.length),
"isCoAuthoring": this.isCoAuthoring, "isExcel": this._isExcel, "deleteIndex": this.deleteIndex});
};
DocsCoApi.prototype.unLockDocument = function () {
this._send({"type": "unLockDocument"});
};
DocsCoApi.prototype.getUsers = function () {
// Специально для возможности получения после прохождения авторизации (Стоит переделать)
if (this.onAuthParticipantsChanged)
......@@ -464,7 +474,7 @@
};
DocsCoApi.prototype.getMessages = function () {
this._send({"type": "getmessages"});
this._send({"type": "getMessages"});
};
DocsCoApi.prototype.sendMessage = function (message) {
......@@ -598,7 +608,7 @@
};
DocsCoApi.prototype._onSaveLock = function (data) {
if (undefined != data["savelock"] && null != data["savelock"]) {
if (undefined != data["saveLock"] && null != data["saveLock"]) {
var indexCallback = this._saveCallback.length - 1;
var oTmpCallback = this._saveCallback[indexCallback];
if (oTmpCallback) {
......@@ -624,8 +634,6 @@
var hasChanges = false;
for (var changeId in allServerChanges) if (allServerChanges.hasOwnProperty(changeId)){
var change = allServerChanges[changeId];
if (change["skipChange"])
continue;
var changesOneUser = change["changes"];
if (changesOneUser) {
hasChanges = true;
......@@ -846,14 +854,15 @@
switch (type) {
case 'auth' : t._onAuth(dataObject); break;
case 'message' : t._onMessages(dataObject); break;
case 'getlock' : t._onGetLock(dataObject); break;
case 'releaselock' : t._onReleaseLock(dataObject); break;
case 'connectstate' : t._onConnectionStateChanged(dataObject); break;
case 'savechanges' : t._onSaveChanges(dataObject); break;
case 'savelock' : t._onSaveLock(dataObject); break;
case 'unsavelock' : t._onUnSaveLock(dataObject); break;
case 'getLock' : t._onGetLock(dataObject); break;
case 'releaseLock' : t._onReleaseLock(dataObject); break;
case 'connectState' : t._onConnectionStateChanged(dataObject); break;
case 'saveChanges' : t._onSaveChanges(dataObject); break;
case 'saveLock' : t._onSaveLock(dataObject); break;
case 'unSaveLock' : t._onUnSaveLock(dataObject); break;
case 'savePartChanges' : t._onSavePartChanges(); break;
case 'drop' : t._onDrop(dataObject); break;
case 'waitAuth' : /*Ждем, когда придет auth, документ залочен*/break;
}
};
sockjs.onclose = function (evt) {
......
......@@ -1879,7 +1879,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
onSaveCallback: function (e) {
var t = this;
var nState;
if (false == e["savelock"]) {
if (false == e["saveLock"]) {
if (this.isAutoSave) {
this.asc_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
this.asc_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.PrepareToSave);
......
......@@ -492,11 +492,14 @@ asc_docs_api.prototype._coAuthoringInit = function () {
this.CoAuthoringApi.onStartCoAuthoring = function (isStartEvent) {
if (t.ParcedDocument) {
CollaborativeEditing.Start_CollaborationEditing();
editor.WordControl.m_oLogicDocument.DrawingDocument.Start_CollaborationEditing();
t.WordControl.m_oLogicDocument.DrawingDocument.Start_CollaborationEditing();
if (true != History.Is_Clear()) {
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Send_Changes();
} else {
// Изменений нет, но нужно сбросить lock
t.CoAuthoringApi.unLockDocument();
}
} else
t.isStartCoAuthoringOnEndLoad = true;
......@@ -1788,7 +1791,7 @@ function safe_Apply_Changes()
asc_docs_api.prototype.onSaveCallback = function (e) {
var t = this;
var nState;
if (false == e["savelock"]) {
if (false == e["saveLock"]) {
if (t.isAutoSave) {
t.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
t.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.PrepareToSave);
......
......@@ -1597,12 +1597,15 @@ asc_docs_api.prototype._coAuthoringInit = function()
this.CoAuthoringApi.onStartCoAuthoring = function (isStartEvent) {
if (t.ParcedDocument) {
CollaborativeEditing.Start_CollaborationEditing();
editor.asc_setDrawCollaborationMarks(true);
editor.WordControl.m_oLogicDocument.DrawingDocument.Start_CollaborationEditing();
t.asc_setDrawCollaborationMarks(true);
t.WordControl.m_oLogicDocument.DrawingDocument.Start_CollaborationEditing();
if (true != History.Is_Clear()) {
CollaborativeEditing.Apply_Changes();
CollaborativeEditing.Send_Changes();
} else {
// Изменений нет, но нужно сбросить lock
t.CoAuthoringApi.unLockDocument();
}
} else
t.isStartCoAuthoringOnEndLoad = true;
......@@ -2773,7 +2776,7 @@ function safe_Apply_Changes()
function OnSave_Callback(e)
{
var nState;
if ( false == e["savelock"] ) {
if ( false == e["saveLock"] ) {
if (editor.isAutoSave) {
editor.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
editor.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.PrepareToSave);
......
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