mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Simpler resolved comments dropdown data structure.
This commit is contained in:
parent
9c7d89c5bd
commit
5bd49c08f8
4 changed files with 29 additions and 23 deletions
|
@ -180,7 +180,7 @@ script(type='text/ng-template', id='resolvedCommentEntryTemplate')
|
|||
div
|
||||
.rp-resolved-comment-context
|
||||
| Quoted text on
|
||||
span.rp-resolved-comment-context-file {{ doc.doc.name }}
|
||||
span.rp-resolved-comment-context-file {{ thread.docName }}
|
||||
p.rp-resolved-comment-context-quote {{ thread.content }}
|
||||
.rp-comment(
|
||||
ng-repeat="comment in thread.messages track by comment.id"
|
||||
|
@ -205,12 +205,12 @@ script(type='text/ng-template', id='resolvedCommentEntryTemplate')
|
|||
.rp-entry-actions
|
||||
a.rp-entry-button(
|
||||
href
|
||||
ng-click="onUnresolve({ 'threadId': threadId });"
|
||||
ng-click="onUnresolve({ 'threadId': thread.threadId });"
|
||||
)
|
||||
| Re-open
|
||||
a.rp-entry-button(
|
||||
href
|
||||
ng-click="onDelete({ 'entryId': entryId, 'threadId': threadId });"
|
||||
ng-click="onDelete({ 'entryId': thread.entryId, 'threadId': thread.threadId });"
|
||||
)
|
||||
| Delete
|
||||
|
||||
|
@ -269,15 +269,13 @@ script(type='text/ng-template', id='resolvedCommentsDropdownTemplate')
|
|||
i.fa.fa-spinner.fa-spin
|
||||
div(
|
||||
ng-if="!isLoading"
|
||||
ng-repeat="doc in docs"
|
||||
)
|
||||
resolved-comment-entry(
|
||||
ng-repeat="thread in resolvedCommentsPerFile[doc.doc.id]"
|
||||
entry-id="thread.entryId"
|
||||
thread-id="thread.threadId"
|
||||
ng-repeat="thread in resolvedComments"
|
||||
thread="thread"
|
||||
doc="doc"
|
||||
on-unresolve="handleUnresolve(threadId);"
|
||||
on-delete="handleDelete(entryId, threadId);"
|
||||
)
|
||||
.rp-loading(ng-if="!resolvedComments.length")
|
||||
| No resolved threads.
|
||||
|
||||
|
|
|
@ -5,9 +5,6 @@ define [
|
|||
restrict: "E"
|
||||
templateUrl: "resolvedCommentEntryTemplate"
|
||||
scope:
|
||||
entryId: "="
|
||||
threadId: "="
|
||||
thread: "="
|
||||
doc: "="
|
||||
onUnresolve: "&"
|
||||
onDelete: "&"
|
|
@ -1,7 +1,7 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
App.directive "resolvedCommentsDropdown", () ->
|
||||
App.directive "resolvedCommentsDropdown", (_) ->
|
||||
restrict: "E"
|
||||
templateUrl: "resolvedCommentsDropdownTemplate"
|
||||
scope:
|
||||
|
@ -23,7 +23,7 @@ define [
|
|||
filterResolvedComments()
|
||||
scope.onOpen()
|
||||
|
||||
scope.resolvedCommentsPerFile = {}
|
||||
scope.resolvedComments = []
|
||||
|
||||
scope.handleUnresolve = (threadId) ->
|
||||
scope.onUnresolve({ threadId })
|
||||
|
@ -33,18 +33,28 @@ define [
|
|||
scope.onDelete({ entryId, threadId })
|
||||
filterResolvedComments()
|
||||
|
||||
getDocNameById = (docId) ->
|
||||
doc = _.find(scope.docs, (doc) -> doc.doc.id = docId)
|
||||
if doc?
|
||||
return doc.path
|
||||
else
|
||||
return null
|
||||
|
||||
filterResolvedComments = () ->
|
||||
scope.resolvedCommentsPerFile = {}
|
||||
scope.resolvedComments = []
|
||||
|
||||
for fileId, fileEntries of scope.entries
|
||||
scope.resolvedCommentsPerFile[fileId] = {}
|
||||
for entryId, entry of fileEntries
|
||||
for docId, docEntries of scope.entries
|
||||
for entryId, entry of docEntries
|
||||
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
|
||||
scope.resolvedCommentsPerFile[fileId][entryId].threadId = entry.thread_id
|
||||
scope.resolvedCommentsPerFile[fileId][entryId].entryId = entryId
|
||||
resolvedComment = angular.copy scope.threads[entry.thread_id]
|
||||
|
||||
resolvedComment.content = entry.content
|
||||
resolvedComment.threadId = entry.thread_id
|
||||
resolvedComment.entryId = entryId
|
||||
resolvedComment.docId = docId
|
||||
resolvedComment.docName = getDocNameById(docId)
|
||||
|
||||
scope.resolvedComments.push(resolvedComment)
|
||||
|
||||
scope.$watchCollection "entries", filterResolvedComments
|
||||
scope.$watchCollection "threads", filterResolvedComments
|
||||
|
|
|
@ -498,7 +498,8 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.rp-loading {
|
||||
.rp-loading,
|
||||
.rp-empty {
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
}
|
||||
|
@ -709,7 +710,7 @@
|
|||
margin-left: 1em;
|
||||
background-color: @rp-bg-blue;
|
||||
text-align: left;
|
||||
padding: 5px 5px 0;
|
||||
padding: 5px;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 0 20px 10px rgba(0, 0, 0, .3);
|
||||
|
||||
|
|
Loading…
Reference in a new issue