overleaf/services/web/public/coffee/ide/review-panel/directives/resolvedCommentsDropdown.coffee

45 lines
1.3 KiB
CoffeeScript
Raw Normal View History

define [
"base"
], (App) ->
App.directive "resolvedCommentsDropdown", () ->
restrict: "E"
templateUrl: "resolvedCommentsDropdownTemplate"
scope:
entries : "="
threads : "="
docs : "="
onOpen : "&"
2017-01-09 12:22:01 -05:00
onUnresolve : "&"
isLoading : "="
link: (scope, element, attrs) ->
scope.state =
isOpen: false
scope.toggleOpenState = () ->
scope.state.isOpen = !scope.state.isOpen
if (scope.state.isOpen)
scope.onOpen()
scope.resolvedCommentsPerFile = {}
2017-01-09 12:22:01 -05:00
scope.handleUnresolve = (threadId) ->
scope.onUnresolve({ threadId })
filterResolvedComments()
filterResolvedComments = () ->
scope.resolvedCommentsPerFile = {}
for fileId, fileEntries of scope.entries
scope.resolvedCommentsPerFile[fileId] = {}
for entryId, entry of fileEntries
2017-01-06 10:24:33 -05:00
if entry.type == "comment" and scope.threads[entry.thread_id]?.resolved?
scope.resolvedCommentsPerFile[fileId][entryId] = angular.copy scope.threads[entry.thread_id]
scope.resolvedCommentsPerFile[fileId][entryId].content = entry.content
2017-01-09 12:22:01 -05:00
scope.resolvedCommentsPerFile[fileId][entryId].threadId = entry.thread_id
scope.$watchCollection "entries", filterResolvedComments
scope.$watchCollection "threads", filterResolvedComments