From d874eb70f8a2c3bba78eeb583910f2cc146684d9 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 2 May 2017 15:34:05 +0100 Subject: [PATCH 01/23] Add and remove bulk accept and reject entries with selections. --- .../app/views/project/editor/review-panel.pug | 4 ++++ .../controllers/ReviewPanelController.coffee | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index 2035af4775..132cce7232 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -82,6 +82,10 @@ on-submit="submitNewComment(content);" on-cancel="cancelNewComment();" ) + div(ng-if="entry.type === 'bulk-accept'") + | Bulk accept + div(ng-if="entry.type === 'bulk-reject'") + | Bulk reject .rp-entry-list( ng-if="reviewPanel.subView === SubViews.OVERVIEW" diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index bf3f96ffc3..4bce7facc8 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -159,7 +159,7 @@ define [ entries = $scope.reviewPanel.entries[$scope.editor.open_doc_id] or {} permEntries = {} for entry, entryData of entries - if entry != "add-comment" + if entry not in [ "add-comment", "bulk-accept", "bulk-reject" ] permEntries[entry] = entryData Object.keys(permEntries).length ), (nEntries) -> @@ -285,12 +285,25 @@ define [ entries = getDocEntries(doc_id) delete entries["add-comment"] + delete entries["bulk-accept"] + delete entries["bulk-reject"] + if selection entries["add-comment"] = { type: "add-comment" offset: selection_offset_start length: selection_offset_end - selection_offset_start } + entries["bulk-accept"] = { + type: "bulk-accept" + offset: selection_offset_start + length: selection_offset_end - selection_offset_start + } + entries["bulk-reject"] = { + type: "bulk-reject" + offset: selection_offset_start + length: selection_offset_end - selection_offset_start + } for id, entry of entries if entry.type == "comment" and not $scope.reviewPanel.resolvedThreadIds[entry.thread_id] @@ -299,7 +312,7 @@ define [ entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length) else if entry.type == "delete" entry.focused = (entry.offset == selection_offset_start) - else if entry.type == "add-comment" and selection + else if entry.type in [ "add-comment", "bulk-accept", "bulk-reject" ] and selection entry.focused = true $scope.$broadcast "review-panel:recalculate-screen-positions" From 76ea497b339cbfd9fefd7a543a7df3ee077fe070 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 2 May 2017 15:43:45 +0100 Subject: [PATCH 02/23] Use a single entry for bulk actions. --- .../app/views/project/editor/review-panel.pug | 6 ++---- .../controllers/ReviewPanelController.coffee | 16 +++++----------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index 132cce7232..c87a5016af 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -82,10 +82,8 @@ on-submit="submitNewComment(content);" on-cancel="cancelNewComment();" ) - div(ng-if="entry.type === 'bulk-accept'") - | Bulk accept - div(ng-if="entry.type === 'bulk-reject'") - | Bulk reject + div(ng-if="entry.type === 'bulk-actions'") + | Bulk actions. .rp-entry-list( ng-if="reviewPanel.subView === SubViews.OVERVIEW" diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 4bce7facc8..c5cef1eaba 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -159,7 +159,7 @@ define [ entries = $scope.reviewPanel.entries[$scope.editor.open_doc_id] or {} permEntries = {} for entry, entryData of entries - if entry not in [ "add-comment", "bulk-accept", "bulk-reject" ] + if entry not in [ "add-comment", "bulk-actions" ] permEntries[entry] = entryData Object.keys(permEntries).length ), (nEntries) -> @@ -285,8 +285,7 @@ define [ entries = getDocEntries(doc_id) delete entries["add-comment"] - delete entries["bulk-accept"] - delete entries["bulk-reject"] + delete entries["bulk-actions"] if selection entries["add-comment"] = { @@ -294,13 +293,8 @@ define [ offset: selection_offset_start length: selection_offset_end - selection_offset_start } - entries["bulk-accept"] = { - type: "bulk-accept" - offset: selection_offset_start - length: selection_offset_end - selection_offset_start - } - entries["bulk-reject"] = { - type: "bulk-reject" + entries["bulk-actions"] = { + type: "bulk-actions" offset: selection_offset_start length: selection_offset_end - selection_offset_start } @@ -312,7 +306,7 @@ define [ entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length) else if entry.type == "delete" entry.focused = (entry.offset == selection_offset_start) - else if entry.type in [ "add-comment", "bulk-accept", "bulk-reject" ] and selection + else if entry.type in [ "add-comment", "bulk-actions" ] and selection entry.focused = true $scope.$broadcast "review-panel:recalculate-screen-positions" From e2eaf6619e4f5e4f1b2252e08892aac6deb09b31 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 2 May 2017 16:15:40 +0100 Subject: [PATCH 03/23] Bulk actions directive; include it in the review panel. --- .../app/views/project/editor/review-panel.pug | 22 ++++++++++++++++++- .../review-panel/ReviewPanelManager.coffee | 1 + .../directives/bulkActionsEntry.coffee | 14 ++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index c87a5016af..ded551dbda 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -83,7 +83,10 @@ on-cancel="cancelNewComment();" ) div(ng-if="entry.type === 'bulk-actions'") - | Bulk actions. + bulk-actions-entry( + on-bulk-accept="bulkAccept();" + on-bulk-reject="bulkAccept();" + ) .rp-entry-list( ng-if="reviewPanel.subView === SubViews.OVERVIEW" @@ -355,6 +358,23 @@ script(type='text/ng-template', id='addCommentEntryTemplate') i.fa.fa-comment |  #{translate("comment")} +script(type='text/ng-template', id='bulkActionsEntryTemplate') + div + .rp-entry-callout.rp-entry-callout-bulk-actions + .rp-entry.rp-entry-bulk-actions + a.rp-bulk-actions-btn( + href + ng-click="bulkReject();" + ) + i.fa.fa-times + |  #{translate("reject_all")} + a.rp-bulk-actions-btn( + href + ng-click="bulkAccept();" + ) + i.fa.fa-check + |  #{translate("accept_all")} + script(type='text/ng-template', id='resolvedCommentsDropdownTemplate') .resolved-comments .resolved-comments-backdrop( diff --git a/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee b/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee index 9b622ffa05..289f291b1f 100644 --- a/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee +++ b/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee @@ -6,6 +6,7 @@ define [ "ide/review-panel/directives/changeEntry" "ide/review-panel/directives/commentEntry" "ide/review-panel/directives/addCommentEntry" + "ide/review-panel/directives/bulkActionsEntry" "ide/review-panel/directives/resolvedCommentEntry" "ide/review-panel/directives/resolvedCommentsDropdown" "ide/review-panel/directives/reviewPanelCollapseHeight" diff --git a/services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee b/services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee new file mode 100644 index 0000000000..3adf27ffed --- /dev/null +++ b/services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee @@ -0,0 +1,14 @@ +define [ + "base" +], (App) -> + App.directive "bulkActionsEntry", () -> + restrict: "E" + templateUrl: "bulkActionsEntryTemplate" + scope: + onBulkAccept: "&" + onBulkReject: "&" + link: (scope, element, attrs) -> + scope.bulkAccept = () -> + scope.onBulkAccept() + scope.bulkReject = () -> + scope.onBulkReject() \ No newline at end of file From b7d5faed77e9ff7247b7f1889a43c7811622dabb Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 2 May 2017 16:15:52 +0100 Subject: [PATCH 04/23] Basic bulk actions styling. --- .../stylesheets/app/editor/review-panel.less | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/services/web/public/stylesheets/app/editor/review-panel.less b/services/web/public/stylesheets/app/editor/review-panel.less index 59f0e40566..8faee01eae 100644 --- a/services/web/public/stylesheets/app/editor/review-panel.less +++ b/services/web/public/stylesheets/app/editor/review-panel.less @@ -277,6 +277,9 @@ right: 5px; } } + &-bulk-actions { + right: auto; + } } .rp-state-overview & { border-radius: 0; @@ -335,6 +338,12 @@ border-left-color: @rp-yellow; } } + + &-bulk-actions { + background-color: transparent; + right: auto; + border-left-width: 0; + } } .rp-entry-body { display: flex; @@ -451,7 +460,8 @@ padding: 0 5px; } - .rp-add-comment-btn { + .rp-add-comment-btn, + .rp-bulk-actions-btn { .rp-button(); display: block; padding: 5px 10px; @@ -464,6 +474,19 @@ } } + .rp-bulk-actions-btn { + display: inline-block; + border-radius: 0; + &:first-child { + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; + } + &:last-child { + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + } + } + .rp-new-comment { padding: 5px; } From 3f441ff38c7065a782c68a05f66c8724afe5aaf3 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 2 May 2017 17:02:30 +0100 Subject: [PATCH 05/23] Count entries within selection; only show bulk actions if there are selected entries. --- services/web/app/views/project/editor/review-panel.pug | 5 ++++- .../review-panel/controllers/ReviewPanelController.coffee | 6 ++++++ .../ide/review-panel/directives/bulkActionsEntry.coffee | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index ded551dbda..235207a50a 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -86,6 +86,7 @@ bulk-actions-entry( on-bulk-accept="bulkAccept();" on-bulk-reject="bulkAccept();" + n-entries="reviewPanel.nSelectedEntries" ) .rp-entry-list( @@ -359,7 +360,7 @@ script(type='text/ng-template', id='addCommentEntryTemplate') |  #{translate("comment")} script(type='text/ng-template', id='bulkActionsEntryTemplate') - div + div(ng-if="nEntries > 0") .rp-entry-callout.rp-entry-callout-bulk-actions .rp-entry.rp-entry-bulk-actions a.rp-bulk-actions-btn( @@ -368,12 +369,14 @@ script(type='text/ng-template', id='bulkActionsEntryTemplate') ) i.fa.fa-times |  #{translate("reject_all")} + | ({{ nEntries }}) a.rp-bulk-actions-btn( href ng-click="bulkAccept();" ) i.fa.fa-check |  #{translate("accept_all")} + | ({{ nEntries }}) script(type='text/ng-template', id='resolvedCommentsDropdownTemplate') .resolved-comments diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index c5cef1eaba..023921e44f 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -26,6 +26,7 @@ define [ resolvedThreadIds: {} rendererData: {} loadingThreads: false + nSelectedEntries: 0 window.addEventListener "beforeunload", () -> collapsedStates = {} @@ -283,6 +284,7 @@ define [ $scope.$on "editor:focus:changed", (e, selection_offset_start, selection_offset_end, selection) -> doc_id = $scope.editor.open_doc_id entries = getDocEntries(doc_id) + $scope.reviewPanel.nSelectedEntries = 0 delete entries["add-comment"] delete entries["bulk-actions"] @@ -303,9 +305,13 @@ define [ if entry.type == "comment" and not $scope.reviewPanel.resolvedThreadIds[entry.thread_id] entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length) else if entry.type == "insert" + isEntryWithinSelection = entry.offset >= selection_offset_start and entry.offset + entry.content.length <= selection_offset_end entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length) + $scope.reviewPanel.nSelectedEntries++ if isEntryWithinSelection else if entry.type == "delete" + isEntryWithinSelection = selection_offset_start <= entry.offset >= selection_offset_start entry.focused = (entry.offset == selection_offset_start) + $scope.reviewPanel.nSelectedEntries++ if isEntryWithinSelection else if entry.type in [ "add-comment", "bulk-actions" ] and selection entry.focused = true diff --git a/services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee b/services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee index 3adf27ffed..4c206ab635 100644 --- a/services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee +++ b/services/web/public/coffee/ide/review-panel/directives/bulkActionsEntry.coffee @@ -7,6 +7,7 @@ define [ scope: onBulkAccept: "&" onBulkReject: "&" + nEntries: "=" link: (scope, element, attrs) -> scope.bulkAccept = () -> scope.onBulkAccept() From 722d75f6ef33370bb93cf885dd86cd37fb8630e8 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 2 May 2017 17:08:41 +0100 Subject: [PATCH 06/23] Correctly check if deletions are within selection. --- .../ide/review-panel/controllers/ReviewPanelController.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 023921e44f..d3d4684a4c 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -309,7 +309,7 @@ define [ entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length) $scope.reviewPanel.nSelectedEntries++ if isEntryWithinSelection else if entry.type == "delete" - isEntryWithinSelection = selection_offset_start <= entry.offset >= selection_offset_start + isEntryWithinSelection = selection_offset_start <= entry.offset <= selection_offset_end entry.focused = (entry.offset == selection_offset_start) $scope.reviewPanel.nSelectedEntries++ if isEntryWithinSelection else if entry.type in [ "add-comment", "bulk-actions" ] and selection From 0249a13012464260fc51a3fb741d581763b7c617 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 3 May 2017 11:41:17 +0100 Subject: [PATCH 07/23] Add bulk actions as in-editor widgets. --- .../app/views/project/editor/review-panel.pug | 19 ++++++++++++++++++- .../stylesheets/app/editor/review-panel.less | 12 ++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index 235207a50a..a9e12eaaed 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -6,6 +6,22 @@ ng-click="toggleReviewPanel();" ng-class="{ 'rp-track-changes-indicator-on-dark' : darkTheme }" ) !{translate("track_changes_is_on")} + a.rp-bulk-actions-btn( + href + ng-if="reviewPanel.nSelectedEntries > 0" + ng-click="bulkAccept();" + ) + i.fa.fa-check + |  #{translate("accept_all")} + | ({{ reviewPanel.nSelectedEntries }}) + a.rp-bulk-actions-btn( + href + ng-if="reviewPanel.nSelectedEntries > 0" + ng-click="bulkReject();" + ) + i.fa.fa-times + |  #{translate("reject_all")} + | ({{ reviewPanel.nSelectedEntries }}) a.rp-add-comment-btn( href ng-if="reviewPanel.entries[editor.open_doc_id]['add-comment'] != null" @@ -13,6 +29,7 @@ ) i.fa.fa-comment |  #{translate("add_comment")} + .review-panel-toolbar resolved-comments-dropdown( class="rp-flex-block" @@ -85,7 +102,7 @@ div(ng-if="entry.type === 'bulk-actions'") bulk-actions-entry( on-bulk-accept="bulkAccept();" - on-bulk-reject="bulkAccept();" + on-bulk-reject="bulkReject();" n-entries="reviewPanel.nSelectedEntries" ) diff --git a/services/web/public/stylesheets/app/editor/review-panel.less b/services/web/public/stylesheets/app/editor/review-panel.less index 8faee01eae..6d503fea3f 100644 --- a/services/web/public/stylesheets/app/editor/review-panel.less +++ b/services/web/public/stylesheets/app/editor/review-panel.less @@ -463,19 +463,22 @@ .rp-add-comment-btn, .rp-bulk-actions-btn { .rp-button(); - display: block; + display: inline-block; padding: 5px 10px; border-radius: 3px; .rp-in-editor-widgets & { + display: block; white-space: nowrap; border-radius: 0; - border-bottom-left-radius: 3px; + + &:last-child { + border-bottom-left-radius: 3px; + } } } .rp-bulk-actions-btn { - display: inline-block; border-radius: 0; &:first-child { border-top-left-radius: 3px; @@ -484,9 +487,10 @@ &:last-child { border-top-right-radius: 3px; border-bottom-right-radius: 3px; + margin-left: 1px; } } - + .rp-new-comment { padding: 5px; } From bf7bf701ed7283b08b1562ae90f6644cc48eb262 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 3 May 2017 16:35:58 +0100 Subject: [PATCH 08/23] Store selected entries; improve visibility logic. --- services/web/app/views/project/editor/review-panel.pug | 10 +++++----- .../controllers/ReviewPanelController.coffee | 8 ++++---- .../public/stylesheets/app/editor/review-panel.less | 7 +++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index a9e12eaaed..c2617c452a 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -8,20 +8,20 @@ ) !{translate("track_changes_is_on")} a.rp-bulk-actions-btn( href - ng-if="reviewPanel.nSelectedEntries > 0" + ng-if="reviewPanel.selectedEntries.length > 0" ng-click="bulkAccept();" ) i.fa.fa-check |  #{translate("accept_all")} - | ({{ reviewPanel.nSelectedEntries }}) + | ({{ reviewPanel.selectedEntries.length }}) a.rp-bulk-actions-btn( href - ng-if="reviewPanel.nSelectedEntries > 0" + ng-if="reviewPanel.selectedEntries.length > 0" ng-click="bulkReject();" ) i.fa.fa-times |  #{translate("reject_all")} - | ({{ reviewPanel.nSelectedEntries }}) + | ({{ reviewPanel.selectedEntries.length }}) a.rp-add-comment-btn( href ng-if="reviewPanel.entries[editor.open_doc_id]['add-comment'] != null" @@ -103,7 +103,7 @@ bulk-actions-entry( on-bulk-accept="bulkAccept();" on-bulk-reject="bulkReject();" - n-entries="reviewPanel.nSelectedEntries" + n-entries="reviewPanel.selectedEntries.length" ) .rp-entry-list( diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index d3d4684a4c..7a86d5db43 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -26,7 +26,7 @@ define [ resolvedThreadIds: {} rendererData: {} loadingThreads: false - nSelectedEntries: 0 + selectedEntries: [] window.addEventListener "beforeunload", () -> collapsedStates = {} @@ -284,7 +284,7 @@ define [ $scope.$on "editor:focus:changed", (e, selection_offset_start, selection_offset_end, selection) -> doc_id = $scope.editor.open_doc_id entries = getDocEntries(doc_id) - $scope.reviewPanel.nSelectedEntries = 0 + $scope.reviewPanel.selectedEntries = [] delete entries["add-comment"] delete entries["bulk-actions"] @@ -307,11 +307,11 @@ define [ else if entry.type == "insert" isEntryWithinSelection = entry.offset >= selection_offset_start and entry.offset + entry.content.length <= selection_offset_end entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length) - $scope.reviewPanel.nSelectedEntries++ if isEntryWithinSelection + $scope.reviewPanel.selectedEntries.push entry if isEntryWithinSelection else if entry.type == "delete" isEntryWithinSelection = selection_offset_start <= entry.offset <= selection_offset_end entry.focused = (entry.offset == selection_offset_start) - $scope.reviewPanel.nSelectedEntries++ if isEntryWithinSelection + $scope.reviewPanel.selectedEntries.push entry if isEntryWithinSelection else if entry.type in [ "add-comment", "bulk-actions" ] and selection entry.focused = true diff --git a/services/web/public/stylesheets/app/editor/review-panel.less b/services/web/public/stylesheets/app/editor/review-panel.less index 6d503fea3f..018a402015 100644 --- a/services/web/public/stylesheets/app/editor/review-panel.less +++ b/services/web/public/stylesheets/app/editor/review-panel.less @@ -930,6 +930,9 @@ .rp-size-mini & { right: @review-off-width; } + .rp-size-expanded & { + display: none; + } } .rp-track-changes-indicator { display: block; @@ -958,10 +961,6 @@ background-color: rgba(240, 240, 240, 1); color: @rp-type-blue; } - - .rp-size-expanded & { - display: none; - } } // Helper class for elements which aren't treated as flex-items by IE10, e.g: From 05d9bf47d1e567e776a453123b15c134c51c8666 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 3 May 2017 16:53:04 +0100 Subject: [PATCH 09/23] Use entry ids instead. --- .../web/app/views/project/editor/review-panel.pug | 10 +++++----- .../controllers/ReviewPanelController.coffee | 14 ++++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index c2617c452a..89d62c3ba3 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -8,20 +8,20 @@ ) !{translate("track_changes_is_on")} a.rp-bulk-actions-btn( href - ng-if="reviewPanel.selectedEntries.length > 0" + ng-if="reviewPanel.selectedEntryIds.length > 0" ng-click="bulkAccept();" ) i.fa.fa-check |  #{translate("accept_all")} - | ({{ reviewPanel.selectedEntries.length }}) + | ({{ reviewPanel.selectedEntryIds.length }}) a.rp-bulk-actions-btn( href - ng-if="reviewPanel.selectedEntries.length > 0" + ng-if="reviewPanel.selectedEntryIds.length > 0" ng-click="bulkReject();" ) i.fa.fa-times |  #{translate("reject_all")} - | ({{ reviewPanel.selectedEntries.length }}) + | ({{ reviewPanel.selectedEntryIds.length }}) a.rp-add-comment-btn( href ng-if="reviewPanel.entries[editor.open_doc_id]['add-comment'] != null" @@ -103,7 +103,7 @@ bulk-actions-entry( on-bulk-accept="bulkAccept();" on-bulk-reject="bulkReject();" - n-entries="reviewPanel.selectedEntries.length" + n-entries="reviewPanel.selectedEntryIds.length" ) .rp-entry-list( diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 7a86d5db43..474a680b07 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -26,7 +26,7 @@ define [ resolvedThreadIds: {} rendererData: {} loadingThreads: false - selectedEntries: [] + selectedEntryIds: [] window.addEventListener "beforeunload", () -> collapsedStates = {} @@ -284,7 +284,7 @@ define [ $scope.$on "editor:focus:changed", (e, selection_offset_start, selection_offset_end, selection) -> doc_id = $scope.editor.open_doc_id entries = getDocEntries(doc_id) - $scope.reviewPanel.selectedEntries = [] + $scope.reviewPanel.selectedEntryIds = [] delete entries["add-comment"] delete entries["bulk-actions"] @@ -307,11 +307,11 @@ define [ else if entry.type == "insert" isEntryWithinSelection = entry.offset >= selection_offset_start and entry.offset + entry.content.length <= selection_offset_end entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length) - $scope.reviewPanel.selectedEntries.push entry if isEntryWithinSelection + $scope.reviewPanel.selectedEntryIds.push id if isEntryWithinSelection else if entry.type == "delete" isEntryWithinSelection = selection_offset_start <= entry.offset <= selection_offset_end entry.focused = (entry.offset == selection_offset_start) - $scope.reviewPanel.selectedEntries.push entry if isEntryWithinSelection + $scope.reviewPanel.selectedEntryIds.push id if isEntryWithinSelection else if entry.type in [ "add-comment", "bulk-actions" ] and selection entry.focused = true @@ -327,6 +327,12 @@ define [ $scope.$broadcast "change:reject", entry_id event_tracking.sendMB "rp-change-rejected", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' } + $scope.bulkAccept = () -> + console.log $scope.reviewPanel.selectedEntryIds + + $scope.bulkReject = () -> + console.log $scope.reviewPanel.selectedEntryIds + $scope.addNewComment = () -> $scope.$broadcast "comment:start_adding" $scope.toggleReviewPanel() From dae66d5edff76cbb76e94d8397076688046610f7 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 3 May 2017 17:16:29 +0100 Subject: [PATCH 10/23] Add bulk methods in controller. --- .../controllers/ReviewPanelController.coffee | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 474a680b07..552b03f374 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -328,10 +328,20 @@ define [ event_tracking.sendMB "rp-change-rejected", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' } $scope.bulkAccept = () -> - console.log $scope.reviewPanel.selectedEntryIds + $scope.$broadcast "change:bulk-accept", $scope.reviewPanel.selectedEntryIds.slice() + $scope.reviewPanel.selectedEntryIds = [] + event_tracking.sendMB "rp-bulk-accept", { + view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini', + nEntries: $scope.reviewPanel.selectedEntryIds.length + } $scope.bulkReject = () -> - console.log $scope.reviewPanel.selectedEntryIds + $scope.$broadcast "change:bulk-reject", $scope.reviewPanel.selectedEntryIds.slice() + $scope.reviewPanel.selectedEntryIds = [] + event_tracking.sendMB "rp-bulk-reject", { + view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini', + nEntries: $scope.reviewPanel.selectedEntryIds.length + } $scope.addNewComment = () -> $scope.$broadcast "comment:start_adding" From 8f6d11632b3e0add74c60949afd5a28a649862be Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 3 May 2017 17:16:41 +0100 Subject: [PATCH 11/23] Add bulk rejection support. --- .../track-changes/TrackChangesManager.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee index 0dd6a9f06b..5c98c23f0e 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee @@ -31,6 +31,12 @@ define [ @$scope.$on "change:reject", (e, change_id) => @rejectChangeId(change_id) + + @$scope.$on "change:bulk-accept", (e, change_ids) => + @bulkAcceptChangeIds(change_ids) + + @$scope.$on "change:bulk-reject", (e, change_ids) => + @bulkRejectChangeIds(change_ids) @$scope.$on "comment:remove", (e, comment_id) => @removeCommentId(comment_id) @@ -233,6 +239,13 @@ define [ else throw new Error("unknown change: #{JSON.stringify(change)}") + bulkAcceptChangeIds: (change_ids) -> + console.log change_id for change_id in change_ids + + bulkRejectChangeIds: (change_ids) -> + for change_id in change_ids + @rejectChangeId change_id + removeCommentId: (comment_id) -> @rangesTracker.removeCommentId(comment_id) @updateAnnotations() From 6662ec34aee74ac45f9597bd10413c728de96ad9 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 4 May 2017 11:30:05 +0100 Subject: [PATCH 12/23] Only show bulk actions when n changes > 1. --- services/web/app/views/project/editor/review-panel.pug | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index 89d62c3ba3..baaa583a07 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -8,7 +8,7 @@ ) !{translate("track_changes_is_on")} a.rp-bulk-actions-btn( href - ng-if="reviewPanel.selectedEntryIds.length > 0" + ng-if="reviewPanel.selectedEntryIds.length > 1" ng-click="bulkAccept();" ) i.fa.fa-check @@ -16,7 +16,7 @@ | ({{ reviewPanel.selectedEntryIds.length }}) a.rp-bulk-actions-btn( href - ng-if="reviewPanel.selectedEntryIds.length > 0" + ng-if="reviewPanel.selectedEntryIds.length > 1" ng-click="bulkReject();" ) i.fa.fa-times @@ -377,7 +377,7 @@ script(type='text/ng-template', id='addCommentEntryTemplate') |  #{translate("comment")} script(type='text/ng-template', id='bulkActionsEntryTemplate') - div(ng-if="nEntries > 0") + div(ng-if="nEntries > 1") .rp-entry-callout.rp-entry-callout-bulk-actions .rp-entry.rp-entry-bulk-actions a.rp-bulk-actions-btn( From 19828d3c5b278bb33bd16b1c81db991c73bb69fc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 4 May 2017 15:33:47 +0100 Subject: [PATCH 13/23] Basic bulk accept support. --- .../DocumentUpdaterHandler.coffee | 19 +++++++++++++++++++ .../track-changes/TrackChangesManager.coffee | 3 --- .../controllers/ReviewPanelController.coffee | 4 +++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee index 595fe07971..2f1de61852 100644 --- a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee +++ b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee @@ -153,6 +153,25 @@ module.exports = DocumentUpdaterHandler = logger.error {project_id, doc_id, change_id}, "doc updater returned a non-success status code: #{res.statusCode}" callback new Error("doc updater returned a non-success status code: #{res.statusCode}") + bulkAcceptChanges: (project_id, doc_id, change_ids, callback = (error) ->) -> + timer = new metrics.Timer("bulk-accept-changes") + reqSettings = + url: "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/accept" + json: + change_ids: change_ids + logger.log {project_id, doc_id }, "bulk accepting #{ change_ids.length } changes" + request.post reqSettings, (error, res, body)-> + timer.done() + if error? + logger.error {err:error, project_id, doc_id }, "error accepting #{ change_ids.length } changes in doc updater" + return callback(error) + if res.statusCode >= 200 and res.statusCode < 300 + logger.log {project_id, doc_id }, "accepted #{ change_ids.length } changes in document updater" + return callback(null) + else + logger.error {project_id, doc_id }, "doc updater returned a non-success status code: #{res.statusCode}" + callback new Error("doc updater returned a non-success status code: #{res.statusCode}") + deleteThread: (project_id, doc_id, thread_id, callback = (error) ->) -> timer = new metrics.Timer("delete-thread") url = "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/comment/#{thread_id}" diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee index 5c98c23f0e..4c5f5fa96a 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee @@ -32,9 +32,6 @@ define [ @$scope.$on "change:reject", (e, change_id) => @rejectChangeId(change_id) - @$scope.$on "change:bulk-accept", (e, change_ids) => - @bulkAcceptChangeIds(change_ids) - @$scope.$on "change:bulk-reject", (e, change_ids) => @bulkRejectChangeIds(change_ids) diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 552b03f374..2636060a47 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -328,7 +328,9 @@ define [ event_tracking.sendMB "rp-change-rejected", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' } $scope.bulkAccept = () -> - $scope.$broadcast "change:bulk-accept", $scope.reviewPanel.selectedEntryIds.slice() + entry_ids = $scope.reviewPanel.selectedEntryIds.slice() + $http.post "/project/#{$scope.project_id}/doc/#{$scope.editor.open_doc_id}/changes/accept", { change_ids: entry_ids, _csrf: window.csrfToken} + $scope.$broadcast "change:bulk-accept", entry_ids $scope.reviewPanel.selectedEntryIds = [] event_tracking.sendMB "rp-bulk-accept", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini', From f25db3ff64eba1356d4696812ee3e9d3b2661cfb Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 4 May 2017 15:47:25 +0100 Subject: [PATCH 14/23] Reflect accepted changes on the UI layer. --- .../aceEditor/track-changes/TrackChangesManager.coffee | 7 ++++++- .../controllers/ReviewPanelController.coffee | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee index 4c5f5fa96a..9eedb93eb9 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee @@ -32,6 +32,9 @@ define [ @$scope.$on "change:reject", (e, change_id) => @rejectChangeId(change_id) + @$scope.$on "change:bulk-accept", (e, change_ids) => + @bulkAcceptChangeIds(change_ids) + @$scope.$on "change:bulk-reject", (e, change_ids) => @bulkRejectChangeIds(change_ids) @@ -237,7 +240,9 @@ define [ throw new Error("unknown change: #{JSON.stringify(change)}") bulkAcceptChangeIds: (change_ids) -> - console.log change_id for change_id in change_ids + for change_id in change_ids + @rangesTracker.removeChangeId(change_id) + @updateAnnotations() bulkRejectChangeIds: (change_ids) -> for change_id in change_ids diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 2636060a47..bf5841c11b 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -77,6 +77,15 @@ define [ $scope.$broadcast "change:accept", change_id updateEntries(doc_id) $scope.$apply () -> + + ide.socket.on "bulk-accept-changes", (doc_id, change_ids) -> + if doc_id != $scope.editor.open_doc_id + for change_id in change_ids + getChangeTracker(doc_id).removeChangeId(change_id) + else + $scope.$broadcast "change:bulk-accept", change_ids + updateEntries(doc_id) + $scope.$apply () -> ide.socket.on "resolve-thread", (thread_id, user) -> _onCommentResolved(thread_id, user) From 3ced808411cfad2678875a7401bf68a323c483dc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 5 May 2017 15:19:31 +0100 Subject: [PATCH 15/23] Use a single accept changes method. --- .../DocumentUpdaterHandler.coffee | 22 +++---------------- .../controllers/ReviewPanelController.coffee | 2 +- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee index 2f1de61852..2de1e3b780 100644 --- a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee +++ b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee @@ -137,29 +137,13 @@ module.exports = DocumentUpdaterHandler = logger.error project_id:project_id, doc_id:doc_id, url: url, "doc updater returned a non-success status code: #{res.statusCode}" callback new Error("doc updater returned a non-success status code: #{res.statusCode}") - acceptChange: (project_id, doc_id, change_id, callback = (error) ->) -> - timer = new metrics.Timer("accept-change") - url = "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/#{change_id}/accept" - logger.log {project_id, doc_id, change_id}, "accepting change in document updater" - request.post url, (error, res, body)-> - timer.done() - if error? - logger.error {err:error, project_id, doc_id, change_id}, "error accepting change in doc updater" - return callback(error) - if res.statusCode >= 200 and res.statusCode < 300 - logger.log {project_id, doc_id, change_id}, "accepted change in document updater" - return callback(null) - else - logger.error {project_id, doc_id, change_id}, "doc updater returned a non-success status code: #{res.statusCode}" - callback new Error("doc updater returned a non-success status code: #{res.statusCode}") - - bulkAcceptChanges: (project_id, doc_id, change_ids, callback = (error) ->) -> - timer = new metrics.Timer("bulk-accept-changes") + acceptChanges: (project_id, doc_id, change_ids = [], callback = (error) ->) -> + timer = new metrics.Timer("accept-changes") reqSettings = url: "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/accept" json: change_ids: change_ids - logger.log {project_id, doc_id }, "bulk accepting #{ change_ids.length } changes" + logger.log {project_id, doc_id }, "accepting #{ change_ids.length } changes" request.post reqSettings, (error, res, body)-> timer.done() if error? diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index bf5841c11b..107eec2086 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -78,7 +78,7 @@ define [ updateEntries(doc_id) $scope.$apply () -> - ide.socket.on "bulk-accept-changes", (doc_id, change_ids) -> + ide.socket.on "accept-changes", (doc_id, change_ids) -> if doc_id != $scope.editor.open_doc_id for change_id in change_ids getChangeTracker(doc_id).removeChangeId(change_id) From 03b8b72520d97be3a26455bf70154bf884367490 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 8 May 2017 16:10:08 +0100 Subject: [PATCH 16/23] Update range tracker with new bulk method. --- .../coffee/ide/review-panel/RangesTracker.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/web/public/coffee/ide/review-panel/RangesTracker.coffee b/services/web/public/coffee/ide/review-panel/RangesTracker.coffee index 14193f628d..f589098440 100644 --- a/services/web/public/coffee/ide/review-panel/RangesTracker.coffee +++ b/services/web/public/coffee/ide/review-panel/RangesTracker.coffee @@ -100,6 +100,21 @@ load = () -> change = @getChange(change_id) return if !change? @_removeChange(change) + + removeChangeIds: (change_to_remove_ids) -> + return if !change_to_remove_ids?.length > 0 + i = @changes.length + remove_change_id = {} + for change_id in change_to_remove_ids + remove_change_id[change_id] = true + + while (i--) + if remove_change_id[@changes[i].id] + delete remove_change_id[@changes[i].id] + removed_change = @changes.splice(i, 1)[0] + @_markAsDirty removed_change, "change", "removed" + if Object.keys(remove_change_id).length == 0 + break validate: (text) -> for change in @changes From 499272cbb547e06212e5ae44df3020fd4eefbfd5 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 8 May 2017 16:12:21 +0100 Subject: [PATCH 17/23] Use new range-tracker method. --- .../aceEditor/track-changes/TrackChangesManager.coffee | 3 +-- .../ide/review-panel/controllers/ReviewPanelController.coffee | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee index 9eedb93eb9..61d12d74df 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee @@ -240,8 +240,7 @@ define [ throw new Error("unknown change: #{JSON.stringify(change)}") bulkAcceptChangeIds: (change_ids) -> - for change_id in change_ids - @rangesTracker.removeChangeId(change_id) + @rangesTracker.removeChangeIds(change_ids) @updateAnnotations() bulkRejectChangeIds: (change_ids) -> diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 107eec2086..64c75f4340 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -80,8 +80,7 @@ define [ ide.socket.on "accept-changes", (doc_id, change_ids) -> if doc_id != $scope.editor.open_doc_id - for change_id in change_ids - getChangeTracker(doc_id).removeChangeId(change_id) + getChangeTracker(doc_id).removeChangeIds(change_ids) else $scope.$broadcast "change:bulk-accept", change_ids updateEntries(doc_id) From f3e020df7ed4fabb915df42a8eb0972d91f0850f Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 9 May 2017 16:06:19 +0100 Subject: [PATCH 18/23] Add dialog to confirm bulk actions. --- .../app/views/project/editor/review-panel.pug | 29 ++++++++++++++++--- .../BulkActionsModalController.coffee | 10 +++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 services/web/public/coffee/ide/review-panel/controllers/BulkActionsModalController.coffee diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index baaa583a07..47e21eb848 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -9,7 +9,7 @@ a.rp-bulk-actions-btn( href ng-if="reviewPanel.selectedEntryIds.length > 1" - ng-click="bulkAccept();" + ng-click="showBulkAcceptDialog();" ) i.fa.fa-check |  #{translate("accept_all")} @@ -17,7 +17,7 @@ a.rp-bulk-actions-btn( href ng-if="reviewPanel.selectedEntryIds.length > 1" - ng-click="bulkReject();" + ng-click="showBulkRejectDialog();" ) i.fa.fa-times |  #{translate("reject_all")} @@ -101,8 +101,8 @@ ) div(ng-if="entry.type === 'bulk-actions'") bulk-actions-entry( - on-bulk-accept="bulkAccept();" - on-bulk-reject="bulkReject();" + on-bulk-accept="showBulkAcceptDialog();" + on-bulk-reject="showBulkRejectDialog();" n-entries="reviewPanel.selectedEntryIds.length" ) @@ -475,3 +475,24 @@ script(type="text/ng-template", id="trackChangesUpgradeModalTemplate") ng-click="cancel()" ) span #{translate("close")} + +script(type="text/ng-template", id="bulkActionsModalTemplate") + .modal-header + button.close( + type="button" + data-dismiss="modal" + ng-click="cancel()" + ) × + h3 {{ isAccept ? '#{translate("accept_all")}' : '#{translate("reject_all")}' }} + .modal-body + p(ng-if="isAccept") #{translate("bulk_accept_confirm", { nChanges: "{{ nChanges }}"})} + p(ng-if="!isAccept") #{translate("bulk_reject_confirm", { nChanges: "{{ nChanges }}"})} + .modal-footer() + button.btn.btn-default( + ng-click="cancel()" + ) + span #{translate("cancel")} + button.btn.btn-primary( + ng-click="confirm()" + ) + span #{translate("ok")} diff --git a/services/web/public/coffee/ide/review-panel/controllers/BulkActionsModalController.coffee b/services/web/public/coffee/ide/review-panel/controllers/BulkActionsModalController.coffee new file mode 100644 index 0000000000..575fcb9716 --- /dev/null +++ b/services/web/public/coffee/ide/review-panel/controllers/BulkActionsModalController.coffee @@ -0,0 +1,10 @@ +define [ + "base" +], (App) -> + App.controller "BulkActionsModalController", ($scope, $modalInstance, isAccept, nChanges) -> + $scope.isAccept = isAccept + $scope.nChanges = nChanges + $scope.cancel = () -> + $modalInstance.dismiss() + $scope.confirm = () -> + $modalInstance.close(isAccept) \ No newline at end of file From 8aee0edfe8f0c85f994bb3306d7e2f1c5aae0a8d Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 9 May 2017 16:06:34 +0100 Subject: [PATCH 19/23] Integrate bulk actions dialog with controller actions. --- .../review-panel/ReviewPanelManager.coffee | 1 + .../controllers/ReviewPanelController.coffee | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee b/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee index 289f291b1f..420c9c6139 100644 --- a/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee +++ b/services/web/public/coffee/ide/review-panel/ReviewPanelManager.coffee @@ -1,6 +1,7 @@ define [ "ide/review-panel/controllers/ReviewPanelController" "ide/review-panel/controllers/TrackChangesUpgradeModalController" + "ide/review-panel/controllers/BulkActionsModalController" "ide/review-panel/directives/reviewPanelSorted" "ide/review-panel/directives/reviewPanelToggle" "ide/review-panel/directives/changeEntry" diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 64c75f4340..478b50bd9e 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -335,7 +335,7 @@ define [ $scope.$broadcast "change:reject", entry_id event_tracking.sendMB "rp-change-rejected", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' } - $scope.bulkAccept = () -> + bulkAccept = () -> entry_ids = $scope.reviewPanel.selectedEntryIds.slice() $http.post "/project/#{$scope.project_id}/doc/#{$scope.editor.open_doc_id}/changes/accept", { change_ids: entry_ids, _csrf: window.csrfToken} $scope.$broadcast "change:bulk-accept", entry_ids @@ -345,7 +345,7 @@ define [ nEntries: $scope.reviewPanel.selectedEntryIds.length } - $scope.bulkReject = () -> + bulkReject = () -> $scope.$broadcast "change:bulk-reject", $scope.reviewPanel.selectedEntryIds.slice() $scope.reviewPanel.selectedEntryIds = [] event_tracking.sendMB "rp-bulk-reject", { @@ -353,6 +353,26 @@ define [ nEntries: $scope.reviewPanel.selectedEntryIds.length } + $scope.showBulkAcceptDialog = () -> + console.log "showBulkAcceptDialog" + showBulkActionsDialog true + + $scope.showBulkRejectDialog = () -> showBulkActionsDialog false + + showBulkActionsDialog = (isAccept) -> + $modal.open({ + templateUrl: "bulkActionsModalTemplate" + controller: "BulkActionsModalController" + resolve: + isAccept: () -> isAccept + nChanges: () -> $scope.reviewPanel.selectedEntryIds.length + scope: $scope.$new() + }).result.then (isAccept) -> + if isAccept + bulkAccept() + else + bulkReject() + $scope.addNewComment = () -> $scope.$broadcast "comment:start_adding" $scope.toggleReviewPanel() From 658e70a77262acb794755a83383964870225a579 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 11 May 2017 11:32:12 +0100 Subject: [PATCH 20/23] Update ranges tracker. --- .../ide/review-panel/RangesTracker.coffee | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/services/web/public/coffee/ide/review-panel/RangesTracker.coffee b/services/web/public/coffee/ide/review-panel/RangesTracker.coffee index f589098440..4174dcdab0 100644 --- a/services/web/public/coffee/ide/review-panel/RangesTracker.coffee +++ b/services/web/public/coffee/ide/review-panel/RangesTracker.coffee @@ -108,13 +108,16 @@ load = () -> for change_id in change_to_remove_ids remove_change_id[change_id] = true - while (i--) - if remove_change_id[@changes[i].id] - delete remove_change_id[@changes[i].id] - removed_change = @changes.splice(i, 1)[0] - @_markAsDirty removed_change, "change", "removed" - if Object.keys(remove_change_id).length == 0 - break + remaining_changes = [] + + for change in @changes + if remove_change_id[change.id] + delete remove_change_id[change.id] + @_markAsDirty change, "change", "removed" + else + remaining_changes.push change + + @changes = remaining_changes validate: (text) -> for change in @changes From dd85c2fab2c87df831ce579011346c7f3dd3fcc4 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 12 May 2017 15:44:49 +0100 Subject: [PATCH 21/23] Remove debug line. --- .../ide/review-panel/controllers/ReviewPanelController.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 478b50bd9e..29ac6e3d1b 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -354,7 +354,6 @@ define [ } $scope.showBulkAcceptDialog = () -> - console.log "showBulkAcceptDialog" showBulkActionsDialog true $scope.showBulkRejectDialog = () -> showBulkActionsDialog false From 7bb5d65b52994d320056ec8016c284544bce2786 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 15 May 2017 11:11:28 +0100 Subject: [PATCH 22/23] Update ranges tracker. --- .../coffee/ide/review-panel/RangesTracker.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/services/web/public/coffee/ide/review-panel/RangesTracker.coffee b/services/web/public/coffee/ide/review-panel/RangesTracker.coffee index 4174dcdab0..869d63159b 100644 --- a/services/web/public/coffee/ide/review-panel/RangesTracker.coffee +++ b/services/web/public/coffee/ide/review-panel/RangesTracker.coffee @@ -96,6 +96,20 @@ load = () -> break return change + getChanges: (change_ids) -> + changes_response = [] + ids_map = {} + + for change_id in change_ids + ids_map[change_id] = true + + for change in @changes + if ids_map[change.id] + delete ids_map[change.id] + changes_response.push change + + return changes_response + removeChangeId: (change_id) -> change = @getChange(change_id) return if !change? From f4e46bb2f949a57b662426b8c2ec5926631f5a5b Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 15 May 2017 11:24:40 +0100 Subject: [PATCH 23/23] Use new ranges tracker method to get N changes at once; small refactor. --- .../track-changes/TrackChangesManager.coffee | 61 ++++++++----------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee index 61d12d74df..4d293dcd4b 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee @@ -27,16 +27,16 @@ define [ @selectLineIfNoSelection() @$scope.$on "change:accept", (e, change_id) => - @acceptChangeId(change_id) + @acceptChangeIds([ change_id ]) @$scope.$on "change:reject", (e, change_id) => - @rejectChangeId(change_id) + @rejectChangeIds([ change_id ]) @$scope.$on "change:bulk-accept", (e, change_ids) => - @bulkAcceptChangeIds(change_ids) + @acceptChangeIds(change_ids) @$scope.$on "change:bulk-reject", (e, change_ids) => - @bulkRejectChangeIds(change_ids) + @rejectChangeIds(change_ids) @$scope.$on "comment:remove", (e, comment_id) => @removeCommentId(comment_id) @@ -213,39 +213,32 @@ define [ if @editor.selection.isEmpty() @editor.selection.selectLine() - acceptChangeId: (change_id) -> - @rangesTracker.removeChangeId(change_id) - @updateAnnotations() - - rejectChangeId: (change_id) -> - change = @rangesTracker.getChange(change_id) - return if !change? - session = @editor.getSession() - if change.op.d? - content = change.op.d - position = @_shareJsOffsetToAcePosition(change.op.p) - session.$fromReject = true # Tell track changes to cancel out delete - session.insert(position, content) - session.$fromReject = false - else if change.op.i? - start = @_shareJsOffsetToAcePosition(change.op.p) - end = @_shareJsOffsetToAcePosition(change.op.p + change.op.i.length) - editor_text = session.getDocument().getTextRange({start, end}) - if editor_text != change.op.i - throw new Error("Op to be removed (#{JSON.stringify(change.op)}), does not match editor text, '#{editor_text}'") - session.$fromReject = true - session.remove({start, end}) - session.$fromReject = false - else - throw new Error("unknown change: #{JSON.stringify(change)}") - - bulkAcceptChangeIds: (change_ids) -> + acceptChangeIds: (change_ids) -> @rangesTracker.removeChangeIds(change_ids) @updateAnnotations() - bulkRejectChangeIds: (change_ids) -> - for change_id in change_ids - @rejectChangeId change_id + rejectChangeIds: (change_ids) -> + changes = @rangesTracker.getChanges(change_ids) + return if changes.length == 0 + session = @editor.getSession() + for change in changes + if change.op.d? + content = change.op.d + position = @_shareJsOffsetToAcePosition(change.op.p) + session.$fromReject = true # Tell track changes to cancel out delete + session.insert(position, content) + session.$fromReject = false + else if change.op.i? + start = @_shareJsOffsetToAcePosition(change.op.p) + end = @_shareJsOffsetToAcePosition(change.op.p + change.op.i.length) + editor_text = session.getDocument().getTextRange({start, end}) + if editor_text != change.op.i + throw new Error("Op to be removed (#{JSON.stringify(change.op)}), does not match editor text, '#{editor_text}'") + session.$fromReject = true + session.remove({start, end}) + session.$fromReject = false + else + throw new Error("unknown change: #{JSON.stringify(change)}") removeCommentId: (comment_id) -> @rangesTracker.removeCommentId(comment_id)