Use entry ids instead.

This commit is contained in:
Paulo Reis 2017-05-03 16:53:04 +01:00
parent bf7bf701ed
commit 05d9bf47d1
2 changed files with 15 additions and 9 deletions

View file

@ -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(

View file

@ -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()