[DE] Add api parameters for co-authoring mode

This commit is contained in:
Julia Radzhabova 2021-04-01 13:36:08 +03:00
parent 788bea18ca
commit 553b2daffc
5 changed files with 147 additions and 60 deletions

View file

@ -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: <coauthoring mode>, '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}'],

View file

@ -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) {

View file

@ -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);

View file

@ -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.<br> 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.<br> 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 || {}))
});

View file

@ -233,16 +233,16 @@ define([
'<td class="right"><span id="fms-chb-forcesave"></span></td>',
'</tr>','<tr class="divider forcesave"></tr>',
/** coauthoring begin **/
'<tr class="coauth changes">',
'<tr class="coauth changes-mode">',
'<td class="left"><label><%= scope.strCoAuthMode %></label></td>',
'<td class="right">',
'<div><div id="fms-cmb-coauth-mode" style="display: inline-block; margin-right: 15px;vertical-align: middle;"></div>',
'<label id="fms-lbl-coauth-mode" style="vertical-align: middle;"><%= scope.strCoAuthModeDescFast %></label></div></td>',
'</tr>','<tr class="divider coauth changes"></tr>',
'<tr class="coauth changes">',
'</tr>','<tr class="divider coauth changes-mode"></tr>',
'<tr class="coauth changes-show">',
'<td class="left"><label><%= scope.strShowChanges %></label></td>',
'<td class="right"><span id="fms-cmb-show-changes"></span></td>',
'</tr>','<tr class="divider coauth changes"></tr>',
'</tr>','<tr class="divider coauth changes-show"></tr>',
/** coauthoring end **/
'<tr class="themes">',
'<td class="left"><label><%= scope.strTheme %></label></td>',
@ -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);