From 553b2daffc254d2e470fda521614f8261f0a46c7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 1 Apr 2021 13:36:08 +0300 Subject: [PATCH] [DE] Add api parameters for co-authoring mode --- apps/api/documents/api.js | 4 +- apps/common/main/lib/view/ReviewChanges.js | 20 +-- .../main/app/controller/LeftMenu.js | 20 ++- .../main/app/controller/Main.js | 138 +++++++++++++----- .../main/app/view/FileMenuPanels.js | 25 +++- 5 files changed, 147 insertions(+), 60 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 80b7618ad..39e6a4f14 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -161,7 +161,9 @@ plugins: true // can run plugins in document macrosMode: 'warn' // warn about automatic macros, 'enable', 'disable', 'warn', trackChanges: undefined // true/false - open editor with track changes mode on/off, - hideRulers: false, // hide or show rulers on first loading (presentation or document editor) + hideRulers: false, // hide or show rulers on first loading (presentation or document editor), + modeCoAuthoring: , 'fast' (default) or 'strict'. if 'fast' and 'autosave'=false -> set 'autosave'=true + changeCoAuthoring: true // can change co-authoring mode }, plugins: { autostart: ['asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}'], diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index 63ae72f2f..335a53873 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -219,6 +219,8 @@ define([ Common.UI.BaseView.prototype.initialize.call(this, options); this.appConfig = options.mode; + var filter = Common.localStorage.getKeysFilter(); + this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; if ( this.appConfig.canReview ) { this.btnAccept = new Common.UI.Button({ @@ -318,7 +320,7 @@ define([ }); } - if (this.appConfig.isEdit && !this.appConfig.isOffline && this.appConfig.canCoAuthoring) { + if (this.appConfig.isEdit && !this.appConfig.isOffline && this.appConfig.canCoAuthoring && Common.Utils.InternalSettings.get(this.appPrefix + "settings-change-coauthmode")) { this.btnCoAuthMode = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'toolbar__icon btn-ic-coedit', @@ -356,9 +358,6 @@ define([ }); } - var filter = Common.localStorage.getKeysFilter(); - this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; - Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, @@ -502,12 +501,13 @@ define([ })); me.btnCoAuthMode.updateHint(me.tipCoAuthMode); - var value = Common.localStorage.getItem(me.appPrefix + "settings-coauthmode"); - if (value===null && !Common.localStorage.itemExists(me.appPrefix + "settings-autosave") && - config.customization && config.customization.autosave===false) { - value = 0; // use customization.autosave only when de-settings-coauthmode and de-settings-autosave are null - } - me.turnCoAuthMode((value===null || parseInt(value) == 1) && !(config.isDesktopApp && config.isOffline) && config.canCoAuthoring); + // var value = Common.localStorage.getItem(me.appPrefix + "settings-coauthmode"); + // if (value===null && !Common.localStorage.itemExists(me.appPrefix + "settings-autosave") && + // config.customization && config.customization.autosave===false) { + // value = 0; // use customization.autosave only when de-settings-coauthmode and de-settings-autosave are null + // } + // me.turnCoAuthMode((value===null || parseInt(value) == 1) && !(config.isDesktopApp && config.isOffline) && config.canCoAuthoring); + me.turnCoAuthMode(Common.Utils.InternalSettings.get(me.appPrefix + "settings-coauthmode")); } if (me.btnCommentRemove) { diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index a32244d23..7a5665a52 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -444,11 +444,15 @@ define([ Common.Utils.InternalSettings.set("de-settings-inputmode", value); this.api.SetTextBoxInputMode(value); + var canChangeCoAuth = Common.Utils.InternalSettings.get("de-settings-change-coauthmode"); + var fast_coauth = Common.Utils.InternalSettings.get("de-settings-coauthmode"); /** coauthoring begin **/ - if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) { - var fast_coauth = Common.localStorage.getBool("de-settings-coauthmode", true); - Common.Utils.InternalSettings.set("de-settings-coauthmode", fast_coauth); - this.api.asc_SetFastCollaborative(fast_coauth); + if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring ) { + if (canChangeCoAuth) { + fast_coauth = Common.localStorage.getBool("de-settings-coauthmode", true); + Common.Utils.InternalSettings.set("de-settings-coauthmode", fast_coauth); + this.api.asc_SetFastCollaborative(fast_coauth); + } value = Common.localStorage.getItem((fast_coauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict"); Common.Utils.InternalSettings.set((fast_coauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value); @@ -484,9 +488,11 @@ define([ } if (this.mode.isEdit) { - value = parseInt(Common.localStorage.getItem("de-settings-autosave")); - Common.Utils.InternalSettings.set("de-settings-autosave", value); - this.api.asc_setAutoSaveGap(value); + if (canChangeCoAuth || !fast_coauth) {// can change co-auth. mode or for strict mode + value = parseInt(Common.localStorage.getItem("de-settings-autosave")); + Common.Utils.InternalSettings.set("de-settings-autosave", value); + this.api.asc_setAutoSaveGap(value); + } value = Common.localStorage.getBool("de-settings-spellcheck", true); Common.Utils.InternalSettings.set("de-settings-spellcheck", value); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index f90cd8460..5bb78c11d 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1039,32 +1039,56 @@ define([ me.api.SetTextBoxInputMode(value); /** coauthoring begin **/ - if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) { - value = Common.localStorage.getItem("de-settings-coauthmode"); - if (value===null && !Common.localStorage.itemExists("de-settings-autosave") && - me.appOptions.customization && me.appOptions.customization.autosave===false) { - value = 0; // use customization.autosave only when de-settings-coauthmode and de-settings-autosave are null - } - me._state.fastCoauth = (value===null || parseInt(value) == 1); - me.api.asc_SetFastCollaborative(me._state.fastCoauth); + me._state.fastCoauth = Common.Utils.InternalSettings.get("de-settings-coauthmode"); + me.api.asc_SetFastCollaborative(me._state.fastCoauth); - value = Common.localStorage.getItem((me._state.fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict"); - if (value == null) value = me._state.fastCoauth ? 'none' : 'last'; - me.api.SetCollaborativeMarksShowType(value == 'all' ? Asc.c_oAscCollaborativeMarksShowType.All : - (value == 'none' ? Asc.c_oAscCollaborativeMarksShowType.None : Asc.c_oAscCollaborativeMarksShowType.LastChanges)); - Common.Utils.InternalSettings.set((me._state.fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value); - } else if (!me.appOptions.isEdit && me.appOptions.isRestrictedEdit) { - me._state.fastCoauth = true; - me.api.asc_SetFastCollaborative(me._state.fastCoauth); - me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); - me.api.asc_setAutoSaveGap(1); - Common.Utils.InternalSettings.set("de-settings-autosave", 1); - } else { - me._state.fastCoauth = false; - me.api.asc_SetFastCollaborative(me._state.fastCoauth); - me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); + value = Common.Utils.InternalSettings.get((me._state.fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict"); + switch(value) { + case 'all': value = Asc.c_oAscCollaborativeMarksShowType.All; break; + case 'none': value = Asc.c_oAscCollaborativeMarksShowType.None; break; + case 'last': value = Asc.c_oAscCollaborativeMarksShowType.LastChanges; break; + default: value = (me._state.fastCoauth) ? Asc.c_oAscCollaborativeMarksShowType.None : Asc.c_oAscCollaborativeMarksShowType.LastChanges; } - Common.Utils.InternalSettings.set("de-settings-coauthmode", me._state.fastCoauth); + me.api.SetCollaborativeMarksShowType(value); + me.api.asc_setAutoSaveGap(Common.Utils.InternalSettings.get("de-settings-autosave")); + + // var changeCoAuth = false; + // if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) { + // changeCoAuth = !(me.appOptions.customization && me.appOptions.customization.changeCoAuthoring===false); + // if (!changeCoAuth) { //can't change co-auth. mode. Use customization.modeCoAuthoring or 'fast' by default + // me._state.fastCoauth = !(me.appOptions.customization && me.appOptions.customization.modeCoAuthoring==='strict'); + // } else { + // value = Common.localStorage.getItem("de-settings-coauthmode"); + // if (value===null) { + // value = (me.appOptions.customization && me.appOptions.customization.modeCoAuthoring!==undefined) ? (me.appOptions.customization.modeCoAuthoring==='strict' ? 0 : 1) : null; + // if (value===null && !Common.localStorage.itemExists("de-settings-autosave") && + // me.appOptions.customization && me.appOptions.customization.autosave===false) { + // value = 0; // use customization.autosave only when de-settings-coauthmode and de-settings-autosave are null + // } + // } + // me._state.fastCoauth = (value===null || parseInt(value) == 1); + // } + // me.api.asc_SetFastCollaborative(me._state.fastCoauth); + // + // value = Common.localStorage.getItem((me._state.fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict"); + // if (value == null) value = me._state.fastCoauth ? 'none' : 'last'; + // me.api.SetCollaborativeMarksShowType(value == 'all' ? Asc.c_oAscCollaborativeMarksShowType.All : + // (value == 'none' ? Asc.c_oAscCollaborativeMarksShowType.None : Asc.c_oAscCollaborativeMarksShowType.LastChanges)); + // Common.Utils.InternalSettings.set((me._state.fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value); + // } else if (!me.appOptions.isEdit && me.appOptions.isRestrictedEdit) { + // me._state.fastCoauth = true; + // me.api.asc_SetFastCollaborative(me._state.fastCoauth); + // me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); + // me.api.asc_setAutoSaveGap(1); + // Common.Utils.InternalSettings.set("de-settings-autosave", 1); + // } else { + // me._state.fastCoauth = false; + // me.api.asc_SetFastCollaborative(me._state.fastCoauth); + // me.api.SetCollaborativeMarksShowType(Asc.c_oAscCollaborativeMarksShowType.None); + // } + // Common.Utils.InternalSettings.set("de-settings-coauthmode", me._state.fastCoauth); + // Common.Utils.InternalSettings.set("de-settings-change-coauthmode", changeCoAuth); + me.api.asc_SetPerformContentControlActionByClick(me.appOptions.isRestrictedEdit && me.appOptions.canFillForms); /** coauthoring end **/ @@ -1103,12 +1127,12 @@ define([ documentHolderController.getView().setApi(me.api).on('editcomplete', _.bind(me.onEditComplete, me)); if (me.appOptions.isEdit) { - value = Common.localStorage.getItem("de-settings-autosave"); - if (value===null && me.appOptions.customization && me.appOptions.customization.autosave===false) - value = 0; - value = (!me._state.fastCoauth && value!==null) ? parseInt(value) : (me.appOptions.canCoAuthoring ? 1 : 0); - Common.Utils.InternalSettings.set("de-settings-autosave", value); - me.api.asc_setAutoSaveGap(value); + // value = Common.localStorage.getItem("de-settings-autosave"); + // if (value===null && me.appOptions.customization && me.appOptions.customization.autosave===false) + // value = 0; + // value = (!me._state.fastCoauth && value!==null) ? parseInt(value) : (me.appOptions.canCoAuthoring ? 1 : 0); + // Common.Utils.InternalSettings.set("de-settings-autosave", value); + // me.api.asc_setAutoSaveGap(value); if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true me.appOptions.forcesave = Common.localStorage.getBool("de-settings-forcesave", me.appOptions.canForcesave); @@ -1378,6 +1402,7 @@ define([ Common.NotificationCenter.on('comments:cleardummy', _.bind(this.onClearDummyComment, this)); Common.NotificationCenter.on('comments:showdummy', _.bind(this.onShowDummyComment, this)); + this.loadCoAuthSettings(); this.applyModeCommonElements(); this.applyModeEditorElements(); @@ -1394,6 +1419,49 @@ define([ this.api.asc_LoadDocument(); }, + loadCoAuthSettings: function() { + var changeCoAuth = false, + fastCoauth = true, + autosave = 1, + value; + if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) { + changeCoAuth = !(this.appOptions.customization && this.appOptions.customization.changeCoAuthoring===false); + if (!changeCoAuth) { //can't change co-auth. mode. Use customization.modeCoAuthoring or 'fast' by default + fastCoauth = !(this.appOptions.customization && this.appOptions.customization.modeCoAuthoring==='strict'); + } else { + value = Common.localStorage.getItem("de-settings-coauthmode"); + if (value===null) { + value = (this.appOptions.customization && this.appOptions.customization.modeCoAuthoring!==undefined) ? (this.appOptions.customization.modeCoAuthoring==='strict' ? 0 : 1) : null; + if (value===null && !Common.localStorage.itemExists("de-settings-autosave") && + this.appOptions.customization && this.appOptions.customization.autosave===false) { + value = 0; // use customization.autosave only when de-settings-coauthmode and de-settings-autosave are null + } + } + fastCoauth = (value===null || parseInt(value) == 1); + } + + value = Common.localStorage.getItem((fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict"); + if (value == null) value = fastCoauth ? 'none' : 'last'; + Common.Utils.InternalSettings.set((fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value); + } else if (!this.appOptions.isEdit && this.appOptions.isRestrictedEdit) { + fastCoauth = true; + } else { + fastCoauth = false; + autosave = 0; + } + + if (this.appOptions.isEdit) { + value = Common.localStorage.getItem("de-settings-autosave"); + if (value === null && this.appOptions.customization && this.appOptions.customization.autosave === false) + value = 0; + autosave = (!fastCoauth && value !== null) ? parseInt(value) : (this.appOptions.canCoAuthoring ? 1 : 0); + } + + Common.Utils.InternalSettings.set("de-settings-coauthmode", fastCoauth); + Common.Utils.InternalSettings.set("de-settings-change-coauthmode", changeCoAuth); + Common.Utils.InternalSettings.set("de-settings-autosave", autosave); + }, + applyModeCommonElements: function() { window.editor_elements_prepared = true; @@ -2228,12 +2296,13 @@ define([ onTryUndoInFastCollaborative: function() { if (!Common.localStorage.getBool("de-hide-try-undoredo")) + var canChange = Common.Utils.InternalSettings.get("de-settings-change-coauthmode"); Common.UI.info({ width: 500, - msg: this.textTryUndoRedo, + msg: canChange ? this.textTryUndoRedo : this.textTryUndoRedoWarn, iconCls: 'info', - buttons: ['custom', 'cancel'], - primary: 'custom', + buttons: canChange ? ['custom', 'cancel'] : ['ok'], + primary: canChange ? 'custom' : 'ok', customButtonText: this.textStrict, dontshow: true, callback: _.bind(function(btn, dontshow){ @@ -2877,7 +2946,8 @@ define([ textGuest: 'Guest', errorSubmit: 'Submit failed.', txtClickToLoad: 'Click to load image', - leavePageTextOnClose: 'All unsaved changes in this document will be lost.
Click \'Cancel\' then \'Save\' to save them. Click \'OK\' to discard all the unsaved changes.' + leavePageTextOnClose: 'All unsaved changes in this document will be lost.
Click \'Cancel\' then \'Save\' to save them. Click \'OK\' to discard all the unsaved changes.', + textTryUndoRedoWarn: 'The Undo/Redo functions are disabled for the Fast co-editing mode.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index d2be4f186..e22610c6f 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -233,16 +233,16 @@ define([ '', '','', /** coauthoring begin **/ - '', + '', '', '', '
', '
', - '','', - '', + '','', + '', '', '', - '','', + '','', /** coauthoring end **/ '', '', @@ -521,8 +521,12 @@ define([ setMode: function(mode) { this.mode = mode; + + var canChangeCoAuth = Common.Utils.InternalSettings.get("de-settings-change-coauthmode"); + var fast_coauth = Common.Utils.InternalSettings.get("de-settings-coauthmode"); + $('tr.edit', this.el)[mode.isEdit?'show':'hide'](); - $('tr.autosave', this.el)[mode.isEdit ? 'show' : 'hide'](); + $('tr.autosave', this.el)[mode.isEdit && (canChangeCoAuth || !fast_coauth) ? 'show' : 'hide'](); $('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide'](); if (this.mode.isDesktopApp && this.mode.isOffline) { this.chAutosave.setCaption(this.strAutoRecover); @@ -530,7 +534,8 @@ define([ } /** coauthoring begin **/ $('tr.coauth', this.el)[mode.isEdit && mode.canCoAuthoring ? 'show' : 'hide'](); - $('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide'](); + $('tr.coauth.changes-mode', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring && canChangeCoAuth ? 'show' : 'hide'](); + $('tr.coauth.changes-show', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide'](); $('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide'](); /** coauthoring end **/ @@ -607,6 +612,9 @@ define([ applySettings: function() { Common.UI.Themes.setTheme(this.cmbTheme.getValue()); + var canChangeCoAuth = Common.Utils.InternalSettings.get("de-settings-change-coauthmode"); + var fast_coauth = Common.Utils.InternalSettings.get("de-settings-coauthmode"); + Common.localStorage.setItem("de-settings-inputmode", this.chInputMode.isChecked() ? 1 : 0); Common.localStorage.setItem("de-settings-zoom", this.cmbZoom.getValue()); Common.Utils.InternalSettings.set("de-settings-zoom", Common.localStorage.getItem("de-settings-zoom")); @@ -615,7 +623,7 @@ define([ Common.localStorage.setItem("de-settings-livecomment", this.chLiveComment.isChecked() ? 1 : 0); Common.localStorage.setItem("de-settings-resolvedcomment", this.chResolvedComment.isChecked() ? 1 : 0); if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) { - Common.localStorage.setItem("de-settings-coauthmode", this.cmbCoAuthMode.getValue()); + canChangeCoAuth && Common.localStorage.setItem("de-settings-coauthmode", this.cmbCoAuthMode.getValue()); Common.localStorage.setItem(this.cmbCoAuthMode.getValue() ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", this.cmbShowChanges.getValue()); } /** coauthoring end **/ @@ -623,7 +631,8 @@ define([ var item = this.cmbFontRender.store.findWhere({value: 'custom'}); Common.localStorage.setItem("de-settings-cachemode", item && !item.get('checked') ? 0 : 1); Common.localStorage.setItem("de-settings-unit", this.cmbUnit.getValue()); - Common.localStorage.setItem("de-settings-autosave", this.chAutosave.isChecked() ? 1 : 0); + if (canChangeCoAuth || !fast_coauth) + 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);