Commit 6f777edf authored by konovalovsergey's avatar konovalovsergey

for forceSave button

parent 4f2d6498
......@@ -313,13 +313,17 @@ var editor;
};
spreadsheet_api.prototype.asc_Save = function (isAutoSave) {
this.IsUserSave = !isAutoSave;
if (!this.canSave || this.isChartEditor || c_oAscAdvancedOptionsAction.None !== this.advancedOptionsAction ||
this.isLongAction() ||
!(this.asc_isDocumentCanSave() || this.collaborativeEditing.haveOtherChanges() || this.canUnlockDocument)) {
this.isLongAction()) {
return;
} else if (!(this.asc_isDocumentCanSave() || this.collaborativeEditing.haveOtherChanges() || this.canUnlockDocument)) {
if (this.isForceSaveOnUserSave && this.IsUserSave) {
this.forceSave();
}
return;
}
this.IsUserSave = !isAutoSave;
if (this.IsUserSave) {
this.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
}
......@@ -1450,6 +1454,9 @@ var editor;
this.CoAuthoringApi.onUnSaveLock = function() {
t.CoAuthoringApi.onUnSaveLock = null;
if (t.isForceSaveOnUserSave && t.IsUserSave) {
t.forceSave();
}
if (t.collaborativeEditing.getCollaborativeEditing()) {
// Шлем update для toolbar-а, т.к. когда select в lock ячейке нужно заблокировать toolbar
......@@ -3293,6 +3300,8 @@ var editor;
prot["asc_LoadEmptyDocument"] = prot.asc_LoadEmptyDocument;
prot["asc_DownloadAs"] = prot.asc_DownloadAs;
prot["asc_Save"] = prot.asc_Save;
prot["forceSave"] = prot.forceSave;
prot["asc_setIsForceSaveOnUserSave"] = prot.asc_setIsForceSaveOnUserSave;
prot["asc_Print"] = prot.asc_Print;
prot["asc_Resize"] = prot.asc_Resize;
prot["asc_Copy"] = prot.asc_Copy;
......
......@@ -139,6 +139,7 @@
this.canSave = true; // Флаг нужен чтобы не происходило сохранение пока не завершится предыдущее сохранение
this.IsUserSave = false; // Флаг, контролирующий сохранение было сделано пользователем или нет (по умолчанию - нет)
this.isForceSaveOnUserSave = false;
// Version History
this.VersionHistory = null; // Объект, который отвечает за точку в списке версий
......@@ -487,6 +488,10 @@
{
this.CoAuthoringApi.forceSave()
};
baseEditorsApi.prototype.asc_setIsForceSaveOnUserSave = function(val)
{
this.isForceSaveOnUserSave = val;
};
// Функция автосохранения. Переопределяется во всех редакторах
baseEditorsApi.prototype._autoSave = function () {
};
......
......@@ -865,7 +865,11 @@
};
DocsCoApi.prototype.forceSave = function() {
this._send({'type': 'forceSaveStart'});
var newForceSaveButtonTime = Math.max(this.lastOtherSaveTime, this.lastOwnSaveTime);
if (this._lastForceSaveButtonTime < newForceSaveButtonTime) {
this._lastForceSaveButtonTime = newForceSaveButtonTime;
this._send({'type': 'forceSaveStart'});
}
};
DocsCoApi.prototype.openDocument = function(data) {
......@@ -971,7 +975,7 @@
}, timeout);
}
};
DocsCoApi.prototype._onForceSaveStart = function(data) {
if (data['code'] === c_oAscServerCommandErrors.NoError) {
this._lastForceSaveButtonTime = data['time'];
......@@ -982,9 +986,10 @@
DocsCoApi.prototype._onForceSave = function(data) {
if (c_oAscForceSaveTypes.Button === data['type']) {
if (this._lastForceSaveButtonTime == data['time']) {
this.onForceSave({type: c_oAscForceSaveTypes.Button, saved:true});
this.onForceSave({type: c_oAscForceSaveTypes.Button, saved: true});
}
} else if(c_oAscForceSaveTypes.Timeout === data['type']) {
}
if (null != this._lastForceSaveTime) {
this._lastForceSaveTime = data['time'];
this._checkLastForceSave();
}
......@@ -992,13 +997,13 @@
DocsCoApi.prototype._checkLastForceSave = function(data) {
if (null != this._lastForceSaveTime) {
var newState = false;
if((-1 == this.lastOtherSaveTime || this.lastOtherSaveTime <= this._lastForceSaveTime) &&
if ((-1 == this.lastOtherSaveTime || this.lastOtherSaveTime <= this._lastForceSaveTime) &&
(-1 == this.lastOwnSaveTime || this.lastOwnSaveTime <= this._lastForceSaveTime)) {
newState = true;
}
if(newState != this._allChangesSaved){
}
if (newState != this._allChangesSaved) {
this._allChangesSaved = newState;
this.onForceSave({type: c_oAscForceSaveTypes.Timeout, saved:this._allChangesSaved});
this.onForceSave({type: c_oAscForceSaveTypes.Timeout, saved: this._allChangesSaved});
}
}
};
......
......@@ -1847,7 +1847,9 @@ background-repeat: no-repeat;\
this.CoAuthoringApi.onUnSaveLock = function()
{
t.CoAuthoringApi.onUnSaveLock = null;
if (t.isForceSaveOnUserSave && t.IsUserSave) {
t.forceSave();
}
// Выставляем, что документ не модифицирован
t.CheckChangedDocument();
t.canSave = true;
......@@ -1947,16 +1949,23 @@ background-repeat: no-repeat;\
asc_docs_api.prototype.asc_Save = function(isAutoSave, isUndoRequest)
{
this.IsUserSave = !isAutoSave;
if (true === this.canSave && !this.isLongAction() && (this.asc_isDocumentCanSave() || History.Have_Changes() ||
AscCommon.CollaborativeEditing.Have_OtherChanges() || true === isUndoRequest || this.canUnlockDocument))
if (true === this.canSave && !this.isLongAction())
{
this.canSave = false;
if (this.asc_isDocumentCanSave() || History.Have_Changes() ||
AscCommon.CollaborativeEditing.Have_OtherChanges() || true === isUndoRequest || this.canUnlockDocument)
{
this.canSave = false;
var t = this;
this.CoAuthoringApi.askSaveChanges(function(e)
var t = this;
this.CoAuthoringApi.askSaveChanges(function(e)
{
t.onSaveCallback(e, isUndoRequest);
});
}
else if (this.isForceSaveOnUserSave && this.IsUserSave)
{
t.onSaveCallback(e, isUndoRequest);
});
this.forceSave();
}
}
};
asc_docs_api.prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
......@@ -6497,6 +6506,8 @@ background-repeat: no-repeat;\
asc_docs_api.prototype['Paste'] = asc_docs_api.prototype.Paste;
asc_docs_api.prototype['Share'] = asc_docs_api.prototype.Share;
asc_docs_api.prototype['asc_Save'] = asc_docs_api.prototype.asc_Save;
asc_docs_api.prototype['forceSave'] = asc_docs_api.prototype.forceSave;
asc_docs_api.prototype['asc_setIsForceSaveOnUserSave'] = asc_docs_api.prototype.asc_setIsForceSaveOnUserSave;
asc_docs_api.prototype['asc_DownloadAs'] = asc_docs_api.prototype.asc_DownloadAs;
asc_docs_api.prototype['Resize'] = asc_docs_api.prototype.Resize;
asc_docs_api.prototype['AddURL'] = asc_docs_api.prototype.AddURL;
......
......@@ -1818,6 +1818,9 @@ background-repeat: no-repeat;\
this.CoAuthoringApi.onUnSaveLock = function()
{
t.CoAuthoringApi.onUnSaveLock = null;
if (t.isForceSaveOnUserSave && t.IsUserSave) {
t.forceSave();
}
// Выставляем, что документ не модифицирован
t.CheckChangedDocument();
......@@ -1916,16 +1919,23 @@ background-repeat: no-repeat;\
asc_docs_api.prototype.asc_Save = function(isAutoSave, isUndoRequest)
{
this.IsUserSave = !isAutoSave;
if (true === this.canSave && !this.isLongAction() && (this.asc_isDocumentCanSave() || History.Have_Changes() ||
AscCommon.CollaborativeEditing.Have_OtherChanges() || true === isUndoRequest || this.canUnlockDocument))
if (true === this.canSave && !this.isLongAction())
{
this.canSave = false;
if (this.asc_isDocumentCanSave() || History.Have_Changes() ||
AscCommon.CollaborativeEditing.Have_OtherChanges() || true === isUndoRequest || this.canUnlockDocument)
{
this.canSave = false;
var t = this;
this.CoAuthoringApi.askSaveChanges(function(e)
var t = this;
this.CoAuthoringApi.askSaveChanges(function(e)
{
t.onSaveCallback(e, isUndoRequest);
});
}
else if (this.isForceSaveOnUserSave && this.IsUserSave)
{
t.onSaveCallback(e, isUndoRequest);
});
this.forceSave();
}
}
};
asc_docs_api.prototype.asc_DownloadOrigin = function(bIsDownloadEvent)
......@@ -7540,6 +7550,8 @@ background-repeat: no-repeat;\
asc_docs_api.prototype['Paste'] = asc_docs_api.prototype.Paste;
asc_docs_api.prototype['Share'] = asc_docs_api.prototype.Share;
asc_docs_api.prototype['asc_Save'] = asc_docs_api.prototype.asc_Save;
asc_docs_api.prototype['forceSave'] = asc_docs_api.prototype.forceSave;
asc_docs_api.prototype['asc_setIsForceSaveOnUserSave'] = asc_docs_api.prototype.asc_setIsForceSaveOnUserSave;
asc_docs_api.prototype['asc_DownloadAs'] = asc_docs_api.prototype.asc_DownloadAs;
asc_docs_api.prototype['asc_DownloadAsMailMerge'] = asc_docs_api.prototype.asc_DownloadAsMailMerge;
asc_docs_api.prototype['asc_DownloadOrigin'] = asc_docs_api.prototype.asc_DownloadOrigin;
......
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