Count entries within selection; only show bulk actions if there are selected entries.

This commit is contained in:
Paulo Reis 2017-05-02 17:02:30 +01:00
parent b7d5faed77
commit 3f441ff38c
3 changed files with 11 additions and 1 deletions

View file

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

View file

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

View file

@ -7,6 +7,7 @@ define [
scope:
onBulkAccept: "&"
onBulkReject: "&"
nEntries: "="
link: (scope, element, attrs) ->
scope.bulkAccept = () ->
scope.onBulkAccept()