Skip to content

Commit 3decac5

Browse files
committed
Comments: Navigate to active edit instead of blocking with popup
-When a user inserted a new comment/modified/replied with an unsaved edit, the UI displayed a blocking popup requiring the edited comment to be resolved first. -In large documents with many comments, locating that comment was slow and disruptive. -This update removes that popup and now automatically navigates to the comment currently in edit, applies a doc-type outline, and sets focus so the user can save or discard. Signed-off-by: Banobe Pascal <[email protected]> Change-Id: I2e149f3a44f9b2c144f768d07c0e9e7deda6341d
1 parent a0cf4d8 commit 3decac5

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

browser/css/cool.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,11 @@ body {
794794
height: var(--default-height); /* Height of new image */
795795
}
796796

797+
.cool-annotation-inedit {
798+
outline: 2px solid rgb(var(--doc-type));
799+
offset: -2px;
800+
}
801+
797802
.leaflet-container .leaflet-pane.leaflet-calc-background-pane {
798803
z-index: 0;
799804
}

browser/src/canvas/CanvasSectionObject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class CanvasSectionObject {
191191
isCalcRTL(): boolean { return; }
192192
setViewResolved(on: boolean): void { return; }
193193
setView(on: boolean): void { return; }
194+
navigateAndFocusComment(comment: cool.Comment): void { return; }
194195
scrollVerticalWithOffset(offset: number): void { return; }
195196
remove(id: string): void { return; }
196197
deleteThis(): void { return; }

browser/src/canvas/sections/CommentListSection.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ window.L.Map.include({
1919
if (this.stateChangeHandler.getItemValue('InsertAnnotation') === 'disabled')
2020
return;
2121
if (cool.Comment.isAnyEdit()) {
22-
cool.CommentSection.showCommentEditingWarning();
22+
app.sectionContainer.getSectionWithName(app.CSections.CommentList.name).navigateAndFocusComment(cool.Comment.isAnyEdit());
2323
return;
2424
}
2525

@@ -180,9 +180,27 @@ export class CommentSection extends CanvasSectionObject {
180180
}
181181
}
182182

183-
public static showCommentEditingWarning (): void {
184-
window.L.Map.THIS.uiManager.showInfoModal('annotation-editing', _('A comment is being edited'),
185-
_('Please save or discard the comment currently being edited.'), null, _('Close'));
183+
public navigateAndFocusComment(comment: cool.Comment): void {
184+
this.highlightComment(comment);
185+
comment.highlight();
186+
this.scrollCommentIntoView(comment);
187+
188+
if (this.sectionProperties.selectedComment !== comment) {
189+
this.select(comment, true);
190+
}
191+
192+
comment.focus();
193+
194+
const wrapper = comment.sectionProperties.wrapper;
195+
wrapper.classList.add('cool-annotation-inedit');
196+
197+
}
198+
199+
private removeCommentAttention(annotation: any): void {
200+
if (annotation.sectionProperties.container) {
201+
const wrapper = annotation.sectionProperties.wrapper;
202+
wrapper.classList.remove('cool-annotation-inedit');
203+
}
186204
}
187205

188206
private checkCollapseState(): void {
@@ -747,12 +765,13 @@ export class CommentSection extends CanvasSectionObject {
747765
this.map.sendUnoCommand('.uno:EditAnnotation', comment, true /* force */);
748766
}
749767
this.unselect();
768+
this.removeCommentAttention(annotation);
750769
this.map.focus();
751770
}
752771

753772
public reply (annotation: any): void {
754773
if (cool.Comment.isAnyEdit()) {
755-
cool.CommentSection.showCommentEditingWarning();
774+
this.navigateAndFocusComment(cool.Comment.isAnyEdit());
756775
return;
757776
}
758777
if ((<any>window).mode.isMobile()) {
@@ -791,8 +810,9 @@ export class CommentSection extends CanvasSectionObject {
791810
}
792811

793812
public modify (annotation: any): void {
813+
const editComment = cool.Comment.isAnyEdit();
794814
if (cool.Comment.isAnyEdit()) {
795-
cool.CommentSection.showCommentEditingWarning();
815+
this.navigateAndFocusComment(editComment);
796816
return;
797817
}
798818
if ((<any>window).mode.isMobile()) {
@@ -1053,6 +1073,8 @@ export class CommentSection extends CanvasSectionObject {
10531073
}
10541074

10551075
public cancel (annotation: any): void {
1076+
this.removeCommentAttention(annotation);
1077+
10561078
if (annotation.sectionProperties.data.id === 'new') {
10571079
this.removeItem(annotation.sectionProperties.data.id);
10581080
}

browser/src/control/Control.PartsPreview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ window.L.Control.PartsPreview = window.L.Control.extend({
480480

481481
_setPart: function (e) {
482482
if (cool.Comment.isAnyEdit()) {
483-
cool.CommentSection.showCommentEditingWarning();
483+
app.sectionContainer.getSectionWithName(app.CSections.CommentList.name).navigateAndFocusComment(cool.Comment.isAnyEdit());
484484
return;
485485
}
486486

browser/src/control/Control.Tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ window.L.Control.Tabs = window.L.Control.extend({
326326
// Set the part by index. Return true if cancelled.
327327
_setPartIndex: function(index) {
328328
if (cool.Comment.isAnyEdit()) {
329-
cool.CommentSection.showCommentEditingWarning();
329+
app.sectionContainer.getSectionWithName(app.CSections.CommentList.name).navigateAndFocusComment(cool.Comment.isAnyEdit());
330330
return true;
331331
}
332332

browser/src/control/Parts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ window.L.Map.include({
2323
*/
2424
setPart: function (part, external, calledFromSetPartHandler) {
2525
if (cool.Comment.isAnyEdit()) {
26-
cool.CommentSection.showCommentEditingWarning();
26+
app.sectionContainer.getSectionWithName(app.CSections.CommentList.name).navigateAndFocusComment(cool.Comment.isAnyEdit());
2727
return;
2828
}
2929

@@ -330,7 +330,7 @@ window.L.Map.include({
330330

331331
insertPage: function(nPos) {
332332
if (cool.Comment.isAnyEdit()) {
333-
cool.CommentSection.showCommentEditingWarning();
333+
app.sectionContainer.getSectionWithName(app.CSections.CommentList.name).navigateAndFocusComment(cool.Comment.isAnyEdit());
334334
return;
335335
}
336336

0 commit comments

Comments
 (0)