Add basic comment replying

This commit is contained in:
James Allen 2016-11-09 15:25:41 +00:00
parent 707ed43a7d
commit 6d7f4e9e6a
3 changed files with 38 additions and 14 deletions

View file

@ -51,15 +51,23 @@ div.full-size(
.review-panel-scroller
.review-entry-list(review-panel-sorted)
.review-entry(ng-repeat="(entry_id, entry) in reviewPanel.entries", ng-style="{'top': top}")
div(ng-if="entry.type != 'focus-position'")
div(ng-if="entry.type == 'change'")
div.small {{ entry.metadata.ts }}
{{ entry.content }}
div(ng-if="entry.type == 'comment'")
div(ng-repeat="comment in entry.thread", class="comment-thread__comment")
div.small {{ comment.ts }}
div.small {{ comment.user_id }}
{{ comment.content }}
div(ng-if="entry.replying")
textarea(ng-model="entry.replyContent")
a.btn.btn-sm.btn-primary(href, ng-click="submitReply(entry)") Submit
a.btn.btn-sm.btn-primary(href, ng-click="startReply(entry)", ng-if="!entry.replying") Reply
div(ng-if="entry.type == 'focus-position'")
a.btn.btn-sm(href, ng-if="!commentState.adding", ng-click="startAddingComment()") Add comment
a.btn.btn-sm(href, ng-if="!commentState.adding", ng-click="startNewComment()") Add comment
div(ng-if="commentState.adding")
textarea(ng-model="commentState.content")
a.btn.btn-sm.btm-primary(href, ng-click="submitComment()") Submit
a.btn.btn-sm.btn-primary(href, ng-click="submitNewComment()") Submit
.ui-layout-east
div(ng-if="ui.pdfLayout == 'sideBySide'")

View file

@ -89,18 +89,21 @@ define [
turn_off_tracking: () ->
@changesTracker.track_changes = false
addComment: (offset, length, comment) ->
addComment: (offset, length, content) ->
@changesTracker.addComment offset, length, {
comment: comment
user_id: window.user_id
thread: [{
content: content
user_id: window.user_id
ts: new Date()
}]
}
addCommentToSelection: (comment) ->
addCommentToSelection: (content) ->
range = @editor.getSelectionRange()
offset = @_aceRangeToShareJs(range.start)
end = @_aceRangeToShareJs(range.end)
length = end - offset
@addComment(offset, length, comment)
@addComment(offset, length, content)
selectLineIfNoSelection: () ->
if @editor.selection.isEmpty()
@ -163,7 +166,7 @@ define [
for comment in @changesTracker.comments
@$scope.reviewPanel.entries[comment.id] = {
type: "comment"
content: comment.metadata.comment
thread: comment.metadata.thread
offset: comment.offset
}
@updateFocus()

View file

@ -60,11 +60,24 @@ define [
scroller.scrollTop(scroller.scrollTop() + deltaY * 4)
e.preventDefault()
$scope.startAddingComment = () ->
$scope.startNewComment = () ->
$scope.commentState.adding = true
$scope.$broadcast "comment:select_line"
$scope.submitComment = () ->
$scope.submitNewComment = () ->
$scope.commentState.adding = false
console.log "ADDING COMMENT", $scope.commentState.content
$scope.$broadcast "comment:add", $scope.commentState.content
$scope.$broadcast "comment:add", $scope.commentState.content
$scope.commentState.content = ""
$scope.startReply = (entry) ->
console.log "Start new reply"
entry.replying = true
$scope.submitReply = (entry) ->
entry.thread.push {
content: entry.replyContent
ts: new Date()
user_id: window.user_id
}
entry.replyContent = ""
entry.replying = false