Merge feature/force-save.

This commit is contained in:
Julia Radzhabova 2017-04-11 16:40:01 +03:00
parent 68bf190120
commit d2d9b2b594
7 changed files with 90 additions and 42 deletions

View file

@ -105,15 +105,16 @@
url: 'http://...', url: 'http://...',
text: 'Go to London' text: 'Go to London'
}, },
chat: false, chat: true,
comments: false, comments: true,
zoom: 100, zoom: 100,
compactToolbar: false, compactToolbar: false,
leftMenu: true, leftMenu: true,
rightMenu: true, rightMenu: true,
toolbar: true, toolbar: true,
header: true, header: true,
autosave: true autosave: true,
forcesave: false
}, },
plugins: { plugins: {
autoStartGuid: 'asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}', autoStartGuid: 'asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}',

View file

@ -541,10 +541,13 @@ define([
application.getController('DocumentHolder').getView().focus(); application.getController('DocumentHolder').getView().focus();
if (this.api) { if (this.api) {
var cansave = this.api.asc_isDocumentCanSave(); var cansave = this.api.asc_isDocumentCanSave(),
forcesave = this.appOptions.forcesave;
var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'); var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch');
if (toolbarView.btnSave.isDisabled() !== (!cansave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1)) if (toolbarView.btnSave.isDisabled() !== (!cansave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1))
toolbarView.btnSave.setDisabled(!cansave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1); toolbarView.btnSave.setDisabled(!cansave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1);
if (toolbarView.btnSave.isDisabled() !== (!cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave))
toolbarView.btnSave.setDisabled(!cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave);
} }
}, },
@ -569,29 +572,23 @@ define([
if (action) { if (action) {
this.setLongActionView(action) this.setLongActionView(action)
} else { } else {
if ( id==Asc.c_oAscAsyncAction.Save ) { if (id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) {
if (this._state.fastCoauth && this._state.usersCount>1) {
var me = this; var me = this;
if ( me._state.fastCoauth && me._state.usersCount > 1 ) {
if ( !me._state.timerSave &&
Date.now() - me._state.isSaving < 500 )
{
me._state.timerSave = setTimeout(function () { me._state.timerSave = setTimeout(function () {
me.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('end'); me.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('end');
delete me._state.timerSave; delete me._state.timerSave;
}, 500); }, 500);
} } else
} else { this.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('end');
me.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('end'); } else
}
} else {
this.getApplication().getController('Statusbar').setStatusCaption(''); this.getApplication().getController('Statusbar').setStatusCaption('');
} }
}
action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.BlockInteraction}); action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.BlockInteraction});
action ? this.setLongActionView(action) : this.loadMask && this.loadMask.hide(); action ? this.setLongActionView(action) : this.loadMask && this.loadMask.hide();
if (id==Asc.c_oAscAsyncAction['Save'] && (!this._state.fastCoauth || this._state.usersCount<2)) if ((id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) && (!this._state.fastCoauth || this._state.usersCount<2))
this.synchronizeChanges(); this.synchronizeChanges();
if ( type == Asc.c_oAscAsyncActionType.BlockInteraction && if ( type == Asc.c_oAscAsyncActionType.BlockInteraction &&
@ -603,7 +600,7 @@ define([
}, },
setLongActionView: function(action) { setLongActionView: function(action) {
var title = '', text = ''; var title = '', text = '', force = false;
switch (action.id) { switch (action.id) {
case Asc.c_oAscAsyncAction['Open']: case Asc.c_oAscAsyncAction['Open']:
@ -612,7 +609,9 @@ define([
break; break;
case Asc.c_oAscAsyncAction['Save']: case Asc.c_oAscAsyncAction['Save']:
this._state.isSaving = Date.now(); case Asc.c_oAscAsyncAction['ForceSaveButton']:
clearTimeout(this._state.timerSave);
force = true;
// title = this.saveTitleText; // title = this.saveTitleText;
// text = this.saveTextText; // text = this.saveTextText;
break; break;
@ -697,7 +696,7 @@ define([
if (!this.isShowOpenDialog) if (!this.isShowOpenDialog)
this.loadMask.show(); this.loadMask.show();
} else } else
if ( action.id == Asc.c_oAscAsyncAction.Save ) { if ( action.id == Asc.c_oAscAsyncAction.Save || action.id == Asc.c_oAscAsyncAction['ForceSaveButton']) {
this.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('begin'); this.getApplication().getController('Viewport').getView('Common.Views.Header').setSaveStatus('begin');
} else { } else {
this.getApplication().getController('Statusbar').setStatusCaption(text); this.getApplication().getController('Statusbar').setStatusCaption(text);
@ -894,6 +893,12 @@ define([
me.api.asc_setAutoSaveGap(value); me.api.asc_setAutoSaveGap(value);
if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true
value = Common.localStorage.getItem("de-settings-forcesave");
me.appOptions.forcesave = (value===null) ? me.appOptions.canForcesave : (parseInt(value)==1);
me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave);
}
if (me.needToUpdateVersion) if (me.needToUpdateVersion)
Common.NotificationCenter.trigger('api:disconnect'); Common.NotificationCenter.trigger('api:disconnect');
var timer_sl = setInterval(function(){ var timer_sl = setInterval(function(){
@ -1017,6 +1022,8 @@ define([
this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canPrint = (this.permissions.print !== false);
this.appOptions.canRename = !!this.permissions.rename; this.appOptions.canRename = !!this.permissions.rename;
this.appOptions.buildVersion = params.asc_getBuildVersion(); this.appOptions.buildVersion = params.asc_getBuildVersion();
this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave);
this.appOptions.forcesave = this.appOptions.canForcesave;
if ( this.appOptions.isLightVersion ) { if ( this.appOptions.isLightVersion ) {
this.appOptions.canUseHistory = this.appOptions.canUseHistory =
@ -1418,9 +1425,11 @@ define([
if (window.document.title != title) if (window.document.title != title)
window.document.title = title; window.document.title = title;
if (!this._state.fastCoauth || this._state.usersCount<2 ) if (!this._state.fastCoauth || this._state.usersCount<2 ) {
Common.Gateway.setDocumentModified(isModified); Common.Gateway.setDocumentModified(isModified);
else if ( this._state.startModifyDocument!==undefined && this._state.startModifyDocument === isModified){ if (isModified)
this.getApplication().getController('Statusbar').setStatusCaption('', true);
} else if ( this._state.startModifyDocument!==undefined && this._state.startModifyDocument === isModified){
Common.Gateway.setDocumentModified(isModified); Common.Gateway.setDocumentModified(isModified);
this._state.startModifyDocument = (this._state.startModifyDocument) ? !this._state.startModifyDocument : undefined; this._state.startModifyDocument = (this._state.startModifyDocument) ? !this._state.startModifyDocument : undefined;
} }
@ -1445,9 +1454,10 @@ define([
var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar');
if (toolbarView) { if (toolbarView) {
var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'); var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'),
if (toolbarView.btnSave.isDisabled() !== (!isModified && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1)) forcesave = this.appOptions.forcesave;
toolbarView.btnSave.setDisabled(!isModified && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1); if (toolbarView.btnSave.isDisabled() !== (!isModified && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave))
toolbarView.btnSave.setDisabled(!isModified && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave);
} }
/** coauthoring begin **/ /** coauthoring begin **/
@ -1462,9 +1472,10 @@ define([
toolbarView = toolbarController.getView('Toolbar'); toolbarView = toolbarController.getView('Toolbar');
if (toolbarView && this.api) { if (toolbarView && this.api) {
var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'); var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'),
if (toolbarView.btnSave.isDisabled() !== (!isCanSave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1)) forcesave = this.appOptions.forcesave;
toolbarView.btnSave.setDisabled(!isCanSave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1); if (toolbarView.btnSave.isDisabled() !== (!isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave))
toolbarView.btnSave.setDisabled(!isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave);
} }
}, },
@ -1578,7 +1589,7 @@ define([
if (this._state.hasCollaborativeChanges) return; if (this._state.hasCollaborativeChanges) return;
this._state.hasCollaborativeChanges = true; this._state.hasCollaborativeChanges = true;
if (this.appOptions.isEdit) if (this.appOptions.isEdit)
this.getApplication().getController('Statusbar').setStatusCaption(this.txtNeedSynchronize); this.getApplication().getController('Statusbar').setStatusCaption(this.txtNeedSynchronize, true);
}, },
/** coauthoring end **/ /** coauthoring end **/
@ -1830,6 +1841,11 @@ define([
if (this._state.fastCoauth && !oldval) if (this._state.fastCoauth && !oldval)
this.synchronizeChanges(); this.synchronizeChanges();
} }
if (this.appOptions.canForcesave) {
value = Common.localStorage.getItem("de-settings-forcesave");
this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1);
this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave);
}
}, },
onDocumentName: function(name) { onDocumentName: function(name) {
@ -2129,7 +2145,8 @@ define([
errorSessionToken: 'The connection to the server has been interrupted. Please reload the page.', errorSessionToken: 'The connection to the server has been interrupted. Please reload the page.',
errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.', errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.',
titleServerVersion: 'Editor updated', titleServerVersion: 'Editor updated',
errorServerVersion: 'The editor version has been updated. The page will be reloaded to apply the changes.' errorServerVersion: 'The editor version has been updated. The page will be reloaded to apply the changes.',
textChangesSaved: 'All changes saved'
} }
})(), DE.Controllers.Main || {})) })(), DE.Controllers.Main || {}))
}); });

View file

@ -216,9 +216,16 @@ define([
this.statusbar.reloadLanguages(langs); this.statusbar.reloadLanguages(langs);
}, },
setStatusCaption: function(text) { setStatusCaption: function(text, force, delay) {
if (text.length) if (this.timerCaption && ( ((new Date()) < this.timerCaption) || text.length==0 ) && !force )
this.statusbar.showStatusMessage(text); else return;
this.timerCaption = undefined;
if (text.length) {
this.statusbar.showStatusMessage(text);
if (delay>0)
this.timerCaption = (new Date()).getTime() + delay;
} else
this.statusbar.clearStatusMessage(); this.statusbar.clearStatusMessage();
}, },

View file

@ -850,13 +850,13 @@ define([
if (this.api) { if (this.api) {
var isModified = this.api.asc_isDocumentCanSave(); var isModified = this.api.asc_isDocumentCanSave();
var isSyncButton = $('.btn-icon', this.toolbar.btnSave.cmpEl).hasClass('btn-synch'); var isSyncButton = $('.btn-icon', this.toolbar.btnSave.cmpEl).hasClass('btn-synch');
if (!isModified && !isSyncButton) if (!isModified && !isSyncButton && !this.toolbar.mode.forcesave)
return; return;
this.api.asc_Save(); 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.NotificationCenter.trigger('edit:complete', this.toolbar);

View file

@ -132,6 +132,10 @@ define([
'<td class="left"><label id="fms-lbl-autosave"><%= scope.textAutoSave %></label></td>', '<td class="left"><label id="fms-lbl-autosave"><%= scope.textAutoSave %></label></td>',
'<td class="right"><span id="fms-chb-autosave" /></td>', '<td class="right"><span id="fms-chb-autosave" /></td>',
'</tr>','<tr class="divider autosave"></tr>', '</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 **/ /** coauthoring begin **/
'<tr class="coauth changes">', '<tr class="coauth changes">',
'<td class="left"><label><%= scope.strCoAuthMode %></label></td>', '<td class="left"><label><%= scope.strCoAuthMode %></label></td>',
@ -200,6 +204,11 @@ define([
}, this)); }, this));
this.lblAutosave = $('#fms-lbl-autosave'); this.lblAutosave = $('#fms-lbl-autosave');
this.chForcesave = new Common.UI.CheckBox({
el: $('#fms-chb-forcesave'),
labelText: this.strForcesave
});
this.chAlignGuides = new Common.UI.CheckBox({ this.chAlignGuides = new Common.UI.CheckBox({
el: $('#fms-chb-align-guides'), el: $('#fms-chb-align-guides'),
labelText: this.strAlignGuides labelText: this.strAlignGuides
@ -309,6 +318,7 @@ define([
this.mode = mode; this.mode = mode;
$('tr.edit', this.el)[mode.isEdit?'show':'hide'](); $('tr.edit', this.el)[mode.isEdit?'show':'hide']();
$('tr.autosave', 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) { if (this.mode.isDesktopApp && this.mode.isOffline) {
this.chAutosave.setCaption(this.strAutoRecover); this.chAutosave.setCaption(this.strAutoRecover);
this.lblAutosave.text(this.textAutoRecover); this.lblAutosave.text(this.textAutoRecover);
@ -363,6 +373,12 @@ define([
value = 0; value = 0;
this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); 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"); value = Common.localStorage.getItem("de-settings-spellcheck");
this.chSpell.setValue(value===null || parseInt(value) == 1); 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-fontrender", this.cmbFontRender.getValue());
Common.localStorage.setItem("de-settings-unit", this.cmbUnit.getValue()); Common.localStorage.setItem("de-settings-unit", this.cmbUnit.getValue());
Common.localStorage.setItem("de-settings-autosave", this.chAutosave.isChecked() ? 1 : 0); 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-spellcheck", this.chSpell.isChecked() ? 1 : 0);
Common.localStorage.setItem("de-settings-showsnaplines", this.chAlignGuides.isChecked() ? 1 : 0); Common.localStorage.setItem("de-settings-showsnaplines", this.chAlignGuides.isChecked() ? 1 : 0);
Common.localStorage.save(); Common.localStorage.save();
@ -443,7 +461,9 @@ define([
strAutoRecover: 'Turn on autorecover', strAutoRecover: 'Turn on autorecover',
txtInch: 'Inch', txtInch: 'Inch',
txtFitPage: 'Fit to Page', 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.Settings || {}));
DE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({ DE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({

View file

@ -2374,7 +2374,7 @@ define([
if (this.synchTooltip) if (this.synchTooltip)
this.synchTooltip.hide(); this.synchTooltip.hide();
this.btnSave.updateHint(this.btnSaveTip); this.btnSave.updateHint(this.btnSaveTip);
this.btnSave.setDisabled(true); this.btnSave.setDisabled(!this.mode.forcesave);
this._state.hasCollaborativeChanges = false; this._state.hasCollaborativeChanges = false;
} }
} }

View file

@ -317,6 +317,7 @@
"DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.",
"DE.Controllers.Main.titleServerVersion": "Editor updated", "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.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.textHasChanges": "New changes have been tracked",
"DE.Controllers.Statusbar.textTrackChanges": "The document is opened with the Track Changes mode enabled", "DE.Controllers.Statusbar.textTrackChanges": "The document is opened with the Track Changes mode enabled",
"DE.Controllers.Statusbar.zoomText": "Zoom {0}%", "DE.Controllers.Statusbar.zoomText": "Zoom {0}%",
@ -971,6 +972,8 @@
"DE.Views.FileMenuPanels.Settings.txtPt": "Point", "DE.Views.FileMenuPanels.Settings.txtPt": "Point",
"DE.Views.FileMenuPanels.Settings.txtSpellCheck": "Spell Checking", "DE.Views.FileMenuPanels.Settings.txtSpellCheck": "Spell Checking",
"DE.Views.FileMenuPanels.Settings.txtWin": "as Windows", "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.textBottomCenter": "Bottom Center",
"DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom Left", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom Left",
"DE.Views.HeaderFooterSettings.textBottomRight": "Bottom Right", "DE.Views.HeaderFooterSettings.textBottomRight": "Bottom Right",