From 5b3cfbab266d1f0ef7c484a8325811abb0dfec7e Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Fri, 9 Feb 2024 01:42:04 +0530 Subject: [PATCH] annotation: refresh comments on accept/reject all tracked changes problem: tracked comments deletion was not reflected with accept/reject all changes implementation explaination: we have different implementation for accept and reject all changes, due to fact when we reject the changes those elements already exists in DOM, we can mark them as rejected and modify them. while on the other hand with accepting change DOM elements need to rearranged. i.e: if comments are deleted while being tracked, and we accept that changes, comment needs to be removed from DOM and if we rejected that change we just need to remove CSS class. This implementation takes care of cases when comments are being deleted, other cases of addition or modification works usually Signed-off-by: Pranam Lashkari Change-Id: I0964fbd220f450cb144a115e8203250467e7edae --- browser/src/control/Control.Menubar.js | 13 +++++++++---- browser/src/control/Control.NotebookbarWriter.js | 12 ++++++------ browser/src/control/Toolbar.js | 9 +++++++++ browser/src/layer/tile/CommentListSection.ts | 10 ++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/browser/src/control/Control.Menubar.js b/browser/src/control/Control.Menubar.js index 6d965a9f7..82644d551 100644 --- a/browser/src/control/Control.Menubar.js +++ b/browser/src/control/Control.Menubar.js @@ -116,8 +116,8 @@ L.Control.Menubar = L.Control.extend({ {uno: '.uno:ShowTrackedChanges'}, {type: 'separator'}, {uno: '.uno:AcceptTrackedChanges'}, - {uno: '.uno:AcceptAllTrackedChanges'}, - {uno: '.uno:RejectAllTrackedChanges'}, + {name: _UNO('.uno:AcceptAllTrackedChanges', 'text'), id: 'acceptalltrackedchanges', type: 'action'}, + {name: _UNO('.uno:RejectAllTrackedChanges', 'text'), id: 'rejectalltrackedchanges', type: 'action'}, {uno: '.uno:PreviousTrackedChange'}, {uno: '.uno:NextTrackedChange'} ]}, @@ -960,8 +960,8 @@ L.Control.Menubar = L.Control.extend({ {uno: '.uno:TrackChanges'}, {uno: '.uno:ShowTrackedChanges'}, {type: 'separator'}, - {uno: '.uno:AcceptAllTrackedChanges'}, - {uno: '.uno:RejectAllTrackedChanges'}, + {name: _UNO('.uno:AcceptAllTrackedChanges', 'text'), id: 'acceptalltrackedchanges', type: 'action'}, + {name: _UNO('.uno:RejectAllTrackedChanges', 'text'), id: 'rejectalltrackedchanges', type: 'action'}, {uno: '.uno:PreviousTrackedChange'}, {uno: '.uno:NextTrackedChange'} ]}, @@ -1969,6 +1969,11 @@ L.Control.Menubar = L.Control.extend({ this._map.hideSlide(); } else if (id.indexOf('morelanguages-') != -1) { this._map.fire('morelanguages', { applyto: id.substr('morelanguages-'.length) }); + } else if (id === 'acceptalltrackedchanges') { + this._map.dispatch('acceptalltrackedchanges'); + + } else if (id === 'rejectalltrackedchanges') { + this._map.dispatch('rejectalltrackedchanges'); } // Inform the host if asked if (postmessage) diff --git a/browser/src/control/Control.NotebookbarWriter.js b/browser/src/control/Control.NotebookbarWriter.js index 05dc45b6b..2c94632cb 100644 --- a/browser/src/control/Control.NotebookbarWriter.js +++ b/browser/src/control/Control.NotebookbarWriter.js @@ -2283,10 +2283,10 @@ L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({ 'type': 'toolbox', 'children': [ { - 'id': 'review-accept-all-tracked-changes', - 'type': 'toolitem', + 'id': 'acceptalltrackedchanges', + 'type': 'customtoolitem', 'text': _UNO('.uno:AcceptAllTrackedChanges', 'text'), - 'command': '.uno:AcceptAllTrackedChanges', + 'command': 'acceptalltrackedchanges', 'accessibility': { focusBack: true, combination: 'A2', de: 'A2' } } ] @@ -2295,10 +2295,10 @@ L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({ 'type': 'toolbox', 'children': [ { - 'id': 'review-reject-all-tracked-changes', - 'type': 'toolitem', + 'id': 'rejectalltrackedchanges', + 'type': 'customtoolitem', 'text': _UNO('.uno:RejectAllTrackedChanges', 'text'), - 'command': '.uno:RejectAllTrackedChanges', + 'command': 'rejectalltrackedchanges', 'accessibility': { focusBack: true, combination: 'J', de: 'J' } } ] diff --git a/browser/src/control/Toolbar.js b/browser/src/control/Toolbar.js index b6ac64dec..d4465bcd8 100644 --- a/browser/src/control/Toolbar.js +++ b/browser/src/control/Toolbar.js @@ -1161,6 +1161,15 @@ L.Map.include({ } } break; + case 'acceptalltrackedchanges': + this.sendUnoCommand('.uno:AcceptAllTrackedChanges'); + app.socket.sendMessage('commandvalues command=.uno:ViewAnnotations'); + break; + case 'rejectalltrackedchanges': + this.sendUnoCommand('.uno:RejectAllTrackedChanges'); + var commentSection = app.sectionContainer.getSectionWithName(L.CSections.CommentList.name); + commentSection.rejectAllTrackedCommentChanges(); + break; default: console.error('unknown dispatch: "' + action + '"'); } diff --git a/browser/src/layer/tile/CommentListSection.ts b/browser/src/layer/tile/CommentListSection.ts index 4d727fae8..d5ac8afe1 100644 --- a/browser/src/layer/tile/CommentListSection.ts +++ b/browser/src/layer/tile/CommentListSection.ts @@ -1992,6 +1992,16 @@ export class CommentSection extends CanvasSectionObject { comment.onCommentDataUpdate(); } } + + public rejectAllTrackedCommentChanges(): void { + for (var i = 0; i < this.sectionProperties.commentList.length; i++) { + var comment = this.sectionProperties.commentList[i]; + if (comment.sectionProperties.data.layoutStatus === 3) { + comment.sectionProperties.data.layoutStatus = 2; + comment.sectionProperties.container.classList.remove('greyed'); + } + } + } } }