Commit 5461be6b authored by Julia Radzhabova's avatar Julia Radzhabova Committed by GitHub

Merge pull request #64 from ONLYOFFICE/feature/force-save

Feature/force save
parents 2eb46fa2 e2ef004b
......@@ -105,15 +105,16 @@
url: 'http://...',
text: 'Go to London'
},
chat: false,
comments: false,
chat: true,
comments: true,
zoom: 100,
compactToolbar: false,
leftMenu: true,
rightMenu: true,
toolbar: true,
header: true,
autosave: true
autosave: true,
forcesave: false
},
plugins: {
autoStartGuid: 'asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}',
......
......@@ -149,9 +149,16 @@ define([
this.statusbar.reloadLanguages(langs);
},
setStatusCaption: function(text) {
if (text.length)
this.statusbar.showStatusMessage(text); else
setStatusCaption: function(text, force, delay) {
if (this.timerCaption && ( ((new Date()) < this.timerCaption) || text.length==0 ) && !force )
return;
this.timerCaption = undefined;
if (text.length) {
this.statusbar.showStatusMessage(text);
if (delay>0)
this.timerCaption = (new Date()).getTime() + delay;
} else
this.statusbar.clearStatusMessage();
},
......
......@@ -854,13 +854,13 @@ define([
if (this.api) {
var isModified = this.api.asc_isDocumentCanSave();
var isSyncButton = $('.btn-icon', this.toolbar.btnSave.cmpEl).hasClass('btn-synch');
if (!isModified && !isSyncButton)
if (!isModified && !isSyncButton && !this.toolbar.mode.forcesave)
return;
this.api.asc_Save();
}
this.toolbar.btnSave.setDisabled(true);
this.toolbar.btnSave.setDisabled(!this.toolbar.mode.forcesave);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
......
......@@ -132,7 +132,11 @@ define([
'<td class="left"><label id="fms-lbl-autosave"><%= scope.textAutoSave %></label></td>',
'<td class="right"><span id="fms-chb-autosave" /></td>',
'</tr>','<tr class="divider autosave"></tr>',
/** coauthoring begin **/
'<tr class="forcesave">',
'<td class="left"><label id="fms-lbl-forcesave"><%= scope.textForceSave %></label></td>',
'<td class="right"><span id="fms-chb-forcesave" /></td>',
'</tr>','<tr class="divider forcesave"></tr>',
/** coauthoring begin **/
'<tr class="coauth changes">',
'<td class="left"><label><%= scope.strCoAuthMode %></label></td>',
'<td class="right">',
......@@ -199,7 +203,12 @@ define([
}
}, this));
this.lblAutosave = $('#fms-lbl-autosave');
this.chForcesave = new Common.UI.CheckBox({
el: $('#fms-chb-forcesave'),
labelText: this.strForcesave
});
this.chAlignGuides = new Common.UI.CheckBox({
el: $('#fms-chb-align-guides'),
labelText: this.strAlignGuides
......@@ -309,6 +318,7 @@ define([
this.mode = mode;
$('tr.edit', this.el)[mode.isEdit?'show':'hide']();
$('tr.autosave', this.el)[mode.isEdit ? 'show' : 'hide']();
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
if (this.mode.isDesktopApp && this.mode.isOffline) {
this.chAutosave.setCaption(this.strAutoRecover);
this.lblAutosave.text(this.textAutoRecover);
......@@ -363,6 +373,12 @@ define([
value = 0;
this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1));
if (this.mode.canForcesave) {
value = Common.localStorage.getItem("de-settings-forcesave");
value = (value === null) ? this.mode.canForcesave : (parseInt(value) == 1);
this.chForcesave.setValue(value);
}
value = Common.localStorage.getItem("de-settings-spellcheck");
this.chSpell.setValue(value===null || parseInt(value) == 1);
......@@ -383,6 +399,8 @@ define([
Common.localStorage.setItem("de-settings-fontrender", this.cmbFontRender.getValue());
Common.localStorage.setItem("de-settings-unit", this.cmbUnit.getValue());
Common.localStorage.setItem("de-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
if (this.mode.canForcesave)
Common.localStorage.setItem("de-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
Common.localStorage.setItem("de-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
Common.localStorage.setItem("de-settings-showsnaplines", this.chAlignGuides.isChecked() ? 1 : 0);
Common.localStorage.save();
......@@ -443,7 +461,9 @@ define([
strAutoRecover: 'Turn on autorecover',
txtInch: 'Inch',
txtFitPage: 'Fit to Page',
txtFitWidth: 'Fit to Width'
txtFitWidth: 'Fit to Width',
textForceSave: 'Save to Server',
strForcesave: 'Always save to server (otherwise save to server on document close)'
}, DE.Views.FileMenuPanels.Settings || {}));
DE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
......
......@@ -1740,7 +1740,7 @@ define([
if (this.synchTooltip)
this.synchTooltip.hide();
this.btnSave.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(true);
this.btnSave.setDisabled(!this.mode.forcesave);
this._state.hasCollaborativeChanges = false;
}
}
......
......@@ -300,6 +300,7 @@
"DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.",
"DE.Controllers.Main.titleServerVersion": "Editor updated",
"DE.Controllers.Main.errorServerVersion": "The editor version has been updated. The page will be reloaded to apply the changes.",
"DE.Controllers.Main.textChangesSaved": "All changes saved",
"DE.Controllers.Statusbar.textHasChanges": "New changes have been tracked",
"DE.Controllers.Statusbar.textTrackChanges": "The document is opened with the Track Changes mode enabled",
"DE.Controllers.Statusbar.zoomText": "Zoom {0}%",
......@@ -953,6 +954,8 @@
"DE.Views.FileMenuPanels.Settings.txtPt": "Point",
"DE.Views.FileMenuPanels.Settings.txtSpellCheck": "Spell Checking",
"DE.Views.FileMenuPanels.Settings.txtWin": "as Windows",
"DE.Views.FileMenuPanels.Settings.textForceSave": "Save to Server",
"DE.Views.FileMenuPanels.Settings.strForcesave": "Always save to server (otherwise save to server on document close)",
"DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom Center",
"DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom Left",
"DE.Views.HeaderFooterSettings.textBottomRight": "Bottom Right",
......
......@@ -177,9 +177,16 @@ define([
}
},
setStatusCaption: function(text) {
if (text.length)
this.statusbar.showStatusMessage(text); else
setStatusCaption: function(text, force, delay) {
if (this.timerCaption && ( ((new Date()) < this.timerCaption) || text.length==0 ) && !force )
return;
this.timerCaption = undefined;
if (text.length) {
this.statusbar.showStatusMessage(text);
if (delay>0)
this.timerCaption = (new Date()).getTime() + delay;
} else
this.statusbar.clearStatusMessage();
},
......
......@@ -878,7 +878,7 @@ define([
this.api.asc_Save();
}
this.toolbar.btnSave.setDisabled(true);
this.toolbar.btnSave.setDisabled(!this.toolbar.mode.forcesave);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('Save');
......
......@@ -122,6 +122,10 @@ define([
'<td class="left"><label id="fms-lbl-autosave"><%= scope.textAutoSave %></label></td>',
'<td class="right"><span id="fms-chb-autosave" /></td>',
'</tr>','<tr class="divider autosave"></tr>',
'<tr class="forcesave">',
'<td class="left"><label id="fms-lbl-forcesave"><%= scope.textForceSave %></label></td>',
'<td class="right"><span id="fms-chb-forcesave" /></td>',
'</tr>','<tr class="divider forcesave"></tr>',
/** coauthoring begin **/
'<tr class="coauth changes">',
'<td class="left"><label><%= scope.strCoAuthMode %></label></td>',
......@@ -212,6 +216,11 @@ define([
}, this));
this.lblAutosave = $('#fms-lbl-autosave');
this.chForcesave = new Common.UI.CheckBox({
el: $('#fms-chb-forcesave'),
labelText: this.strForcesave
});
this.chAlignGuides = new Common.UI.CheckBox({
el: $('#fms-chb-align-guides'),
labelText: this.strAlignGuides
......@@ -259,6 +268,7 @@ define([
this.chAutosave.setCaption(this.strAutoRecover);
this.lblAutosave.text(this.textAutoRecover);
}
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
/** coauthoring begin **/
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide']();
/** coauthoring end **/
......@@ -295,6 +305,12 @@ define([
value = 0;
this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1));
if (this.mode.canForcesave) {
value = Common.localStorage.getItem("pe-settings-forcesave");
value = (value === null) ? this.mode.canForcesave : (parseInt(value) == 1);
this.chForcesave.setValue(value);
}
value = Common.localStorage.getItem("pe-settings-showsnaplines");
this.chAlignGuides.setValue(value===null || parseInt(value) == 1);
},
......@@ -309,6 +325,8 @@ define([
/** coauthoring end **/
Common.localStorage.setItem("pe-settings-unit", this.cmbUnit.getValue());
Common.localStorage.setItem("pe-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
if (this.mode.canForcesave)
Common.localStorage.setItem("pe-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
Common.localStorage.setItem("pe-settings-showsnaplines", this.chAlignGuides.isChecked() ? 1 : 0);
Common.localStorage.save();
......@@ -345,7 +363,9 @@ define([
textAutoRecover: 'Autorecover',
strAutoRecover: 'Turn on autorecover',
txtInch: 'Inch',
txtFitWidth: 'Fit to Width'
txtFitWidth: 'Fit to Width',
textForceSave: 'Save to Server',
strForcesave: 'Always save to server (otherwise save to server on document close)'
}, PE.Views.FileMenuPanels.Settings || {}));
PE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
......
......@@ -1540,7 +1540,7 @@ define([
if (this.synchTooltip)
this.synchTooltip.hide();
this.btnSave.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(true);
this.btnSave.setDisabled(!this.mode.forcesave);
this._state.hasCollaborativeChanges = false;
}
}
......
......@@ -247,6 +247,7 @@
"PE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.",
"PE.Controllers.Main.titleServerVersion": "Editor updated",
"PE.Controllers.Main.errorServerVersion": "The editor version has been updated. The page will be reloaded to apply the changes.",
"PE.Controllers.Main.textChangesSaved": "All changes saved",
"PE.Controllers.Statusbar.zoomText": "Zoom {0}%",
"PE.Controllers.Toolbar.confirmAddFontName": "The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the system fonts, the saved font will be used when it is available.<br>Do you want to continue?",
"PE.Controllers.Toolbar.textAccent": "Accents",
......@@ -818,6 +819,8 @@
"PE.Views.FileMenuPanels.Settings.txtInput": "Alternate Input",
"PE.Views.FileMenuPanels.Settings.txtLast": "View Last",
"PE.Views.FileMenuPanels.Settings.txtPt": "Point",
"PE.Views.FileMenuPanels.Settings.textForceSave": "Save to Server",
"PE.Views.FileMenuPanels.Settings.strForcesave": "Always save to server (otherwise save to server on document close)",
"PE.Views.HyperlinkSettingsDialog.cancelButtonText": "Cancel",
"PE.Views.HyperlinkSettingsDialog.okButtonText": "OK",
"PE.Views.HyperlinkSettingsDialog.strDisplay": "Display",
......
......@@ -447,6 +447,12 @@ define([
title = this.saveTitleText;
break;
case Asc.c_oAscAsyncAction.ForceSaveTimeout:
break;
case Asc.c_oAscAsyncAction.ForceSaveButton:
break;
case Asc.c_oAscAsyncAction.LoadDocumentFonts:
title = this.loadFontsTitleText;
break;
......@@ -656,6 +662,12 @@ define([
}
me.api.asc_setAutoSaveGap(value);
if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true
value = Common.localStorage.getItem("sse-settings-forcesave");
me.appOptions.forcesave = (value === null) ? me.appOptions.canForcesave : (parseInt(value) == 1);
me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave);
}
if (me.needToUpdateVersion) {
Common.NotificationCenter.trigger('api:disconnect');
toolbarController.onApiCoAuthoringDisconnect();
......@@ -813,6 +825,9 @@ define([
this.appOptions.isEdit = (this.appOptions.canLicense || this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && this.permissions.edit !== false && this.editorConfig.mode !== 'view';
this.appOptions.canDownload = !this.appOptions.nativeApp && (this.permissions.download !== false);
this.appOptions.canPrint = (this.permissions.print !== false);
this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) &&
(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave);
this.appOptions.forcesave = this.appOptions.canForcesave;
this._state.licenseWarning = !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view';
......@@ -1333,18 +1348,20 @@ define([
Common.Gateway.setDocumentModified(change);
if (this.toolbarView && this.api) {
var isSyncButton = $('.btn-icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch');
var isSyncButton = $('.btn-icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'),
forcesave = this.appOptions.forcesave;
var cansave = this.api.asc_isDocumentCanSave();
if (this.toolbarView.btnSave.isDisabled() !== (!cansave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1))
this.toolbarView.btnSave.setDisabled(!cansave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1);
if (this.toolbarView.btnSave.isDisabled() !== (!cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave))
this.toolbarView.btnSave.setDisabled(!cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave);
}
},
onDocumentCanSaveChanged: function (isCanSave) {
if (this.toolbarView) {
var isSyncButton = $('.btn-icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch');
if (this.toolbarView.btnSave.isDisabled() !== (!isCanSave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1))
this.toolbarView.btnSave.setDisabled(!isCanSave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1);
var isSyncButton = $('.btn-icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'),
forcesave = this.appOptions.forcesave;
if (this.toolbarView.btnSave.isDisabled() !== (!isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave))
this.toolbarView.btnSave.setDisabled(!isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave);
}
},
......@@ -1796,6 +1813,11 @@ define([
if (this._state.fastCoauth && !oldval)
this.toolbarView.synchronizeChanges();
}
if (this.appOptions.canForcesave) {
value = Common.localStorage.getItem("sse-settings-forcesave");
this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1);
this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave);
}
},
onDocumentName: function(name) {
......
......@@ -447,6 +447,10 @@ define([
'<td class="left"><label id="fms-lbl-autosave"><%= scope.textAutoSave %></label></td>',
'<td class="right"><span id="fms-chb-autosave" /></td>',
'</tr>','<tr class="divider autosave"></tr>',
'<tr class="forcesave">',
'<td class="left"><label id="fms-lbl-forcesave"><%= scope.textForceSave %></label></td>',
'<td class="right"><span id="fms-chb-forcesave" /></td>',
'</tr>','<tr class="divider forcesave"></tr>',
'<tr class="coauth changes">',
'<td class="left"><label><%= scope.strCoAuthMode %></label></td>',
'<td class="right">',
......@@ -561,7 +565,12 @@ define([
}
}, this));
this.lblAutosave = $('#fms-lbl-autosave');
this.chForcesave = new Common.UI.CheckBox({
el: $('#fms-chb-forcesave'),
labelText: this.strForcesave
});
this.cmbUnit = new Common.UI.ComboBox({
el : $('#fms-cmb-unit'),
style : 'width: 160px;',
......@@ -653,6 +662,7 @@ define([
this.chAutosave.setCaption(this.strAutoRecover);
this.lblAutosave.text(this.textAutoRecover);
}
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
$('tr.coauth', this.el)[mode.canCoAuthoring && mode.isEdit ? 'show' : 'hide']();
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring? 'show' : 'hide']();
},
......@@ -696,6 +706,12 @@ define([
value = 0;
this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1));
if (this.mode.canForcesave) {
value = Common.localStorage.getItem("sse-settings-forcesave");
value = (value === null) ? this.mode.canForcesave : (parseInt(value) == 1);
this.chForcesave.setValue(value);
}
value = Common.localStorage.getItem("sse-settings-func-locale");
if (value===null)
value = ((this.mode.lang) ? this.mode.lang : 'en').toLowerCase();
......@@ -741,6 +757,8 @@ define([
Common.localStorage.setItem("sse-settings-fontrender", this.cmbFontRender.getValue());
Common.localStorage.setItem("sse-settings-unit", this.cmbUnit.getValue());
Common.localStorage.setItem("sse-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
if (this.mode.canForcesave)
Common.localStorage.setItem("sse-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
Common.localStorage.setItem("sse-settings-func-locale", this.cmbFuncLocale.getValue());
if (this.cmbRegSettings.getSelectedRecord())
Common.localStorage.setItem("sse-settings-reg-settings", this.cmbRegSettings.getValue());
......@@ -808,7 +826,9 @@ define([
strStrict: 'Strict',
textAutoRecover: 'Autorecover',
strAutoRecover: 'Turn on autorecover',
txtInch: 'Inch'
txtInch: 'Inch',
textForceSave: 'Save to Server',
strForcesave: 'Always save to server (otherwise save to server on document close)'
}, SSE.Views.FileMenuPanels.MainSettingsGeneral || {}));
SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
......
......@@ -1739,7 +1739,7 @@ define([
if (this.synchTooltip)
this.synchTooltip.hide();
this.btnSave.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(true);
this.btnSave.setDisabled(!this.mode.forcesave);
this._state.hasCollaborativeChanges = false;
}
}
......
......@@ -1075,6 +1075,8 @@
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtPl": "Polish",
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtRu": "Russian",
"SSE.Views.FileMenuPanels.MainSettingsGeneral.txtWin": "as Windows",
"SSE.Views.FileMenuPanels.MainSettingsGeneral.textForceSave": "Save to Server",
"SSE.Views.FileMenuPanels.MainSettingsGeneral.strForcesave": "Always save to server (otherwise save to server on document close)",
"SSE.Views.FileMenuPanels.Settings.txtGeneral": "General",
"SSE.Views.FileMenuPanels.Settings.txtPageSettings": "Page Settings",
"SSE.Views.FormatSettingsDialog.textCancel": "Cancel",
......
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