From 2887aa1b06e7147bf820b7ce92e2501e67fdae43 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 29 Jun 2021 22:03:37 +0300 Subject: [PATCH] [mobile] Fix bug 47933, fix context menu in comment mode --- .../mobile/src/controller/ContextMenu.jsx | 40 +++++++++++++++---- .../mobile/src/controller/ContextMenu.jsx | 15 ++++++- .../mobile/src/controller/ContextMenu.jsx | 22 ++++++---- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx index 54d0b7c63..d53bec6bb 100644 --- a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx @@ -11,7 +11,9 @@ import EditorUIController from '../lib/patch'; @inject ( stores => ({ isEdit: stores.storeAppOptions.isEdit, + canComments: stores.storeAppOptions.canComments, canViewComments: stores.storeAppOptions.canViewComments, + canCoAuthoring: stores.storeAppOptions.canCoAuthoring, canReview: stores.storeAppOptions.canReview, users: stores.users, isDisconnected: stores.users.isDisconnected @@ -216,12 +218,35 @@ class ContextMenu extends ContextMenuController { } else { const { t } = this.props; const _t = t("ContextMenu", {returnObjects: true}); - const { canViewComments } = this.props; + const { canViewComments, canCoAuthoring, canComments } = this.props; const api = Common.EditorApi.get(); const stack = api.getSelectedElements(); const canCopy = api.can_CopyCut(); + let isText = false, + isObject = false, + isLink = false, + locked = false; + + stack.forEach(item => { + const objectType = item.get_ObjectType(), + objectValue = item.get_ObjectValue(); + if ( objectType == Asc.c_oAscTypeSelectElement.Header ) { + locked = objectValue.get_Locked(); + } else + if ( objectType == Asc.c_oAscTypeSelectElement.Paragraph ) { + locked = objectValue.get_Locked(); + isText = true; + } else + if ( objectType == Asc.c_oAscTypeSelectElement.Image || objectType == Asc.c_oAscTypeSelectElement.Table) { + locked = objectValue.get_Locked(); + isObject = true; + } else if ( objectType == Asc.c_oAscTypeSelectElement.Hyperlink ) { + isLink = true; + } + }); + let itemsIcon = [], itemsText = []; @@ -239,13 +264,12 @@ class ContextMenu extends ContextMenuController { }); } - let isLink = false; - stack.forEach(item => { - const objectType = item.get_ObjectType(); - if ( objectType === Asc.c_oAscTypeSelectElement.Hyperlink ) { - isLink = true; - } - }); + if (api.can_AddQuotedComment() !== false && canCoAuthoring && canComments && !locked && !(!isText && isObject)) { + itemsText.push({ + caption: _t.menuAddComment, + event: 'addcomment' + }); + } if ( isLink ) { itemsText.push({ diff --git a/apps/presentationeditor/mobile/src/controller/ContextMenu.jsx b/apps/presentationeditor/mobile/src/controller/ContextMenu.jsx index 99ed87b06..b24854c41 100644 --- a/apps/presentationeditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/presentationeditor/mobile/src/controller/ContextMenu.jsx @@ -11,7 +11,9 @@ import EditorUIController from '../lib/patch'; @inject ( stores => ({ isEdit: stores.storeAppOptions.isEdit, + canComments: stores.storeAppOptions.canComments, canViewComments: stores.storeAppOptions.canViewComments, + canCoAuthoring: stores.storeAppOptions.canCoAuthoring, users: stores.users, isDisconnected: stores.users.isDisconnected })) @@ -198,7 +200,7 @@ class ContextMenu extends ContextMenuController { const { t } = this.props; const _t = t("ContextMenu", { returnObjects: true }); - const { canViewComments, isDisconnected } = this.props; + const { canViewComments, canCoAuthoring, canComments } = this.props; const api = Common.EditorApi.get(); const stack = api.getSelectedElements(); @@ -214,11 +216,13 @@ class ContextMenu extends ContextMenuController { isShape = false, isLink = false, isSlide = false, - isObject = false; + isObject, + locked = false; stack.forEach(item => { const objectType = item.get_ObjectType(), objectValue = item.get_ObjectValue(); + locked = typeof objectValue.get_Locked === 'function' ? objectValue.get_Locked() : false; if (objectType == Asc.c_oAscTypeSelectElement.Paragraph) { isText = true; @@ -252,6 +256,13 @@ class ContextMenu extends ContextMenuController { }); } + if (!isChart && api.can_AddQuotedComment() !== false && canCoAuthoring && canComments && !locked) { + itemsText.push({ + caption: _t.menuAddComment, + event: 'addcomment' + }); + } + if (isLink) { itemsText.push({ caption: _t.menuOpenLink, diff --git a/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx b/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx index 15462d90b..436ccdd7c 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/ContextMenu.jsx @@ -11,7 +11,9 @@ import EditorUIController from '../lib/patch'; @inject ( stores => ({ isEdit: stores.storeAppOptions.isEdit, + canComments: stores.storeAppOptions.canComments, canViewComments: stores.storeAppOptions.canViewComments, + canCoAuthoring: stores.storeAppOptions.canCoAuthoring, users: stores.users, isDisconnected: stores.users.isDisconnected, storeSheets: stores.sheets @@ -175,7 +177,7 @@ class ContextMenu extends ContextMenuController { if (isEdit && EditorUIController.ContextMenu) { return EditorUIController.ContextMenu.mapMenuItems(this); } else { - const {canViewComments } = this.props; + const {canViewComments, canCoAuthoring, canComments } = this.props; const api = Common.EditorApi.get(); const cellinfo = api.asc_getCellInfo(); @@ -199,12 +201,11 @@ class ContextMenu extends ContextMenuController { case Asc.c_oAscSelectionType.RangeShapeText: istextshapemenu = true; break; } - if (iscellmenu || istextchartmenu || istextshapemenu) { - itemsIcon.push({ - event: 'copy', - icon: 'icon-copy' - }); - } + itemsIcon.push({ + event: 'copy', + icon: 'icon-copy' + }); + if (iscellmenu && cellinfo.asc_getHyperlink()) { itemsText.push({ caption: _t.menuOpenLink, @@ -218,6 +219,13 @@ class ContextMenu extends ContextMenuController { }); } + if (iscellmenu && !api.isCellEdited && canCoAuthoring && canComments && !isComments) { + itemsText.push({ + caption: _t.menuAddComment, + event: 'addcomment' + }); + } + return itemsIcon.concat(itemsText); } }