mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Count entries within selection; only show bulk actions if there are selected entries.
This commit is contained in:
parent
b7d5faed77
commit
3f441ff38c
3 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ define [
|
|||
scope:
|
||||
onBulkAccept: "&"
|
||||
onBulkReject: "&"
|
||||
nEntries: "="
|
||||
link: (scope, element, attrs) ->
|
||||
scope.bulkAccept = () ->
|
||||
scope.onBulkAccept()
|
||||
|
|
Loading…
Reference in a new issue