Commit fac01b2d authored by konovalovsergey's avatar konovalovsergey

for bug 34575. use asc_Save

parent 35478148
......@@ -311,17 +311,18 @@ var editor;
}
this._asc_downloadAs(typeFile, c_oAscAsyncAction.DownloadAs, {downloadType: bIsDownloadEvent ? DownloadType.Download: DownloadType.None});
};
spreadsheet_api.prototype.saveCheck = function() {
return !(!this.canSave || this.isChartEditor || c_oAscAdvancedOptionsAction.None !== this.advancedOptionsAction || this.isLongAction());
};
spreadsheet_api.prototype.asc_Save = function (isAutoSave) {
this.IsUserSave = !isAutoSave;
if (!this.canSave || this.isChartEditor || c_oAscAdvancedOptionsAction.None !== this.advancedOptionsAction ||
this.isLongAction()) {
return;
if (!this.saveCheck()) {
return false;
} else if (!(this.asc_isDocumentCanSave() || this.collaborativeEditing.haveOtherChanges() || this.canUnlockDocument)) {
if (this.isForceSaveOnUserSave && this.IsUserSave) {
this.forceSave();
}
return;
return false;
}
if (this.IsUserSave) {
......@@ -338,6 +339,7 @@ var editor;
this.CoAuthoringApi.askSaveChanges(function (e) {
t.onSaveCallback(e);
});
return true;
};
spreadsheet_api.prototype.asc_Print = function(adjustPrint, bIsDownloadEvent) {
......@@ -1506,6 +1508,10 @@ var editor;
if (undefined !== window["AscDesktopEditor"]) {
window["AscDesktopEditor"]["OnSave"]();
}
if (t.disconnectOnSave) {
t.CoAuthoringApi.disconnect(t.disconnectOnSave.code, t.disconnectOnSave.reason);
t.disconnectOnSave = null;
}
};
// Пересылаем свои изменения
this.collaborativeEditing.sendChanges(this.IsUserSave);
......
......@@ -143,6 +143,7 @@
this.forceSaveButtonTimeout = null;
this.forceSaveButtonContinue = false;
this.forceSaveTimeoutTimeout = null;
this.disconnectOnSave = null;
// Version History
this.VersionHistory = null; // Объект, который отвечает за точку в списке версий
......@@ -648,23 +649,10 @@
extendSession = false;
}
if (!extendSession) {
if (AscCommon.History.Have_Changes()) {
if (t.asc_Save()) {
//enter view mode because save async
t.sendEvent('asc_onCoAuthoringDisconnect');
t.asc_setViewMode(true);
t.CoAuthoringApi.onUnSaveLock = function() {
t.CoAuthoringApi.onUnSaveLock = null;
t.CoAuthoringApi.disconnect(code, reason);
};
if (t.collaborativeEditing && t.collaborativeEditing.applyChanges) {
t.collaborativeEditing.applyChanges();
t.collaborativeEditing.sendChanges();
} else {
AscCommon.CollaborativeEditing.Apply_Changes();
AscCommon.CollaborativeEditing.Send_Changes();
}
t.setViewModeDisconnect();
t.disconnectOnSave = {code: code, reason: reason};
} else {
t.CoAuthoringApi.disconnect(code, reason);
}
......@@ -745,10 +733,7 @@
}
if (null != errorCode)
{
// Посылаем наверх эвент об отключении от сервера
t.sendEvent('asc_onCoAuthoringDisconnect');
// И переходим в режим просмотра т.к. мы не можем сохранить файл
t.asc_setViewMode(true);
t.setViewModeDisconnect();
t.sendEvent('asc_onError', errorCode, c_oAscError.Level.NoCritical);
}
};
......@@ -1335,6 +1320,9 @@
if (this.isEmbedVersion)
return 0;
if (!this.saveCheck())
return 0;
return new Date().getTime() - this.lastWorkTime;
};
......@@ -1343,6 +1331,19 @@
this.lastWorkTime = new Date().getTime();
};
baseEditorsApi.prototype.setViewModeDisconnect = function()
{
// Посылаем наверх эвент об отключении от сервера
this.sendEvent('asc_onCoAuthoringDisconnect');
// И переходим в режим просмотра т.к. мы не можем сохранить файл
this.asc_setViewMode(true);
};
baseEditorsApi.prototype.saveCheck = function()
{
return false;
};
//----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].baseEditorsApi = baseEditorsApi;
......
......@@ -1869,6 +1869,10 @@ background-repeat: no-repeat;\
{
window["AscDesktopEditor"]["OnSave"]();
}
if (t.disconnectOnSave) {
t.CoAuthoringApi.disconnect(t.disconnectOnSave.code, t.disconnectOnSave.reason);
t.disconnectOnSave = null;
}
};
var CursorInfo = null;
if (true === AscCommon.CollaborativeEditing.Is_Fast())
......@@ -1952,10 +1956,14 @@ background-repeat: no-repeat;\
}
}
};
asc_docs_api.prototype.saveCheck = function() {
return true === this.canSave && !this.isLongAction();
}
asc_docs_api.prototype.asc_Save = function(isAutoSave, isUndoRequest)
{
var res = false;
this.IsUserSave = !isAutoSave;
if (true === this.canSave && !this.isLongAction())
if (this.saveCheck())
{
if (this.asc_isDocumentCanSave() || History.Have_Changes() ||
AscCommon.CollaborativeEditing.Have_OtherChanges() || true === isUndoRequest || this.canUnlockDocument)
......@@ -1967,12 +1975,14 @@ background-repeat: no-repeat;\
{
t.onSaveCallback(e, isUndoRequest);
});
res = true;
}
else if (this.isForceSaveOnUserSave && this.IsUserSave)
{
this.forceSave();
}
}
return res;
};
asc_docs_api.prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{//передаем число соответствующее своему формату.
......
......@@ -1852,6 +1852,10 @@ background-repeat: no-repeat;\
{
window["AscDesktopEditor"]["OnSave"]();
}
if (t.disconnectOnSave) {
t.CoAuthoringApi.disconnect(t.disconnectOnSave.code, t.disconnectOnSave.reason);
t.disconnectOnSave = null;
}
};
var CursorInfo = null;
......@@ -1933,10 +1937,14 @@ background-repeat: no-repeat;\
}
}
};
asc_docs_api.prototype.saveCheck = function() {
return true === this.canSave && !this.isLongAction();
}
asc_docs_api.prototype.asc_Save = function(isAutoSave, isUndoRequest)
{
var res = false;
this.IsUserSave = !isAutoSave;
if (true === this.canSave && !this.isLongAction())
if (this.saveCheck())
{
if (this.asc_isDocumentCanSave() || History.Have_Changes() ||
AscCommon.CollaborativeEditing.Have_OtherChanges() || true === isUndoRequest || this.canUnlockDocument)
......@@ -1948,12 +1956,14 @@ background-repeat: no-repeat;\
{
t.onSaveCallback(e, isUndoRequest);
});
res = true;
}
else if (this.isForceSaveOnUserSave && this.IsUserSave)
{
this.forceSave();
}
}
return res;
};
asc_docs_api.prototype.asc_DownloadOrigin = function(bIsDownloadEvent)
{
......
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