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