Merge pull request #420 from sharelatex/ja-track-changes

List track changes in beta program
This commit is contained in:
James Allen 2017-02-14 14:41:57 +01:00 committed by GitHub
commit bb3589ab2d
7 changed files with 25 additions and 17 deletions

View file

@ -18,11 +18,9 @@ block content
| #{translate("beta_program_badge_description")}
span.beta-feature-badge
p.text-centered
| #{translate("beta_program_current_beta_features_description")}
ul.list-unstyled.text-center
li
i.fa.fa-fw.fa-book
|  #{translate("syntax_checking")}
strong We're currently testing track changes and commenting:
p.text-centered
img(src="/img/teasers/track-changes/track-changes-beta.png", style="max-width: 100%; border-bottom: 1px solid #ddd")
.row.text-centered
.col-md-12
if user.betaProgram

View file

@ -92,7 +92,9 @@ header.toolbar.toolbar-header.toolbar-with-labels(
ng-click="toggleReviewPanel()"
)
i.review-icon
p.toolbar-label Review
p.toolbar-label
| Review
span(style="vertical-align: 20%; margin-left: 4px; padding: 2px 4px;").beta-feature-badge
a.btn.btn-full-height(
href,
ng-if="permissions.admin",

View file

@ -332,6 +332,7 @@ script(type='text/ng-template', id='addCommentEntryTemplate')
ng-keypress="handleCommentKeyPress($event);"
placeholder="Add your comment here"
focus-on="comment:new:open"
ng-blur="submitNewComment()"
)
.rp-entry-actions
button.rp-entry-button(

View file

@ -20,8 +20,8 @@ define [
@rangesTracker = doc.ranges
@connectToRangesTracker()
@$scope.$on "comment:add", (e, thread_id) =>
@addCommentToSelection(thread_id)
@$scope.$on "comment:add", (e, thread_id, offset, length) =>
@addCommentToSelection(thread_id, offset, length)
@$scope.$on "comment:select_line", (e) =>
@selectLineIfNoSelection()
@ -45,7 +45,7 @@ define [
@recalculateReviewEntriesScreenPositions()
changingSelection = false
onChangeSelection = (args...) =>
onChangeSelection = () =>
# Deletes can send about 5 changeSelection events, so
# just act on the last one.
if !changingSelection
@ -53,7 +53,6 @@ define [
@$scope.$evalAsync () =>
changingSelection = false
@updateFocus()
@recalculateReviewEntriesScreenPositions()
onResize = () =>
@recalculateReviewEntriesScreenPositions()
@ -64,11 +63,13 @@ define [
bindToAce = () =>
@editor.on "changeSelection", onChangeSelection
@editor.on "change", onChangeSelection # Selection also moves with updates elsewhere in the document
@editor.on "changeSession", onChangeSession
@editor.renderer.on "resize", onResize
unbindFromAce = () =>
@editor.off "changeSelection", onChangeSelection
@editor.off "change", onChangeSelection
@editor.off "changeSession", onChangeSession
@editor.renderer.off "resize", onResize
@ -174,10 +175,11 @@ define [
# @rangesTracker.applyOp op # Will apply via sharejs
@$scope.sharejsDoc.submitOp op
addCommentToSelection: (thread_id) ->
range = @editor.getSelectionRange()
content = @editor.getSelectedText()
offset = @_aceRangeToShareJs(range.start)
addCommentToSelection: (thread_id, offset, length) ->
start = @_shareJsOffsetToAcePosition(offset)
end = @_shareJsOffsetToAcePosition(offset + length)
range = new Range(start.row, start.column, end.row, end.column)
content = @editor.session.getTextRange(range)
@addComment(offset, content, thread_id)
selectLineIfNoSelection: () ->

View file

@ -280,6 +280,7 @@ define [
entries["add-comment"] = {
type: "add-comment"
offset: selection_offset_start
length: selection_offset_end - selection_offset_start
}
for id, entry of entries
@ -310,10 +311,15 @@ define [
$scope.$broadcast "review-panel:layout"
$scope.submitNewComment = (content) ->
return if !content? or content == ""
doc_id = $scope.editor.open_doc_id
entries = getDocEntries(doc_id)
return if !entries["add-comment"]?
{offset, length} = entries["add-comment"]
thread_id = RangesTracker.generateId()
thread = getThread(thread_id)
thread.submitting = true
$scope.$broadcast "comment:add", thread_id
$scope.$broadcast "comment:add", thread_id, offset, length
$http.post("/project/#{$scope.project_id}/thread/#{thread_id}/messages", {content, _csrf: window.csrfToken})
.error (error) ->
ide.showGenericMessageModal("Error submitting comment", "Sorry, there was a problem submitting your comment")

View file

@ -28,10 +28,9 @@ define [
if ev.keyCode == 13 and !ev.shiftKey and !ev.ctrlKey and !ev.metaKey
ev.preventDefault()
if scope.state.content.length > 0
ev.target.blur()
scope.submitNewComment()
scope.submitNewComment = () ->
scope.onSubmit { content: scope.state.content }
scope.state.isAdding = false
scope.state.content = ""
scope.state.content = ""

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB