Commit 8274a409 authored by konovalovsergey's avatar konovalovsergey

continue c_oAscAsyncAction.Save long action if start forceSave by button

parent 41b4a3f2
......@@ -131,7 +131,7 @@ var editor;
this._init();
return this;
}
spreadsheet_api.prototype = Object.create(AscCommon.baseEditorsApi.prototype);
spreadsheet_api.prototype = Object.create(AscCommon.baseEditorsApi.prototype);
spreadsheet_api.prototype.constructor = spreadsheet_api;
spreadsheet_api.prototype.sendEvent = function() {
this.handlers.trigger.apply(this.handlers, arguments);
......@@ -1464,9 +1464,9 @@ var editor;
this.CoAuthoringApi.onUnSaveLock = function() {
t.CoAuthoringApi.onUnSaveLock = null;
if (t.isForceSaveOnUserSave && t.IsUserSave) {
t.forceSave();
}
if (t.isForceSaveOnUserSave && t.IsUserSave) {
t.forceSaveButtonContinue = t.forceSave();
}
if (t.collaborativeEditing.getCollaborativeEditing()) {
// Шлем update для toolbar-а, т.к. когда select в lock ячейке нужно заблокировать toolbar
......@@ -1477,7 +1477,9 @@ var editor;
t.IsUserSave = false;
t.lastSaveTime = null;
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
if (!t.forceSaveButtonContinue) {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
}
// Обновляем состояние возможности сохранения документа
t.onUpdateDocumentModified(History.Have_Changes());
......
......@@ -141,6 +141,7 @@
this.IsUserSave = false; // Флаг, контролирующий сохранение было сделано пользователем или нет (по умолчанию - нет)
this.isForceSaveOnUserSave = false;
this.forceSaveButtonTimeout = null;
this.forceSaveButtonContinue = false;
this.forceSaveTimeoutTimeout = null;
// Version History
......@@ -488,7 +489,7 @@
};
baseEditorsApi.prototype.forceSave = function()
{
this.CoAuthoringApi.forceSave()
return this.CoAuthoringApi.forceSave();
};
baseEditorsApi.prototype.asc_setIsForceSaveOnUserSave = function(val)
{
......@@ -658,20 +659,35 @@
this.CoAuthoringApi.onForceSave = function(data) {
if (AscCommon.c_oAscForceSaveTypes.Button === data.type) {
if (data.start) {
if (null === t.forceSaveButtonTimeout) {
if (null === t.forceSaveButtonTimeout && !t.forceSaveButtonContinue) {
t.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.ForceSaveButton);
} else {
clearInterval(t.forceSaveButtonTimeout);
}
t.forceSaveButtonTimeout = setInterval(function() {
t.forceSaveButtonTimeout = null;
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.ForceSaveButton);
if (t.forceSaveButtonContinue) {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
} else {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.ForceSaveButton);
}
t.forceSaveButtonContinue = false;
}, Asc.c_nMaxConversionTime);
} else if (data.refuse) {
if (t.forceSaveButtonContinue) {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
}
t.forceSaveButtonContinue = false;
} else {
if (null !== t.forceSaveButtonTimeout) {
clearInterval(t.forceSaveButtonTimeout);
t.forceSaveButtonTimeout = null;
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.ForceSaveButton);
if (t.forceSaveButtonContinue) {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
} else {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.ForceSaveButton);
}
t.forceSaveButtonContinue = false;
}
}
} else {
......
......@@ -364,8 +364,9 @@
CDocsCoApi.prototype.forceSave = function() {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.forceSave();
return this._CoAuthoringApi.forceSave();
}
return false;
};
CDocsCoApi.prototype.callback_OnAuthParticipantsChanged = function(e, count) {
......@@ -876,11 +877,14 @@
};
DocsCoApi.prototype.forceSave = function() {
var res = false;
var newForceSaveButtonTime = Math.max(this.lastOtherSaveTime, this.lastOwnSaveTime);
if (this._lastForceSaveButtonTime < newForceSaveButtonTime) {
this._lastForceSaveButtonTime = newForceSaveButtonTime;
this._send({'type': 'forceSaveStart'});
res = true;
}
return res;
};
DocsCoApi.prototype.openDocument = function(data) {
......@@ -994,10 +998,13 @@
};
DocsCoApi.prototype._onForceSaveStart = function(data) {
if (data['code'] === c_oAscServerCommandErrors.NoError) {
var code = data['code'];
if (code === c_oAscServerCommandErrors.NoError) {
this._lastForceSaveButtonTime = data['time'];
this.onForceSave({type: c_oAscForceSaveTypes.Button, start: true});
} else if (data['code'] !== c_oAscServerCommandErrors.NotModified) {
} else if (code === c_oAscServerCommandErrors.NotModified) {
this.onForceSave({type: c_oAscForceSaveTypes.Button, refuse: true});
} else {
this.onWarning(Asc.c_oAscError.ID.Unknown);
}
};
......
......@@ -1849,14 +1849,16 @@ background-repeat: no-repeat;\
{
t.CoAuthoringApi.onUnSaveLock = null;
if (t.isForceSaveOnUserSave && t.IsUserSave) {
t.forceSave();
t.forceSaveButtonContinue = t.forceSave();
}
// Выставляем, что документ не модифицирован
t.CheckChangedDocument();
t.canSave = true;
t.IsUserSave = false;
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
if (!t.forceSaveButtonContinue) {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
}
// Обновляем состояние возможности сохранения документа
t._onUpdateDocumentCanSave();
......
......@@ -1831,14 +1831,16 @@ background-repeat: no-repeat;\
{
t.CoAuthoringApi.onUnSaveLock = null;
if (t.isForceSaveOnUserSave && t.IsUserSave) {
t.forceSave();
t.forceSaveButtonContinue = t.forceSave();
}
// Выставляем, что документ не модифицирован
t.CheckChangedDocument();
t.canSave = true;
t.IsUserSave = false;
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
if (!t.forceSaveButtonContinue) {
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
}
// Обновляем состояние возможности сохранения документа
t._onUpdateDocumentCanSave();
......
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