mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge branch 'ja-review-panel' of github.com:sharelatex/web-sharelatex into ja-review-panel
This commit is contained in:
commit
d1b96cea35
5 changed files with 139 additions and 38 deletions
|
@ -23,8 +23,10 @@
|
|||
comment-entry(
|
||||
entry="entry"
|
||||
users="users"
|
||||
on-resolve=""
|
||||
on-reply="submitReply(entry);"
|
||||
on-resolve="resolveComment(entry, entry_id)"
|
||||
on-unresolve="unresolveComment(entry_id)"
|
||||
on-delete="deleteComment(entry_id)"
|
||||
on-reply="submitReply(entry, entry_id);"
|
||||
on-indicator-click="toggleReviewPanel();"
|
||||
)
|
||||
|
||||
|
@ -61,8 +63,10 @@
|
|||
comment-entry(
|
||||
entry="entry"
|
||||
users="users"
|
||||
on-resolve=""
|
||||
on-reply="submitReply(entry);"
|
||||
on-resolve="resolveComment(entry, entry_id)"
|
||||
on-unresolve="unresolveComment(entry_id)"
|
||||
on-delete="deleteComment(entry_id)"
|
||||
on-reply="submitReply(entry, entry_id);"
|
||||
on-indicator-click="toggleReviewPanel();"
|
||||
ng-click="gotoEntry(doc_id, entry)"
|
||||
)
|
||||
|
@ -122,7 +126,7 @@ script(type='text/ng-template', id='changeEntryTemplate')
|
|||
|
||||
script(type='text/ng-template', id='commentEntryTemplate')
|
||||
div
|
||||
.rp-entry-callout.rp-entry-callout-comment
|
||||
.rp-entry-callout.rp-entry-callout-comment(ng-if="!entry.resolved")
|
||||
.rp-entry-indicator(
|
||||
ng-class="{ 'rp-entry-indicator-focused': entry.focused }"
|
||||
ng-click="onIndicatorClick();"
|
||||
|
@ -132,6 +136,7 @@ script(type='text/ng-template', id='commentEntryTemplate')
|
|||
ng-class="entry.focused ? 'rp-entry-focused' : '';"
|
||||
)
|
||||
.rp-comment(
|
||||
ng-if="!entry.resolved || entry.showWhenResolved"
|
||||
ng-repeat="comment in entry.thread"
|
||||
ng-class="users[comment.user_id].isSelf ? 'rp-comment-self' : '';"
|
||||
)
|
||||
|
@ -145,16 +150,24 @@ script(type='text/ng-template', id='commentEntryTemplate')
|
|||
| {{ comment.ts | date : 'MMM d, y h:mm a' }}
|
||||
| •
|
||||
span(style="color: hsl({{ users[comment.user_id].hue }}, 70%, 40%);") {{ users[comment.user_id].name }}
|
||||
.rp-comment-reply
|
||||
.rp-comment-reply(ng-if="!entry.resolved || entry.showWhenResolved")
|
||||
textarea.rp-comment-input(
|
||||
ng-model="entry.replyContent"
|
||||
ng-keypress="handleCommentReplyKeyPress($event);"
|
||||
placeholder="Hit \"Enter\" to reply"
|
||||
placeholder="{{ 'Hit \"Enter\" to reply' + (entry.resolved ? ' and re-open' : '') }}"
|
||||
)
|
||||
.rp-comment-resolved-description(ng-if="entry.resolved && !entry.showWhenResolved")
|
||||
| Resolved Comment
|
||||
a(href, ng-click="entry.showWhenResolved = true") Show
|
||||
.rp-entry-actions
|
||||
a.rp-entry-button(href, ng-click="onResolve();")
|
||||
a.rp-entry-button(href, ng-click="onResolve();", ng-if="!entry.resolved")
|
||||
i.fa.fa-check
|
||||
| Mark as resolved
|
||||
a.rp-entry-button(href, ng-click="onUnresolve();", ng-if="entry.resolved")
|
||||
| Re-open
|
||||
a.rp-entry-button(href, ng-click="onDelete();", ng-if="entry.resolved")
|
||||
| Delete
|
||||
|
||||
|
||||
script(type='text/ng-template', id='addCommentEntryTemplate')
|
||||
div
|
||||
|
|
|
@ -45,6 +45,15 @@ define [
|
|||
@$scope.$on "change:reject", (e, change_id) =>
|
||||
@rejectChangeId(change_id)
|
||||
|
||||
@$scope.$on "comment:remove", (e, comment_id) =>
|
||||
@removeCommentId(comment_id)
|
||||
|
||||
@$scope.$on "comment:resolve", (e, comment_id) =>
|
||||
@resolveCommentId(comment_id)
|
||||
|
||||
@$scope.$on "comment:unresolve", (e, comment_id) =>
|
||||
@unresolveCommentId(comment_id)
|
||||
|
||||
onChange = (e) =>
|
||||
if !@editor.initing and @enabled
|
||||
# This change is trigger by a sharejs 'change' event, which is before the
|
||||
|
@ -92,7 +101,10 @@ define [
|
|||
@changesTracker.off "delete:removed"
|
||||
@changesTracker.off "changes:moved"
|
||||
@changesTracker.off "comment:added"
|
||||
@changesTracker.off "comment:moved"
|
||||
@changesTracker.off "comment:removed"
|
||||
@changesTracker.off "comment:resolved"
|
||||
@changesTracker.off "comment:unresolved"
|
||||
|
||||
connectToChangesTracker: () ->
|
||||
@changesTracker.track_changes = @$scope.trackNewChanges
|
||||
|
@ -119,6 +131,15 @@ define [
|
|||
@changesTracker.on "comment:moved", (comment) =>
|
||||
sl_console.log "[comment:moved]", comment
|
||||
@_onCommentMoved(comment)
|
||||
@changesTracker.on "comment:removed", (comment) =>
|
||||
sl_console.log "[comment:removed]", comment
|
||||
@_onCommentRemoved(comment)
|
||||
@changesTracker.on "comment:resolved", (comment) =>
|
||||
sl_console.log "[comment:resolved]", comment
|
||||
@_onCommentRemoved(comment)
|
||||
@changesTracker.on "comment:unresolved", (comment) =>
|
||||
sl_console.log "[comment:unresolved]", comment
|
||||
@_onCommentAdded(comment)
|
||||
|
||||
redrawAnnotations: () ->
|
||||
for change in @changesTracker.changes
|
||||
|
@ -179,6 +200,14 @@ define [
|
|||
else
|
||||
throw new Error("unknown change: #{JSON.stringify(change)}")
|
||||
|
||||
removeCommentId: (comment_id) ->
|
||||
@changesTracker.removeCommentId(comment_id)
|
||||
|
||||
resolveCommentId: (comment_id) ->
|
||||
@changesTracker.resolveCommentId(comment_id)
|
||||
|
||||
unresolveCommentId: (comment_id) ->
|
||||
@changesTracker.unresolveCommentId(comment_id)
|
||||
|
||||
checkMapping: () ->
|
||||
session = @editor.getSession()
|
||||
|
@ -190,6 +219,7 @@ define [
|
|||
|
||||
expected_markers = []
|
||||
for change in @changesTracker.changes
|
||||
if @changeIdToMarkerIdMap[change.id]?
|
||||
op = change.op
|
||||
{background_marker_id, callout_marker_id} = @changeIdToMarkerIdMap[change.id]
|
||||
start = @_shareJsOffsetToAcePosition(op.p)
|
||||
|
@ -201,6 +231,7 @@ define [
|
|||
expected_markers.push { marker_id: callout_marker_id, start, end: start }
|
||||
|
||||
for comment in @changesTracker.comments
|
||||
if @changeIdToMarkerIdMap[comment.id]?
|
||||
{background_marker_id, callout_marker_id} = @changeIdToMarkerIdMap[comment.id]
|
||||
start = @_shareJsOffsetToAcePosition(comment.offset)
|
||||
end = @_shareJsOffsetToAcePosition(comment.offset + comment.length)
|
||||
|
@ -253,6 +284,7 @@ define [
|
|||
new_entry = {
|
||||
type: "comment"
|
||||
thread: comment.metadata.thread
|
||||
resolved: comment.metadata.resolved
|
||||
offset: comment.offset
|
||||
length: comment.length
|
||||
}
|
||||
|
@ -281,7 +313,7 @@ define [
|
|||
}
|
||||
|
||||
for id, entry of entries
|
||||
if entry.type == "comment"
|
||||
if entry.type == "comment" and not entry.resolved
|
||||
entry.focused = (entry.offset <= cursor_offset <= entry.offset + entry.length)
|
||||
else if entry.type == "insert"
|
||||
entry.focused = (entry.offset <= cursor_offset <= entry.offset + entry.content.length)
|
||||
|
@ -363,6 +395,7 @@ define [
|
|||
|
||||
_onInsertRemoved: (change) ->
|
||||
{background_marker_id, callout_marker_id} = @changeIdToMarkerIdMap[change.id]
|
||||
delete @changeIdToMarkerIdMap[change.id]
|
||||
session = @editor.getSession()
|
||||
session.removeMarker background_marker_id
|
||||
session.removeMarker callout_marker_id
|
||||
|
@ -370,12 +403,15 @@ define [
|
|||
|
||||
_onDeleteRemoved: (change) ->
|
||||
{background_marker_id, callout_marker_id} = @changeIdToMarkerIdMap[change.id]
|
||||
delete @changeIdToMarkerIdMap[change.id]
|
||||
session = @editor.getSession()
|
||||
session.removeMarker background_marker_id
|
||||
session.removeMarker callout_marker_id
|
||||
@updateReviewEntriesScope()
|
||||
|
||||
_onCommentAdded: (comment) ->
|
||||
if !@changeIdToMarkerIdMap[comment.id]?
|
||||
# Only create new markers if they don't already exist
|
||||
start = @_shareJsOffsetToAcePosition(comment.offset)
|
||||
end = @_shareJsOffsetToAcePosition(comment.offset + comment.length)
|
||||
session = @editor.getSession()
|
||||
|
@ -386,6 +422,16 @@ define [
|
|||
@changeIdToMarkerIdMap[comment.id] = { background_marker_id, callout_marker_id }
|
||||
@updateReviewEntriesScope()
|
||||
|
||||
_onCommentRemoved: (comment) ->
|
||||
if @changeIdToMarkerIdMap[comment.id]?
|
||||
# Resolved comments may not have marker ids
|
||||
{background_marker_id, callout_marker_id} = @changeIdToMarkerIdMap[comment.id]
|
||||
delete @changeIdToMarkerIdMap[comment.id]
|
||||
session = @editor.getSession()
|
||||
session.removeMarker background_marker_id
|
||||
session.removeMarker callout_marker_id
|
||||
@updateReviewEntriesScope()
|
||||
|
||||
_aceRangeToShareJs: (range) ->
|
||||
lines = @editor.getSession().getDocument().getLines 0, range.row
|
||||
offset = 0
|
||||
|
@ -436,12 +482,15 @@ define [
|
|||
@updateReviewEntriesScope()
|
||||
|
||||
_updateMarker: (change_id, start, end) ->
|
||||
return if !@changeIdToMarkerIdMap[change_id]?
|
||||
session = @editor.getSession()
|
||||
markers = session.getMarkers()
|
||||
{background_marker_id, callout_marker_id} = @changeIdToMarkerIdMap[change_id]
|
||||
if background_marker_id?
|
||||
background_marker = markers[background_marker_id]
|
||||
background_marker.range.start = start
|
||||
background_marker.range.end = end
|
||||
if callout_marker_id?
|
||||
callout_marker = markers[callout_marker_id]
|
||||
callout_marker.range.start = start
|
||||
callout_marker.range.end = start
|
||||
|
|
|
@ -61,6 +61,32 @@ define [
|
|||
@emit "comment:added", comment
|
||||
return comment
|
||||
|
||||
getComment: (comment_id) ->
|
||||
comment = null
|
||||
for c in @comments
|
||||
if c.id == comment_id
|
||||
comment = c
|
||||
break
|
||||
return comment
|
||||
|
||||
resolveCommentId: (comment_id) ->
|
||||
comment = @getComment(comment_id)
|
||||
return if !comment?
|
||||
comment.metadata.resolved = true
|
||||
@emit "comment:resolved", comment
|
||||
|
||||
unresolveCommentId: (comment_id) ->
|
||||
comment = @getComment(comment_id)
|
||||
return if !comment?
|
||||
comment.metadata.resolved = false
|
||||
@emit "comment:unresolved", comment
|
||||
|
||||
removeCommentId: (comment_id) ->
|
||||
comment = @getComment(comment_id)
|
||||
return if !comment?
|
||||
@comments = @comments.filter (c) -> c.id != comment_id
|
||||
@emit "comment:removed", comment
|
||||
|
||||
getChange: (change_id) ->
|
||||
change = null
|
||||
for c in @changes
|
||||
|
|
|
@ -110,7 +110,8 @@ define [
|
|||
# ev.target.blur()
|
||||
# $scope.submitReply(entry)
|
||||
|
||||
$scope.submitReply = (entry) ->
|
||||
$scope.submitReply = (entry, entry_id) ->
|
||||
$scope.unresolveComment(entry_id)
|
||||
entry.thread.push {
|
||||
content: entry.replyContent
|
||||
ts: new Date()
|
||||
|
@ -142,6 +143,16 @@ define [
|
|||
entry.replyContent = ""
|
||||
$scope.$broadcast "review-panel:layout"
|
||||
|
||||
$scope.resolveComment = (entry, entry_id) ->
|
||||
entry.showWhenResolved = false
|
||||
$scope.$broadcast "comment:resolve", entry_id
|
||||
|
||||
$scope.unresolveComment = (entry_id) ->
|
||||
$scope.$broadcast "comment:unresolve", entry_id
|
||||
|
||||
$scope.deleteComment = (entry_id) ->
|
||||
$scope.$broadcast "comment:remove", entry_id
|
||||
|
||||
$scope.setSubView = (subView) ->
|
||||
$scope.reviewPanel.subView = subView
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ define [
|
|||
onResolve: "&"
|
||||
onReply: "&"
|
||||
onIndicatorClick: "&"
|
||||
onDelete: "&"
|
||||
onUnresolve: "&"
|
||||
link: (scope, element, attrs) ->
|
||||
scope.handleCommentReplyKeyPress = (ev) ->
|
||||
if ev.keyCode == 13 and !ev.shiftKey and !ev.ctrlKey and !ev.metaKey
|
||||
|
|
Loading…
Reference in a new issue