Aggregate changes; make accept and reject work.

This commit is contained in:
Paulo Reis 2017-06-01 11:47:55 +01:00
parent 3cf8f26583
commit 11c0644490
2 changed files with 25 additions and 13 deletions

View file

@ -86,8 +86,8 @@
aggregate-change-entry( aggregate-change-entry(
entry="entry" entry="entry"
user="users[entry.metadata.user_id]" user="users[entry.metadata.user_id]"
on-reject="rejectChange(entry_id);" on-reject="rejectAggChange(entry_id, entry.metadata.agg_op_id);"
on-accept="acceptChange(entry_id);" on-accept="acceptAggChange(entry_id, entry.metadata.agg_op_id);"
on-indicator-click="toggleReviewPanel();" on-indicator-click="toggleReviewPanel();"
on-body-click="gotoEntry(editor.open_doc_id, entry)" on-body-click="gotoEntry(editor.open_doc_id, entry)"
permissions="permissions" permissions="permissions"
@ -264,13 +264,11 @@ script(type='text/ng-template', id='aggregateChangeEntryTemplate')
del.rp-content-highlight {{ entry.content }} del.rp-content-highlight {{ entry.content }}
| for | for
ins.rp-content-highlight {{ entry.metadata.agg_op.content }} ins.rp-content-highlight {{ entry.metadata.agg_op.content }}
//- span(ng-switch-when="insert") #{translate("tracked_change_added")}  a.rp-collapse-toggle(
//- ins.rp-content-highlight {{ entry.content | limitTo:(isCollapsed ? contentLimit : entry.content.length) }} href
//- a.rp-collapse-toggle( ng-if="needsCollapsing"
//- href ng-click="toggleCollapse();"
//- ng-if="needsCollapsing" ) {{ isCollapsed ? '... (#{translate("show_all")})' : ' (#{translate("show_less")})' }}
//- ng-click="toggleCollapse();"
//- ) {{ isCollapsed ? '... (#{translate("show_all")})' : ' (#{translate("show_less")})' }}
.rp-entry-metadata .rp-entry-metadata
| {{ entry.metadata.ts | date : 'MMM d, y h:mm a' }} •  | {{ entry.metadata.ts | date : 'MMM d, y h:mm a' }} • 
span.rp-entry-user(style="color: hsl({{ user.hue }}, 70%, 40%);") {{ user.name }} span.rp-entry-user(style="color: hsl({{ user.hue }}, 70%, 40%);") {{ user.name }}

View file

@ -256,6 +256,7 @@ define [
if aggregate_entry if aggregate_entry
new_entry.type = "agg-change" new_entry.type = "agg-change"
new_entry.metadata.agg_op = entries[prev_insertion.id] new_entry.metadata.agg_op = entries[prev_insertion.id]
new_entry.metadata.agg_op_id = prev_insertion.id
delete entries[prev_insertion.id] delete entries[prev_insertion.id]
for key, value of new_entry for key, value of new_entry
@ -356,10 +357,23 @@ define [
$scope.$broadcast "change:reject", entry_id $scope.$broadcast "change:reject", entry_id
event_tracking.sendMB "rp-change-rejected", { view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini' } 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 = () -> bulkAccept = () ->
entry_ids = $scope.reviewPanel.selectedEntryIds.slice() _doAcceptMultipleChanges $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 = [] $scope.reviewPanel.selectedEntryIds = []
event_tracking.sendMB "rp-bulk-accept", { event_tracking.sendMB "rp-bulk-accept", {
view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini', view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini',
@ -367,7 +381,7 @@ define [
} }
bulkReject = () -> bulkReject = () ->
$scope.$broadcast "change:bulk-reject", $scope.reviewPanel.selectedEntryIds.slice() _doRejectMultipleChanges $scope.reviewPanel.selectedEntryIds.slice()
$scope.reviewPanel.selectedEntryIds = [] $scope.reviewPanel.selectedEntryIds = []
event_tracking.sendMB "rp-bulk-reject", { event_tracking.sendMB "rp-bulk-reject", {
view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini', view: if $scope.ui.reviewPanelOpen then $scope.reviewPanel.subView else 'mini',