[PE][SSE] Add api parameters for co-authoring mode

This commit is contained in:
Julia Radzhabova 2021-04-02 22:36:08 +03:00
parent c9b200ec9e
commit fc2bcf24bd
7 changed files with 142 additions and 85 deletions

View file

@ -610,9 +610,6 @@ define([
applySettings: function() {
Common.UI.Themes.setTheme(this.cmbTheme.getValue());
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"));
@ -629,7 +626,7 @@ 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());
if (this.mode.canChangeCoAuthoring || !fast_coauth)
if (this.mode.canChangeCoAuthoring || !Common.Utils.InternalSettings.get("de-settings-coauthmode"))
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);

View file

@ -340,11 +340,14 @@ define([
Common.Utils.InternalSettings.set("pe-settings-inputmode", value);
this.api.SetTextBoxInputMode(value);
var fast_coauth = Common.Utils.InternalSettings.get("pe-settings-coauthmode");
/** coauthoring begin **/
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
value = Common.localStorage.getBool("pe-settings-coauthmode", true);
Common.Utils.InternalSettings.set("pe-settings-coauthmode", value);
this.api.asc_SetFastCollaborative(value);
if (this.mode.canChangeCoAuthoring) {
fast_coauth = Common.localStorage.getBool("pe-settings-coauthmode", true);
Common.Utils.InternalSettings.set("pe-settings-coauthmode", fast_coauth);
this.api.asc_SetFastCollaborative(fast_coauth);
}
}
/** coauthoring end **/
@ -357,9 +360,11 @@ define([
this.api.SetFontRenderingMode(parseInt(value));
if (this.mode.isEdit) {
if (this.mode.canChangeCoAuthoring || !fast_coauth) {// can change co-auth. mode or for strict mode
value = parseInt(Common.localStorage.getItem("pe-settings-autosave"));
Common.Utils.InternalSettings.set("pe-settings-autosave", value);
this.api.asc_setAutoSaveGap(value);
}
value = Common.localStorage.getBool("pe-settings-spellcheck", true);
Common.Utils.InternalSettings.set("pe-settings-spellcheck", value);

View file

@ -774,22 +774,9 @@ define([
me.api.SetTextBoxInputMode(value);
/** coauthoring begin **/
if (me.appOptions.isEdit && !me.appOptions.isOffline && me.appOptions.canCoAuthoring) {
value = Common.localStorage.getItem("pe-settings-coauthmode");
if (value===null && !Common.localStorage.itemExists("pe-settings-autosave") &&
me.appOptions.customization && me.appOptions.customization.autosave===false) {
value = 0; // use customization.autosave only when pe-settings-coauthmode and pe-settings-autosave are null
}
me._state.fastCoauth = (value===null || parseInt(value) == 1);
} else {
me._state.fastCoauth = (!me.appOptions.isEdit && me.appOptions.isRestrictedEdit);
if (me._state.fastCoauth) {
me.api.asc_setAutoSaveGap(1);
Common.Utils.InternalSettings.set("pe-settings-autosave", 1);
}
}
me._state.fastCoauth = Common.Utils.InternalSettings.get("pe-settings-coauthmode");
me.api.asc_SetFastCollaborative(me._state.fastCoauth);
Common.Utils.InternalSettings.set("pe-settings-coauthmode", me._state.fastCoauth);
me.api.asc_setAutoSaveGap(Common.Utils.InternalSettings.get("pe-settings-autosave"));
/** coauthoring end **/
Common.Utils.InternalSettings.set("pe-settings-showsnaplines", me.api.get_ShowSnapLines());
@ -826,13 +813,6 @@ define([
application.getController('Viewport').getView('DocumentPreview').setApi(me.api).setMode(me.appOptions).on('editcomplete', _.bind(me.onEditComplete, me));
if (me.appOptions.isEdit) {
value = Common.localStorage.getItem("pe-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);
me.api.asc_setAutoSaveGap(value);
Common.Utils.InternalSettings.set("pe-settings-autosave", value);
if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true
me.appOptions.forcesave = Common.localStorage.getBool("pe-settings-forcesave", me.appOptions.canForcesave);
Common.Utils.InternalSettings.set("pe-settings-forcesave", me.appOptions.forcesave);
@ -1085,6 +1065,9 @@ define([
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions);
this.appOptions.canChangeCoAuthoring = this.appOptions.isEdit && this.appOptions.canCoAuthoring && (this.permissions.changeCoAuthoring!==false);
this.loadCoAuthSettings();
this.applyModeCommonElements();
this.applyModeEditorElements();
@ -1100,6 +1083,46 @@ define([
this.api.asc_LoadDocument();
},
loadCoAuthSettings: function() {
var fastCoauth = true,
autosave = 1,
value;
if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) {
if (!this.appOptions.canChangeCoAuthoring) { //can't change co-auth. mode. Use customization.modeCoAuthoring or 'fast' by default
value = (this.appOptions.customization && this.appOptions.customization.modeCoAuthoring!==undefined) ? (this.appOptions.customization.modeCoAuthoring==='strict' ? 0 : 1) : null;
if (value===null && this.appOptions.customization && this.appOptions.customization.autosave===false) {
value = 0; // use customization.autosave only when modeCoAuthoring are null
}
} else {
value = Common.localStorage.getItem("pe-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("pe-settings-autosave") &&
this.appOptions.customization && this.appOptions.customization.autosave===false) {
value = 0; // use customization.autosave only when de-settings-coauthmode and pe-settings-autosave are null
}
}
}
fastCoauth = (value===null || parseInt(value) == 1);
} else if (!this.appOptions.isEdit && this.appOptions.isRestrictedEdit) {
fastCoauth = true;
} else {
fastCoauth = false;
autosave = 0;
}
if (this.appOptions.isEdit) {
value = Common.localStorage.getItem("pe-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("pe-settings-coauthmode", fastCoauth);
Common.Utils.InternalSettings.set("pe-settings-autosave", autosave);
},
applyModeCommonElements: function() {
window.editor_elements_prepared = true;
@ -1888,10 +1911,10 @@ define([
if (!window.localStorage.getBool("pe-hide-try-undoredo"))
Common.UI.info({
width: 500,
msg: this.textTryUndoRedo,
msg: this.appOptions.canChangeCoAuthoring ? this.textTryUndoRedo : this.textTryUndoRedoWarn,
iconCls: 'info',
buttons: ['custom', 'cancel'],
primary: 'custom',
buttons: this.appOptions.canChangeCoAuthoring ? ['custom', 'cancel'] : ['ok'],
primary: this.appOptions.canChangeCoAuthoring ? 'custom' : 'ok',
customButtonText: this.textStrict,
dontshow: true,
callback: _.bind(function(btn, dontshow){
@ -2675,7 +2698,8 @@ define([
textLongName: 'Enter a name that is less than 128 characters.',
textGuest: 'Guest',
txtErrorLoadHistory: 'Loading history failed',
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.'
}
})(), PE.Controllers.Main || {}))
});

View file

@ -217,7 +217,7 @@ define([
'<tr class="themes">',
'<td class="left"><label><%= scope.strTheme %></label></td>',
'<td class="right"><span id="fms-cmb-theme"></span></td>',
'</tr>','<tr class="divider edit"></tr>',
'</tr>','<tr class="divider"></tr>',
'<tr>',
'<td class="left"><label><%= scope.strZoom %></label></td>',
'<td class="right"><div id="fms-cmb-zoom" class="input-group-nr"></div></td>',
@ -460,15 +460,18 @@ define([
setMode: function(mode) {
this.mode = mode;
var fast_coauth = Common.Utils.InternalSettings.get("pe-settings-coauthmode");
$('tr.edit', this.el)[mode.isEdit?'show':'hide']();
$('tr.autosave', this.el)[mode.isEdit ? 'show' : 'hide']();
$('tr.autosave', this.el)[mode.isEdit && (mode.canChangeCoAuthoring || !fast_coauth) ? 'show' : 'hide']();
if (this.mode.isDesktopApp && this.mode.isOffline) {
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']();
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring && mode.canChangeCoAuthoring ? 'show' : 'hide']();
/** coauthoring end **/
$('tr.macros', this.el)[(mode.customization && mode.customization.macros===false) ? 'hide' : 'show']();
@ -535,13 +538,12 @@ define([
applySettings: function() {
Common.UI.Themes.setTheme(this.cmbTheme.getValue());
Common.localStorage.setItem("pe-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
Common.localStorage.setItem("pe-settings-inputmode", this.chInputMode.isChecked() ? 1 : 0);
Common.localStorage.setItem("pe-settings-zoom", this.cmbZoom.getValue());
Common.Utils.InternalSettings.set("pe-settings-zoom", Common.localStorage.getItem("pe-settings-zoom"));
/** coauthoring begin **/
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring && this.mode.canChangeCoAuthoring) {
Common.localStorage.setItem("pe-settings-coauthmode", this.cmbCoAuthMode.getValue());
}
/** coauthoring end **/
@ -549,6 +551,7 @@ define([
var item = this.cmbFontRender.store.findWhere({value: 'custom'});
Common.localStorage.setItem("pe-settings-cachemode", item && !item.get('checked') ? 0 : 1);
Common.localStorage.setItem("pe-settings-unit", this.cmbUnit.getValue());
if (this.mode.canChangeCoAuthoring || !Common.Utils.InternalSettings.get("pe-settings-coauthmode"))
Common.localStorage.setItem("pe-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
if (this.mode.canForcesave)
Common.localStorage.setItem("pe-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);

View file

@ -387,17 +387,22 @@ define([
Common.Utils.InternalSettings.set("sse-settings-r1c1", value);
this.api.asc_setR1C1Mode(value);
var fast_coauth = Common.Utils.InternalSettings.get("sse-settings-coauthmode");
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
value = Common.localStorage.getBool("sse-settings-coauthmode", true);
Common.Utils.InternalSettings.set("sse-settings-coauthmode", value);
this.api.asc_SetFastCollaborative(value);
if (this.mode.canChangeCoAuthoring) {
fast_coauth = Common.localStorage.getBool("sse-settings-coauthmode", true);
Common.Utils.InternalSettings.set("sse-settings-coauthmode", fast_coauth);
this.api.asc_SetFastCollaborative(fast_coauth);
}
}
/** coauthoring end **/
if (this.mode.isEdit) {
if (this.mode.canChangeCoAuthoring || !fast_coauth) {// can change co-auth. mode or for strict mode
value = parseInt(Common.localStorage.getItem("sse-settings-autosave"));
Common.Utils.InternalSettings.set("sse-settings-autosave", value);
this.api.asc_setAutoSaveGap(value);
}
value = parseInt(Common.localStorage.getItem("sse-settings-paste-button"));
Common.Utils.InternalSettings.set("sse-settings-paste-button", value);

View file

@ -787,22 +787,9 @@ define([
Common.Utils.InternalSettings.set("sse-settings-resolvedcomment", value);
this.isLiveCommenting ? this.api.asc_showComments(value) : this.api.asc_hideComments();
if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) {
value = Common.localStorage.getItem("sse-settings-coauthmode");
if (value===null && Common.localStorage.getItem("sse-settings-autosave")===null &&
this.appOptions.customization && this.appOptions.customization.autosave===false) {
value = 0; // use customization.autosave only when sse-settings-coauthmode and sse-settings-autosave are null
}
this._state.fastCoauth = (value===null || parseInt(value) == 1);
} else {
this._state.fastCoauth = (!this.appOptions.isEdit && this.appOptions.isRestrictedEdit);
if (this._state.fastCoauth) {
this.api.asc_setAutoSaveGap(1);
Common.Utils.InternalSettings.set("sse-settings-autosave", 1);
}
}
this.api.asc_SetFastCollaborative(this._state.fastCoauth);
Common.Utils.InternalSettings.set("sse-settings-coauthmode", me._state.fastCoauth);
this._state.fastCoauth = Common.Utils.InternalSettings.get("sse-settings-coauthmode");
this.api.asc_SetFastCollaborative(me._state.fastCoauth);
this.api.asc_setAutoSaveGap(Common.Utils.InternalSettings.get("sse-settings-autosave"));
/** coauthoring end **/
/** spellcheck settings begin **/
@ -866,17 +853,6 @@ define([
if (me.appOptions.isEdit) {
spellcheckController.setApi(me.api).setMode(me.appOptions);
if (me.appOptions.canAutosave) {
value = Common.localStorage.getItem("sse-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);
} else {
value = 0;
}
me.api.asc_setAutoSaveGap(value);
Common.Utils.InternalSettings.set("sse-settings-autosave", value);
if (me.appOptions.canForcesave) {// use asc_setIsForceSaveOnUserSave only when customization->forcesave = true
me.appOptions.forcesave = Common.localStorage.getBool("sse-settings-forcesave", me.appOptions.canForcesave);
Common.Utils.InternalSettings.set("sse-settings-forcesave", me.appOptions.forcesave);
@ -1148,11 +1124,14 @@ define([
this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false);
this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && this.appOptions.canComments;
this.appOptions.canChangeCoAuthoring = this.appOptions.isEdit && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && this.appOptions.canCoAuthoring && (this.permissions.changeCoAuthoring!==false);
if (!this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge) {
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions);
}
this.loadCoAuthSettings();
this.applyModeCommonElements();
this.applyModeEditorElements();
@ -1168,6 +1147,46 @@ define([
this.api.asc_LoadDocument();
},
loadCoAuthSettings: function() {
var fastCoauth = true,
autosave = 1,
value;
if (this.appOptions.isEdit && !this.appOptions.isOffline && this.appOptions.canCoAuthoring) {
if (!this.appOptions.canChangeCoAuthoring) { //can't change co-auth. mode. Use customization.modeCoAuthoring or 'fast' by default
value = (this.appOptions.customization && this.appOptions.customization.modeCoAuthoring!==undefined) ? (this.appOptions.customization.modeCoAuthoring==='strict' ? 0 : 1) : null;
if (value===null && this.appOptions.customization && this.appOptions.customization.autosave===false) {
value = 0; // use customization.autosave only when modeCoAuthoring are null
}
} else {
value = Common.localStorage.getItem("sse-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("sse-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);
} else if (!this.appOptions.isEdit && this.appOptions.isRestrictedEdit) {
fastCoauth = true;
} else {
fastCoauth = false;
autosave = 0;
}
if (this.appOptions.isEdit && this.appOptions.canAutosave) {
value = Common.localStorage.getItem("sse-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("sse-settings-coauthmode", fastCoauth);
Common.Utils.InternalSettings.set("sse-settings-autosave", autosave);
},
applyModeCommonElements: function() {
window.editor_elements_prepared = true;
@ -2277,10 +2296,10 @@ define([
if (!(val && parseInt(val) == 1))
Common.UI.info({
width: 500,
msg: this.textTryUndoRedo,
msg: this.appOptions.canChangeCoAuthoring ? this.textTryUndoRedo : this.textTryUndoRedoWarn,
iconCls: 'info',
buttons: ['custom', 'cancel'],
primary: 'custom',
buttons: this.appOptions.canChangeCoAuthoring ? ['custom', 'cancel'] : ['ok'],
primary: this.appOptions.canChangeCoAuthoring ? 'custom' : 'ok',
customButtonText: this.textStrict,
dontshow: true,
callback: _.bind(function(btn, dontshow){
@ -2898,7 +2917,8 @@ define([
txtQuarters: 'Quarters',
txtYears: 'Years',
errorPivotGroup: 'Cannot group that selection.',
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.'
}
})(), SSE.Controllers.Main || {}))
});

View file

@ -694,7 +694,7 @@ define([
'<tr class="themes">',
'<td class="left"><label><%= scope.strTheme %></label></td>',
'<td class="right"><span id="fms-cmb-theme"></span></td>',
'</tr>','<tr class="divider edit"></tr>',
'</tr>','<tr class="divider"></tr>',
'<tr>',
'<td class="left"><label><%= scope.strZoom %></label></td>',
'<td class="right"><div id="fms-cmb-zoom" class="input-group-nr"></div></td>',
@ -1070,15 +1070,18 @@ define([
setMode: function(mode) {
this.mode = mode;
var fast_coauth = Common.Utils.InternalSettings.get("sse-settings-coauthmode");
$('tr.edit', this.el)[mode.isEdit ? 'show' : 'hide']();
$('tr.autosave', this.el)[mode.isEdit ? 'show' : 'hide']();
$('tr.autosave', this.el)[mode.isEdit && (mode.canChangeCoAuthoring || !fast_coauth) ? 'show' : 'hide']();
if (this.mode.isDesktopApp && this.mode.isOffline) {
this.chAutosave.setCaption(this.strAutoRecover);
this.lblAutosave.text(this.textAutoRecover);
}
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
$('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide']();
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring? 'show' : 'hide']();
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring && mode.canChangeCoAuthoring ? 'show' : 'hide']();
$('tr.macros', this.el)[(mode.customization && mode.customization.macros===false) ? 'hide' : 'show']();
if ( !Common.UI.Themes.available() ) {
@ -1181,13 +1184,12 @@ define([
applySettings: function() {
Common.UI.Themes.setTheme(this.cmbTheme.getValue());
Common.localStorage.setItem("sse-settings-zoom", this.cmbZoom.getValue());
Common.Utils.InternalSettings.set("sse-settings-zoom", Common.localStorage.getItem("sse-settings-zoom"));
/** coauthoring begin **/
Common.localStorage.setItem("sse-settings-livecomment", this.chLiveComment.isChecked() ? 1 : 0);
Common.localStorage.setItem("sse-settings-resolvedcomment", this.chResolvedComment.isChecked() ? 1 : 0);
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring)
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring && this.mode.canChangeCoAuthoring)
Common.localStorage.setItem("sse-settings-coauthmode", this.cmbCoAuthMode.getValue());
/** coauthoring end **/
Common.localStorage.setItem("sse-settings-r1c1", this.chR1C1Style.isChecked() ? 1 : 0);
@ -1195,6 +1197,7 @@ define([
var item = this.cmbFontRender.store.findWhere({value: 'custom'});
Common.localStorage.setItem("sse-settings-cachemode", item && !item.get('checked') ? 0 : 1);
Common.localStorage.setItem("sse-settings-unit", this.cmbUnit.getValue());
if (this.mode.canChangeCoAuthoring || !Common.Utils.InternalSettings.get("sse-settings-coauthmode"))
Common.localStorage.setItem("sse-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
if (this.mode.canForcesave)
Common.localStorage.setItem("sse-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);