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 <lpranam@collabora.com>
Change-Id: I0964fbd220f450cb144a115e8203250467e7edae
This commit is contained in:
Pranam Lashkari 2024-02-09 01:42:04 +05:30 committed by Pranam Lashkari
parent 71a427c465
commit 5b3cfbab26
4 changed files with 34 additions and 10 deletions

View file

@ -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)

View file

@ -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' }
}
]

View file

@ -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 + '"');
}

View file

@ -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');
}
}
}
}
}