From 11c0644490bfd124c45e00cf20c94948db355b9b Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 1 Jun 2017 11:47:55 +0100 Subject: [PATCH] Aggregate changes; make accept and reject work. --- .../app/views/project/editor/review-panel.pug | 16 ++++++-------- .../controllers/ReviewPanelController.coffee | 22 +++++++++++++++---- 2 files changed, 25 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 2a12f567b4..2366cedc06 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -86,8 +86,8 @@ aggregate-change-entry( entry="entry" user="users[entry.metadata.user_id]" - on-reject="rejectChange(entry_id);" - on-accept="acceptChange(entry_id);" + on-reject="rejectAggChange(entry_id, entry.metadata.agg_op_id);" + on-accept="acceptAggChange(entry_id, entry.metadata.agg_op_id);" on-indicator-click="toggleReviewPanel();" on-body-click="gotoEntry(editor.open_doc_id, entry)" permissions="permissions" @@ -264,13 +264,11 @@ script(type='text/ng-template', id='aggregateChangeEntryTemplate') del.rp-content-highlight {{ entry.content }} | for ins.rp-content-highlight {{ entry.metadata.agg_op.content }} - //- span(ng-switch-when="insert") #{translate("tracked_change_added")}  - //- ins.rp-content-highlight {{ entry.content | limitTo:(isCollapsed ? contentLimit : entry.content.length) }} - //- a.rp-collapse-toggle( - //- href - //- ng-if="needsCollapsing" - //- ng-click="toggleCollapse();" - //- ) {{ isCollapsed ? '... (#{translate("show_all")})' : ' (#{translate("show_less")})' }} + a.rp-collapse-toggle( + href + ng-if="needsCollapsing" + ng-click="toggleCollapse();" + ) {{ isCollapsed ? '... (#{translate("show_all")})' : ' (#{translate("show_less")})' }} .rp-entry-metadata | {{ entry.metadata.ts | date : 'MMM d, y h:mm a' }} •  span.rp-entry-user(style="color: hsl({{ user.hue }}, 70%, 40%);") {{ user.name }} 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 a08e8a93cb..c296bc9c72 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -256,6 +256,7 @@ define [ if aggregate_entry new_entry.type = "agg-change" new_entry.metadata.agg_op = entries[prev_insertion.id] + new_entry.metadata.agg_op_id = prev_insertion.id delete entries[prev_insertion.id] for key, value of new_entry @@ -356,10 +357,23 @@ 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.acceptAggChange = (entry_id1, entry_id2) -> + _doAcceptMultipleChanges [ entry_id1, entry_id2 ] + event_tracking.sendMB "rp-agg-change-accepted", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' } + + $scope.rejectAggChange = (entry_id1, entry_id2) -> + _doRejectMultipleChanges [ entry_id1, entry_id2 ] + event_tracking.sendMB "rp-agg-change-rejected", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' } + + _doAcceptMultipleChanges = (change_ids) -> + $http.post "/project/#{$scope.project_id}/doc/#{$scope.editor.open_doc_id}/changes/accept", { change_ids, _csrf: window.csrfToken} + $scope.$broadcast "change:bulk-accept", change_ids + + _doRejectMultipleChanges = (change_ids) -> + $scope.$broadcast "change:bulk-reject", change_ids + 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 + _doAcceptMultipleChanges $scope.reviewPanel.selectedEntryIds.slice() $scope.reviewPanel.selectedEntryIds = [] event_tracking.sendMB "rp-bulk-accept", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini', @@ -367,7 +381,7 @@ define [ } bulkReject = () -> - $scope.$broadcast "change:bulk-reject", $scope.reviewPanel.selectedEntryIds.slice() + _doRejectMultipleChanges $scope.reviewPanel.selectedEntryIds.slice() $scope.reviewPanel.selectedEntryIds = [] event_tracking.sendMB "rp-bulk-reject", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini',