[DE] Fix for Commit: c1e1ced4d2

Disable adding comment to document from toolbar (add comment only for text) in commenting mode
This commit is contained in:
Julia Radzhabova 2019-03-28 11:47:51 +03:00
parent e798e6d4a7
commit 67dd8e1379
2 changed files with 77 additions and 43 deletions

View file

@ -1234,12 +1234,15 @@ define([
reviewController = application.getController('Common.Controllers.ReviewChanges');
reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
if (this.appOptions.isEdit) {
var toolbarController = application.getController('Toolbar'),
rightmenuController = application.getController('RightMenu'),
if (this.appOptions.isEdit || this.appOptions.isRestrictedEdit) { // set api events for toolbar in the Restricted Editing mode
var toolbarController = application.getController('Toolbar');
toolbarController && toolbarController.setApi(me.api);
if (this.appOptions.isRestrictedEdit) return;
var rightmenuController = application.getController('RightMenu'),
fontsControllers = application.getController('Common.Controllers.Fonts');
fontsControllers && fontsControllers.setApi(me.api);
toolbarController && toolbarController.setApi(me.api);
rightmenuController && rightmenuController.setApi(me.api);
if (this.appOptions.canProtect)

View file

@ -331,6 +331,7 @@ define([
setApi: function(api) {
this.api = api;
if (this.mode.isEdit) {
this.toolbar.setApi(api);
this.api.asc_registerCallback('asc_onFontSize', _.bind(this.onApiFontSize, this));
@ -361,7 +362,7 @@ define([
this.api.asc_registerCallback('asc_onMarkerFormatChanged', _.bind(this.onApiStartHighlight, this));
this.api.asc_registerCallback('asc_onTextHighLight', _.bind(this.onApiHighlightColor, this));
this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onCanCopyCut', _.bind(this.onApiCanCopyCut, this));
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onMathTypes, this));
@ -369,7 +370,12 @@ define([
this.api.asc_registerCallback('asc_onSectionProps', _.bind(this.onSectionProps, this));
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
this.api.asc_registerCallback('asc_onShowParaMarks', _.bind(this.onShowParaMarks, this));
this.api.asc_registerCallback('asc_onChangeSdtGlobalSettings',_.bind(this.onChangeSdtGlobalSettings, this));
this.api.asc_registerCallback('asc_onChangeSdtGlobalSettings', _.bind(this.onChangeSdtGlobalSettings, this));
} else if (this.mode.isRestrictedEdit) {
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObjectRestrictedEdit, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
}
},
onChangeCompactView: function(view, compact) {
@ -629,6 +635,31 @@ define([
Common.localStorage.setItem("de-show-hiddenchars", v);
},
onApiFocusObjectRestrictedEdit: function(selectedObjects) {
if (!this.editMode) return;
var i = -1, type,
paragraph_locked = false,
header_locked = false,
image_locked = false;
while (++i < selectedObjects.length) {
type = selectedObjects[i].get_ObjectType();
if (type === Asc.c_oAscTypeSelectElement.Paragraph) {
paragraph_locked = selectedObjects[i].get_ObjectValue().get_Locked();
} else if (type === Asc.c_oAscTypeSelectElement.Header) {
header_locked = selectedObjects[i].get_ObjectValue().get_Locked();
} else if (type === Asc.c_oAscTypeSelectElement.Image) {
image_locked = selectedObjects[i].get_ObjectValue().get_Locked();
}
}
var need_disable = !this.api.can_AddQuotedComment() || paragraph_locked || header_locked || image_locked;
if ( this.btnsComment && this.btnsComment.length > 0 )
this.btnsComment.setDisabled(need_disable);
},
onApiFocusObject: function(selectedObjects) {
if (!this.editMode) return;
@ -2672,7 +2703,7 @@ define([
},
onApiCoAuthoringDisconnect: function(enableDownload) {
this.toolbar.setMode({isDisconnected:true, enableDownload: !!enableDownload});
this.mode.isEdit && this.toolbar.setMode({isDisconnected:true, enableDownload: !!enableDownload});
this.editMode = false;
this.DisableToolbar(true, true);
},