Merge branch 'ja-track-changes' of github.com:sharelatex/web-sharelatex into ja-track-changes

This commit is contained in:
James Allen 2017-01-10 13:44:01 +01:00
commit 85c613e161
5 changed files with 40 additions and 43 deletions

View file

@ -6,7 +6,7 @@
docs="docs" docs="docs"
on-open="refreshResolvedCommentsDropdown();" on-open="refreshResolvedCommentsDropdown();"
on-unresolve="unresolveComment(threadId);" on-unresolve="unresolveComment(threadId);"
on-delete="deleteComment(entryId);" on-delete="deleteComment(entryId, threadId);"
is-loading="reviewPanel.dropdown.loading" is-loading="reviewPanel.dropdown.loading"
) )
span.review-panel-toolbar-label(ng-click="editor.wantTrackChanges = true;", ng-if="editor.wantTrackChanges === false") Track Changes is span.review-panel-toolbar-label(ng-click="editor.wantTrackChanges = true;", ng-if="editor.wantTrackChanges === false") Track Changes is
@ -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 });" 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);" on-delete="handleDelete(entryId, threadId);"
) )
.rp-loading(ng-if="!resolvedComments.length")
| No resolved threads.

View file

@ -222,9 +222,6 @@ define [
$scope.$broadcast "review-panel:recalculate-screen-positions" $scope.$broadcast "review-panel:recalculate-screen-positions"
$scope.$broadcast "review-panel:layout" $scope.$broadcast "review-panel:layout"
$scope.$on "comment:removed", (comment) ->
console.log comment
$scope.acceptChange = (entry_id) -> $scope.acceptChange = (entry_id) ->
$http.post "/project/#{$scope.project_id}/doc/#{$scope.editor.open_doc_id}/changes/#{entry_id}/accept", {_csrf: window.csrfToken} $http.post "/project/#{$scope.project_id}/doc/#{$scope.editor.open_doc_id}/changes/#{entry_id}/accept", {_csrf: window.csrfToken}
$scope.$broadcast "change:accept", entry_id $scope.$broadcast "change:accept", entry_id
@ -274,7 +271,6 @@ define [
$scope.$broadcast "review-panel:layout" $scope.$broadcast "review-panel:layout"
$scope.resolveComment = (entry, entry_id) -> $scope.resolveComment = (entry, entry_id) ->
entry.showWhenResolved = false
entry.focused = false entry.focused = false
$http.post "/project/#{$scope.project_id}/thread/#{entry.thread_id}/resolve", {_csrf: window.csrfToken} $http.post "/project/#{$scope.project_id}/thread/#{entry.thread_id}/resolve", {_csrf: window.csrfToken}
_onCommentResolved(entry.thread_id, ide.$scope.user) _onCommentResolved(entry.thread_id, ide.$scope.user)
@ -299,19 +295,14 @@ define [
delete resolvedThreadIds[thread_id] delete resolvedThreadIds[thread_id]
$scope.$broadcast "comment:unresolve_thread", thread_id $scope.$broadcast "comment:unresolve_thread", thread_id
$scope.deleteComment = (entry_id) -> _onCommentDeleted = (thread_id) ->
delete $scope.reviewPanel.commentThreads[thread_id]
$scope.deleteComment = (entry_id, thread_id) ->
console.log thread_id
_onCommentDeleted(thread_id)
$scope.$broadcast "comment:remove", entry_id $scope.$broadcast "comment:remove", entry_id
$scope.showThread = (entry) ->
entry.showWhenResolved = true
$timeout () ->
$scope.$broadcast "review-panel:layout"
$scope.hideThread = (entry) ->
entry.showWhenResolved = false
$timeout () ->
$scope.$broadcast "review-panel:layout"
$scope.setSubView = (subView) -> $scope.setSubView = (subView) ->
$scope.reviewPanel.subView = subView $scope.reviewPanel.subView = subView

View file

@ -5,9 +5,6 @@ define [
restrict: "E" restrict: "E"
templateUrl: "resolvedCommentEntryTemplate" templateUrl: "resolvedCommentEntryTemplate"
scope: scope:
entryId: "="
threadId: "="
thread: "=" thread: "="
doc: "="
onUnresolve: "&" onUnresolve: "&"
onDelete: "&" onDelete: "&"

View file

@ -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,28 +23,38 @@ define [
filterResolvedComments() filterResolvedComments()
scope.onOpen() scope.onOpen()
scope.resolvedCommentsPerFile = {} scope.resolvedComments = []
scope.handleUnresolve = (threadId) -> scope.handleUnresolve = (threadId) ->
scope.onUnresolve({ threadId }) scope.onUnresolve({ threadId })
filterResolvedComments() filterResolvedComments()
scope.handleDelete = (entryId) -> scope.handleDelete = (entryId, threadId) ->
scope.onDelete({ entryId }) 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

View file

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