From ccdf5a379fbb694932a83a7d205adc51935fb093 Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Fri, 24 May 2024 06:50:59 +0300 Subject: [PATCH] annotation: display dialog for conflicting comment modification Signed-off-by: Pranam Lashkari Change-Id: Ie45aa11a0df506fdb8c9d0d78b186323ee3a4242 --- .../src/canvas/sections/CommentListSection.ts | 19 +++++++++++++++++++ browser/src/canvas/sections/CommentSection.ts | 8 ++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/browser/src/canvas/sections/CommentListSection.ts b/browser/src/canvas/sections/CommentListSection.ts index 0b386dba8..1c96f4c12 100644 --- a/browser/src/canvas/sections/CommentListSection.ts +++ b/browser/src/canvas/sections/CommentListSection.ts @@ -1216,6 +1216,25 @@ export class CommentSection extends app.definitions.canvasSectionObject { public onACKComment (obj: any): void { var id; + const anyEdit = Comment.isAnyEdit(); + if (anyEdit && anyEdit.sectionProperties.data.id === obj.comment.id) { + if (document.getElementById(this.map.uiManager.generateModalId('comments-update'))) + return; + this.map.uiManager.showYesNoButton( + 'comments-update', + _('Comments updated'), + _('Another user has updated the comment. Would you like to overwrite those changes?'), + _('Overwrite'), + _('Update'), + null, + () => { + this.clearAutoSaveStatus(); + anyEdit.onCancelClick(null); + this.onACKComment(obj); + }, false + ); + return; + } var changetrack = obj.redline ? true : false; var dataroot = changetrack ? 'redline' : 'comment'; if (changetrack) { diff --git a/browser/src/canvas/sections/CommentSection.ts b/browser/src/canvas/sections/CommentSection.ts index e68ffadba..77bccb5f7 100644 --- a/browser/src/canvas/sections/CommentSection.ts +++ b/browser/src/canvas/sections/CommentSection.ts @@ -1033,11 +1033,11 @@ export class Comment extends app.definitions.canvasSectionObject { (this.sectionProperties.nodeReply && this.sectionProperties.nodeReply.style.display !== 'none')); } - public static isAnyEdit (): boolean { + public static isAnyEdit (): Comment { var section = app.sectionContainer && app.sectionContainer instanceof CanvasSectionContainer ? app.sectionContainer.getSectionWithName(L.CSections.CommentList.name) : null; if (!section) { - return false; + return null; } var commentList = section.sectionProperties.commentList; @@ -1047,9 +1047,9 @@ export class Comment extends app.definitions.canvasSectionObject { if (!commentList[i].pendingInit && ((modifyNode && modifyNode.style.display !== 'none') || (replyNode && replyNode.style.display !== 'none'))) - return true; + return commentList[i]; } - return false; + return null; } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types