diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 5e00f02b2..23adfc909 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -680,10 +680,12 @@ define([ cellinfo = this.api.asc_getCellInfo(); if (controller) { var comments = cellinfo.asc_getComments(); - if (comments.length) { - controller.onEditComments(comments); - } else if (this.permissions.canCoAuthoring) { - controller.addDummyComment(); + if (comments) { + if (comments.length) { + controller.onEditComments(comments); + } else if (this.permissions.canCoAuthoring) { + controller.addDummyComment(); + } } } } @@ -1981,9 +1983,9 @@ define([ documentHolder.pmiFreezePanes.setCaption(this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? documentHolder.textUnFreezePanes : documentHolder.textFreezePanes); /** coauthoring begin **/ - var count = cellinfo.asc_getComments().length; - documentHolder.ssMenu.items[19].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && count < 1); - documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && count < 1); + var celcomments = cellinfo.asc_getComments(); // celcomments===null - has comment, but no permissions to view it + documentHolder.ssMenu.items[19].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && celcomments && (celcomments.length < 1)); + documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && celcomments && (celcomments.length < 1)); /** coauthoring end **/ documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu && !iscelledit || isrowmenu || iscolmenu || isallmenu); documentHolder.pmiEntireHide.isrowmenu = isrowmenu; @@ -2091,7 +2093,7 @@ define([ var signProps = (signGuid) ? this.api.asc_getSignatureSetup(signGuid) : null, isInSign = !!signProps && this._canProtect, - canComment = iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled && cellinfo.asc_getComments().length < 1; + canComment = iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled && cellinfo.asc_getComments() && cellinfo.asc_getComments().length < 1; documentHolder.menuViewUndo.setVisible(this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled); documentHolder.menuViewUndo.setDisabled(!this.api.asc_getCanUndo() && !this._isDisabled); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 92881e950..7d1a839ea 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -2843,7 +2843,8 @@ define([ toolbar.btnDeleteCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down); } - toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (info.asc_getComments().length>0 || info.asc_getLocked()) || + // info.asc_getComments()===null - has comment, but no permissions to view it + toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (!info.asc_getComments() || info.asc_getComments().length>0 || info.asc_getLocked()) || this.toolbar.mode.compatibleFeatures && (selectionType != Asc.c_oAscSelectionType.RangeCells), { array: this.btnsComment }); @@ -2852,7 +2853,7 @@ define([ onApiSelectionChangedRestricted: function(info) { var selectionType = info.asc_getSelectionType(); - this.toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (info.asc_getComments().length>0 || info.asc_getLocked()) || + this.toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (!info.asc_getComments() || info.asc_getComments().length>0 || info.asc_getLocked()) || this.appConfig && this.appConfig.compatibleFeatures && (selectionType != Asc.c_oAscSelectionType.RangeCells), { array: this.btnsComment }); }, diff --git a/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx b/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx index 4af867c16..86d2dffaa 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx @@ -187,7 +187,7 @@ class ContextMenu extends ContextMenuController { let iscellmenu, isrowmenu, iscolmenu, isallmenu, ischartmenu, isimagemenu, istextshapemenu, isshapemenu, istextchartmenu; const seltype = cellinfo.asc_getSelectionType(); - const isComments = cellinfo.asc_getComments().length > 0; //prohibit adding multiple comments in one cell; + const hasComments = cellinfo.asc_getComments(); //prohibit adding multiple comments in one cell; switch (seltype) { case Asc.c_oAscSelectionType.RangeCells: iscellmenu = true; break; @@ -212,14 +212,14 @@ class ContextMenu extends ContextMenuController { event: 'openlink' }); } - if (canViewComments && isComments) { + if (canViewComments && hasComments && hasComments.length>0) { itemsText.push({ caption: _t.menuViewComment, event: 'viewcomment' }); } - if (iscellmenu && !api.isCellEdited && canCoAuthoring && canComments && !isComments) { + if (iscellmenu && !api.isCellEdited && canCoAuthoring && canComments && hasComments && hasComments.length<1) { itemsText.push({ caption: _t.menuAddComment, event: 'addcomment' diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx index 85ffc2e93..b168becbe 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx @@ -22,7 +22,7 @@ class AddOtherController extends Component { const cellinfo = Common.EditorApi.get().asc_getCellInfo(); const iscelllocked = cellinfo.asc_getLocked(); const seltype = cellinfo.asc_getSelectionType(); - const isComments = cellinfo.asc_getComments().length > 0; + const isComments = !cellinfo.asc_getComments() || cellinfo.asc_getComments().length > 0; return (!(seltype === Asc.c_oAscSelectionType.RangeCells && !iscelllocked) || isComments); }