From f658f6806d1a3b45f6fe452a0ec8b8f135480248 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 1 Mar 2017 14:58:40 +0300 Subject: [PATCH 1/3] created new feature --- apps/api/documents/api.js | 7 ++- .../main/app/controller/Main.js | 63 +++++++++++-------- .../main/app/controller/Statusbar.js | 13 +++- .../main/app/controller/Toolbar.js | 4 +- apps/documenteditor/main/app/view/Toolbar.js | 2 +- apps/documenteditor/main/locale/en.json | 1 + .../main/app/controller/Main.js | 39 +++++++----- .../main/app/controller/Statusbar.js | 13 +++- apps/presentationeditor/main/locale/en.json | 1 + 9 files changed, 90 insertions(+), 53 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 7853efe00..8408248e3 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -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}', diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 840009f9c..b45770c4e 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -253,12 +253,15 @@ define([ this.appOptions.canBack = this.editorConfig.nativeApp !== true && this.appOptions.canBackToFolder === true; this.appOptions.canPlugins = false; this.plugins = this.editorConfig.plugins; + this.appOptions.forcesave = (typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.forcesave; this.getApplication() .getController('Viewport') .getView('Common.Views.Header') .setCanBack(this.appOptions.canBackToFolder === true); + this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); + if (this.editorConfig.lang) this.api.asc_setLocale(this.editorConfig.lang); @@ -542,10 +545,11 @@ define([ application.getController('DocumentHolder').getView('DocumentHolder').focus(); 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'); - 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); + 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); } }, @@ -570,16 +574,19 @@ define([ if (action) { this.setLongActionView(action) } else { - if (this._state.fastCoauth && this._state.usersCount>1 && id==Asc.c_oAscAsyncAction['Save']) { - var me = this; - if (me._state.timerSave===undefined) - me._state.timerSave = setInterval(function(){ - if ((new Date()) - me._state.isSaving>500) { - clearInterval(me._state.timerSave); - me.getApplication().getController('Statusbar').setStatusCaption(''); - me._state.timerSave = undefined; - } - }, 500); + if (id==Asc.c_oAscAsyncAction['Save']) { + if (this._state.fastCoauth && this._state.usersCount>1) { + var me = this; + if (me._state.timerSave===undefined) + me._state.timerSave = setInterval(function(){ + if ((new Date()) - me._state.isSaving>500) { + clearInterval(me._state.timerSave); + me.getApplication().getController('Statusbar').setStatusCaption(me.textChangesSaved, false, 3000); + me._state.timerSave = undefined; + } + }, 500); + } else + this.getApplication().getController('Statusbar').setStatusCaption(this.textChangesSaved, false, 3000); } else this.getApplication().getController('Statusbar').setStatusCaption(''); } @@ -599,7 +606,7 @@ define([ }, setLongActionView: function(action) { - var title = '', text = ''; + var title = '', text = '', force = false; switch (action.id) { case Asc.c_oAscAsyncAction['Open']: @@ -609,6 +616,7 @@ define([ case Asc.c_oAscAsyncAction['Save']: this._state.isSaving = new Date(); + force = true; title = this.saveTitleText; text = this.saveTextText; break; @@ -694,7 +702,7 @@ define([ this.loadMask.show(); } else { - this.getApplication().getController('Statusbar').setStatusCaption(text); + this.getApplication().getController('Statusbar').setStatusCaption(text, force); } }, @@ -1399,9 +1407,11 @@ define([ if (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); - 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); this._state.startModifyDocument = (this._state.startModifyDocument) ? !this._state.startModifyDocument : undefined; } @@ -1423,9 +1433,10 @@ define([ var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); if (toolbarView) { - 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)) - toolbarView.btnSave.setDisabled(!isModified && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1); + var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), + forcesave = this.appOptions.forcesave; + 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 **/ @@ -1440,9 +1451,10 @@ define([ toolbarView = toolbarController.getView('Toolbar'); if (toolbarView && this.api) { - 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)) - toolbarView.btnSave.setDisabled(!isCanSave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1); + var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), + forcesave = this.appOptions.forcesave; + 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); } }, @@ -1552,7 +1564,7 @@ define([ if (this._state.hasCollaborativeChanges) return; this._state.hasCollaborativeChanges = true; if (this.appOptions.isEdit) - this.getApplication().getController('Statusbar').setStatusCaption(this.txtNeedSynchronize); + this.getApplication().getController('Statusbar').setStatusCaption(this.txtNeedSynchronize, true); }, /** coauthoring end **/ @@ -2127,7 +2139,8 @@ define([ 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.
Please contact your Document Server administrator.', 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 || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Statusbar.js b/apps/documenteditor/main/app/controller/Statusbar.js index ac5233d75..9712cf9e0 100644 --- a/apps/documenteditor/main/app/controller/Statusbar.js +++ b/apps/documenteditor/main/app/controller/Statusbar.js @@ -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(); }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index f10305bc2..ca0e903d1 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -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); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 474884217..dd4325f5b 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -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; } } diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 1660ba6ec..b4c98a50e 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -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}%", diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 0d6b83d26..43a61ccc4 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -384,16 +384,19 @@ define([ if (action) { this.setLongActionView(action) } else { - if (this._state.fastCoauth && this._state.usersCount>1 && id==Asc.c_oAscAsyncAction['Save']) { - var me = this; - if (me._state.timerSave===undefined) - me._state.timerSave = setInterval(function(){ - if ((new Date()) - me._state.isSaving>500) { - clearInterval(me._state.timerSave); - me.getApplication().getController('Statusbar').setStatusCaption(''); - me._state.timerSave = undefined; - } - }, 500); + if (id==Asc.c_oAscAsyncAction['Save']) { + if (this._state.fastCoauth && this._state.usersCount>1) { + var me = this; + if (me._state.timerSave===undefined) + me._state.timerSave = setInterval(function(){ + if ((new Date()) - me._state.isSaving>500) { + clearInterval(me._state.timerSave); + me.getApplication().getController('Statusbar').setStatusCaption(me.textChangesSaved, false, 3000); + me._state.timerSave = undefined; + } + }, 500); + } else + this.getApplication().getController('Statusbar').setStatusCaption(this.textChangesSaved, false, 3000); } else this.getApplication().getController('Statusbar').setStatusCaption(''); } @@ -411,7 +414,7 @@ define([ }, setLongActionView: function(action) { - var title = '', text = ''; + var title = '', text = '', force = false; switch (action.id) { case Asc.c_oAscAsyncAction['Open']: @@ -421,6 +424,7 @@ define([ case Asc.c_oAscAsyncAction['Save']: this._state.isSaving = new Date(); + force = true; title = this.saveTitleText; text = this.saveTextText; break; @@ -496,7 +500,7 @@ define([ this.loadMask.show(); } else { - this.getApplication().getController('Statusbar').setStatusCaption(text); + this.getApplication().getController('Statusbar').setStatusCaption(text, force); } }, @@ -1157,9 +1161,11 @@ define([ if (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); - 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); this._state.startModifyDocument = (this._state.startModifyDocument) ? !this._state.startModifyDocument : undefined; } @@ -1302,7 +1308,7 @@ define([ if (this._state.hasCollaborativeChanges) return; this._state.hasCollaborativeChanges = true; if (this.appOptions.isEdit) - this.getApplication().getController('Statusbar').setStatusCaption(this.txtNeedSynchronize); + this.getApplication().getController('Statusbar').setStatusCaption(this.txtNeedSynchronize, true); }, /** coauthoring end **/ @@ -1917,7 +1923,8 @@ define([ 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.
Please contact your Document Server administrator.', 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' } })(), PE.Controllers.Main || {})) }); diff --git a/apps/presentationeditor/main/app/controller/Statusbar.js b/apps/presentationeditor/main/app/controller/Statusbar.js index 7f0fc3cb2..ae5e6480a 100644 --- a/apps/presentationeditor/main/app/controller/Statusbar.js +++ b/apps/presentationeditor/main/app/controller/Statusbar.js @@ -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(); }, diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 8a6464467..4c012d14b 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -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.
The text style will be displayed using one of the system fonts, the saved font will be used when it is available.
Do you want to continue?", "PE.Controllers.Toolbar.textAccent": "Accents", From c1056ad945b5deba4b817bda31f807cc90998ab3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 6 Mar 2017 20:50:39 +0300 Subject: [PATCH 2/3] Added option for saving to server in advanced settings. --- .../main/app/controller/Main.js | 21 +++++++--- .../main/app/view/FileMenuPanels.js | 22 +++++++++-- apps/documenteditor/main/locale/en.json | 2 + .../main/app/controller/Main.js | 39 +++++++++++++------ .../main/app/controller/Toolbar.js | 2 +- .../main/app/view/FileMenuPanels.js | 18 ++++++++- .../main/app/view/Toolbar.js | 2 +- apps/presentationeditor/main/locale/en.json | 2 + .../main/app/controller/Main.js | 30 +++++++++++--- .../main/app/view/FileMenuPanels.js | 20 +++++++++- .../main/app/view/Toolbar.js | 2 +- apps/spreadsheeteditor/main/locale/en.json | 2 + 12 files changed, 131 insertions(+), 31 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index b45770c4e..c2877a6a3 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -253,15 +253,12 @@ define([ this.appOptions.canBack = this.editorConfig.nativeApp !== true && this.appOptions.canBackToFolder === true; this.appOptions.canPlugins = false; this.plugins = this.editorConfig.plugins; - this.appOptions.forcesave = (typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.forcesave; this.getApplication() .getController('Viewport') .getView('Common.Views.Header') .setCanBack(this.appOptions.canBackToFolder === true); - this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); - if (this.editorConfig.lang) this.api.asc_setLocale(this.editorConfig.lang); @@ -574,7 +571,7 @@ define([ if (action) { this.setLongActionView(action) } 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; if (me._state.timerSave===undefined) @@ -594,7 +591,7 @@ define([ action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.BlockInteraction}); 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(); if ( type == Asc.c_oAscAsyncActionType.BlockInteraction && @@ -615,12 +612,16 @@ define([ break; case Asc.c_oAscAsyncAction['Save']: + case Asc.c_oAscAsyncAction['ForceSaveButton']: this._state.isSaving = new Date(); force = true; title = this.saveTitleText; text = this.saveTextText; break; + case Asc.c_oAscAsyncAction['ForceSaveTimeout']: + break; + case Asc.c_oAscAsyncAction['LoadDocumentFonts']: title = this.loadFontsTitleText; text = this.loadFontsTextText; @@ -894,6 +895,10 @@ define([ me.api.asc_setAutoSaveGap(value); + value = Common.localStorage.getItem("de-settings-forcesave"); + me.appOptions.forcesave = (value===null) ? me.appOptions.forcesave : (parseInt(value)==1); + me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); + if (me.needToUpdateVersion) Common.NotificationCenter.trigger('api:disconnect'); var timer_sl = setInterval(function(){ @@ -1017,6 +1022,7 @@ define([ this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canRename = !!this.permissions.rename; this.appOptions.buildVersion = params.asc_getBuildVersion(); + this.appOptions.forcesave = this.appOptions.isEdit && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType); this.appOptions.canDownloadOrigin = !this.appOptions.nativeApp && this.permissions.download !== false && (type && typeof type[1] === 'string'); @@ -1814,6 +1820,11 @@ define([ if (this._state.fastCoauth && !oldval) this.synchronizeChanges(); } + if (this.appOptions.isEdit) { + value = Common.localStorage.getItem("de-settings-forcesave"); + this.appOptions.forcesave = (value===null) ? (typeof (this.appOptions.customization) == 'object' && this.appOptions.customization.forcesave) : (parseInt(value)==1); + this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); + } }, onDocumentName: function(name) { diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 2cfc3d83f..5989c22dc 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -132,7 +132,11 @@ define([ '', '', '','', - /** coauthoring begin **/ + '', + '', + '', + '','', + /** coauthoring begin **/ '', '', '', @@ -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 @@ -363,6 +372,10 @@ define([ value = 0; this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); + value = Common.localStorage.getItem("de-settings-forcesave"); + value = (value===null) ? (this.mode.customization && this.mode.customization.forcesave) : (parseInt(value)==1); + this.chForcesave.setValue(value); + value = Common.localStorage.getItem("de-settings-spellcheck"); this.chSpell.setValue(value===null || parseInt(value) == 1); @@ -383,6 +396,7 @@ 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); + 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 +457,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({ diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index b4c98a50e..1e9179eec 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -954,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", diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 43a61ccc4..a5cdbc921 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -356,10 +356,11 @@ define([ application.getController('DocumentHolder').getView('DocumentHolder').focus(); if (this.api && this.api.asc_isDocumentCanSave) { - 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'); - 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); + 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); } }, @@ -384,7 +385,7 @@ define([ if (action) { this.setLongActionView(action) } 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; if (me._state.timerSave===undefined) @@ -404,7 +405,7 @@ define([ action = this.stackLongActions.get({type: Asc.c_oAscAsyncActionType.BlockInteraction}); 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(); if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && this.dontCloseDummyComment )) { @@ -423,12 +424,16 @@ define([ break; case Asc.c_oAscAsyncAction['Save']: + case Asc.c_oAscAsyncAction['ForceSaveButton']: this._state.isSaving = new Date(); force = true; title = this.saveTitleText; text = this.saveTextText; break; + case Asc.c_oAscAsyncAction['ForceSaveTimeout']: + break; + case Asc.c_oAscAsyncAction['LoadDocumentFonts']: title = this.loadFontsTitleText; text = this.loadFontsTextText; @@ -670,6 +675,10 @@ define([ value = (!me._state.fastCoauth && value!==null) ? parseInt(value) : (me.appOptions.canCoAuthoring ? 1 : 0); me.api.asc_setAutoSaveGap(value); + value = Common.localStorage.getItem("pe-settings-forcesave"); + me.appOptions.forcesave = (value===null) ? me.appOptions.forcesave : (parseInt(value)==1); + me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); + if (me.needToUpdateVersion) Common.NotificationCenter.trigger('api:disconnect'); var timer_sl = setInterval(function(){ @@ -782,6 +791,7 @@ define([ this.appOptions.canChat = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canRename = !!this.permissions.rename; + this.appOptions.forcesave = this.appOptions.isEdit && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; @@ -1189,9 +1199,10 @@ define([ var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); if (toolbarView) { - 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)) - toolbarView.btnSave.setDisabled(!isModified && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1); + var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), + forcesave = this.appOptions.forcesave; + 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); } }, onDocumentCanSaveChanged: function (isCanSave) { @@ -1199,9 +1210,10 @@ define([ toolbarController = application.getController('Toolbar'), toolbarView = toolbarController.getView('Toolbar'); if (toolbarView) { - 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)) - toolbarView.btnSave.setDisabled(!isCanSave && !isSyncButton || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1); + var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), + forcesave = this.appOptions.forcesave; + 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); } }, @@ -1547,6 +1559,11 @@ define([ if (this._state.fastCoauth && !oldval) this.synchronizeChanges(); } + if (this.appOptions.isEdit) { + value = Common.localStorage.getItem("pe-settings-forcesave"); + this.appOptions.forcesave = (value===null) ? (typeof (this.appOptions.customization) == 'object' && this.appOptions.customization.forcesave) : (parseInt(value)==1); + this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); + } }, onDocumentName: function(name) { diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index ddbdce910..6a9781d4d 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -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'); diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 93230fe4d..3f55065cb 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -122,6 +122,10 @@ define([ '', '', '','', + '', + '', + '', + '','', /** coauthoring begin **/ '', '', @@ -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 @@ -295,6 +304,10 @@ define([ value = 0; this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); + value = Common.localStorage.getItem("pe-settings-forcesave"); + value = (value===null) ? (this.mode.customization && this.mode.customization.forcesave) : (parseInt(value)==1); + this.chForcesave.setValue(value); + value = Common.localStorage.getItem("pe-settings-showsnaplines"); this.chAlignGuides.setValue(value===null || parseInt(value) == 1); }, @@ -309,6 +322,7 @@ define([ /** coauthoring end **/ Common.localStorage.setItem("pe-settings-unit", this.cmbUnit.getValue()); Common.localStorage.setItem("pe-settings-autosave", this.chAutosave.isChecked() ? 1 : 0); + 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 +359,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({ diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index cca5eb07e..4fd7f1e7f 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -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; } } diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 4c012d14b..55da1e8cd 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -819,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", diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index decb5cfed..25c7c11ff 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -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,10 @@ define([ } me.api.asc_setAutoSaveGap(value); + value = Common.localStorage.getItem("sse-settings-forcesave"); + me.appOptions.forcesave = (value===null) ? me.appOptions.forcesave : (parseInt(value)==1); + me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); + if (me.needToUpdateVersion) { Common.NotificationCenter.trigger('api:disconnect'); toolbarController.onApiCoAuthoringDisconnect(); @@ -813,6 +823,7 @@ 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.forcesave = this.appOptions.isEdit && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); this._state.licenseWarning = !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; @@ -1333,18 +1344,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); } }, @@ -1792,6 +1805,11 @@ define([ if (this._state.fastCoauth && !oldval) this.toolbarView.synchronizeChanges(); } + if (this.appOptions.isEdit) { + value = Common.localStorage.getItem("sse-settings-forcesave"); + this.appOptions.forcesave = (value===null) ? (typeof (this.appOptions.customization) == 'object' && this.appOptions.customization.forcesave) : (parseInt(value)==1); + this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); + } }, onDocumentName: function(name) { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index c591b883d..1c10dec07 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -447,6 +447,10 @@ define([ '', '', '','', + '', + '', + '', + '','', '', '', '', @@ -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;', @@ -696,6 +705,10 @@ define([ value = 0; this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); + value = Common.localStorage.getItem("sse-settings-forcesave"); + value = (value===null) ? (this.mode.customization && this.mode.customization.forcesave) : (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 +754,7 @@ 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); + 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 +822,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({ diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index df41701e4..a9d418818 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -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; } } diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 43d1c5d9e..a20866839 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1058,6 +1058,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", From 44c6f2fc4bbc6ee240d10dc6d374c48b7ae2b915 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 14 Mar 2017 12:09:29 +0300 Subject: [PATCH 3/3] Show option for saving changes to the server only when customization->forcesave is true. --- apps/documenteditor/main/app/controller/Main.js | 15 +++++++++------ .../main/app/view/FileMenuPanels.js | 16 ++++++++++------ .../main/app/controller/Main.js | 15 +++++++++------ .../main/app/view/FileMenuPanels.js | 16 ++++++++++------ .../main/app/controller/Main.js | 16 ++++++++++------ .../main/app/view/FileMenuPanels.js | 16 ++++++++++------ 6 files changed, 58 insertions(+), 36 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index c2877a6a3..086f62de7 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -895,9 +895,11 @@ define([ me.api.asc_setAutoSaveGap(value); - value = Common.localStorage.getItem("de-settings-forcesave"); - me.appOptions.forcesave = (value===null) ? me.appOptions.forcesave : (parseInt(value)==1); - me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); + 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) Common.NotificationCenter.trigger('api:disconnect'); @@ -1022,7 +1024,8 @@ define([ this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canRename = !!this.permissions.rename; this.appOptions.buildVersion = params.asc_getBuildVersion(); - this.appOptions.forcesave = this.appOptions.isEdit && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); + this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); + this.appOptions.forcesave = this.appOptions.canForcesave; var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType); this.appOptions.canDownloadOrigin = !this.appOptions.nativeApp && this.permissions.download !== false && (type && typeof type[1] === 'string'); @@ -1820,9 +1823,9 @@ define([ if (this._state.fastCoauth && !oldval) this.synchronizeChanges(); } - if (this.appOptions.isEdit) { + if (this.appOptions.canForcesave) { value = Common.localStorage.getItem("de-settings-forcesave"); - this.appOptions.forcesave = (value===null) ? (typeof (this.appOptions.customization) == 'object' && this.appOptions.customization.forcesave) : (parseInt(value)==1); + this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1); this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); } }, diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 5989c22dc..382d65efb 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -132,10 +132,10 @@ define([ '', '', '','', - '', + '', '', '', - '','', + '','', /** coauthoring begin **/ '', '', @@ -318,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); @@ -372,9 +373,11 @@ define([ value = 0; this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); - value = Common.localStorage.getItem("de-settings-forcesave"); - value = (value===null) ? (this.mode.customization && this.mode.customization.forcesave) : (parseInt(value)==1); - this.chForcesave.setValue(value); + 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); @@ -396,7 +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); - Common.localStorage.setItem("de-settings-forcesave", this.chForcesave.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(); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index a5cdbc921..d320a912b 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -675,9 +675,11 @@ define([ value = (!me._state.fastCoauth && value!==null) ? parseInt(value) : (me.appOptions.canCoAuthoring ? 1 : 0); me.api.asc_setAutoSaveGap(value); - value = Common.localStorage.getItem("pe-settings-forcesave"); - me.appOptions.forcesave = (value===null) ? me.appOptions.forcesave : (parseInt(value)==1); - me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); + if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true + value = Common.localStorage.getItem("pe-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'); @@ -791,7 +793,8 @@ define([ this.appOptions.canChat = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit) && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canRename = !!this.permissions.rename; - this.appOptions.forcesave = this.appOptions.isEdit && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); + this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); + this.appOptions.forcesave = this.appOptions.canForcesave; this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; @@ -1559,9 +1562,9 @@ define([ if (this._state.fastCoauth && !oldval) this.synchronizeChanges(); } - if (this.appOptions.isEdit) { + if (this.appOptions.canForcesave) { value = Common.localStorage.getItem("pe-settings-forcesave"); - this.appOptions.forcesave = (value===null) ? (typeof (this.appOptions.customization) == 'object' && this.appOptions.customization.forcesave) : (parseInt(value)==1); + this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1); this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); } }, diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 3f55065cb..d7c5df045 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -122,10 +122,10 @@ define([ '', '', '','', - '', + '', '', '', - '','', + '','', /** coauthoring begin **/ '', '', @@ -268,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 **/ @@ -304,9 +305,11 @@ define([ value = 0; this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); - value = Common.localStorage.getItem("pe-settings-forcesave"); - value = (value===null) ? (this.mode.customization && this.mode.customization.forcesave) : (parseInt(value)==1); - this.chForcesave.setValue(value); + 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); @@ -322,7 +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); - Common.localStorage.setItem("pe-settings-forcesave", this.chForcesave.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(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 25c7c11ff..aa1fcd8cb 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -662,9 +662,11 @@ define([ } me.api.asc_setAutoSaveGap(value); - value = Common.localStorage.getItem("sse-settings-forcesave"); - me.appOptions.forcesave = (value===null) ? me.appOptions.forcesave : (parseInt(value)==1); - me.api.asc_setIsForceSaveOnUserSave(me.appOptions.forcesave); + 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'); @@ -823,7 +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.forcesave = this.appOptions.isEdit && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && (typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.forcesave); + 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'; @@ -1805,9 +1809,9 @@ define([ if (this._state.fastCoauth && !oldval) this.toolbarView.synchronizeChanges(); } - if (this.appOptions.isEdit) { + if (this.appOptions.canForcesave) { value = Common.localStorage.getItem("sse-settings-forcesave"); - this.appOptions.forcesave = (value===null) ? (typeof (this.appOptions.customization) == 'object' && this.appOptions.customization.forcesave) : (parseInt(value)==1); + this.appOptions.forcesave = (value===null) ? this.appOptions.canForcesave : (parseInt(value)==1); this.api.asc_setIsForceSaveOnUserSave(this.appOptions.forcesave); } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 1c10dec07..cc62ba7f8 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -447,10 +447,10 @@ define([ '', '', '','', - '', + '', '', '', - '','', + '','', '', '', '', @@ -662,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'](); }, @@ -705,9 +706,11 @@ define([ value = 0; this.chAutosave.setValue(fast_coauth || (value===null ? this.mode.canCoAuthoring : parseInt(value) == 1)); - value = Common.localStorage.getItem("sse-settings-forcesave"); - value = (value===null) ? (this.mode.customization && this.mode.customization.forcesave) : (parseInt(value)==1); - this.chForcesave.setValue(value); + 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) @@ -754,7 +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); - Common.localStorage.setItem("sse-settings-forcesave", this.chForcesave.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());