Avoid empty comment submission.

This commit is contained in:
Paulo Reis 2017-01-16 17:14:06 +00:00
parent 121629426e
commit 36f15ff56e
3 changed files with 13 additions and 6 deletions

View file

@ -204,7 +204,8 @@ script(type='text/ng-template', id='commentEntryTemplate')
button.rp-entry-button(
ng-click="onReply();"
ng-if="permissions.comment"
ng-disabled="!entry.replyContent.length")
ng-disabled="!entry.replyContent.length"
)
i.fa.fa-reply
|  Reply
@ -284,10 +285,15 @@ script(type='text/ng-template', id='addCommentEntryTemplate')
focus-on="comment:new:open"
)
.rp-entry-actions
a.rp-entry-button(href, ng-click="cancelNewComment();")
button.rp-entry-button(
ng-click="cancelNewComment();"
)
i.fa.fa-times
|  Cancel
a.rp-entry-button(href, ng-click="submitNewComment()")
button.rp-entry-button(
ng-click="submitNewComment()"
ng-disabled="!state.content.length"
)
i.fa.fa-comment
|  Comment

View file

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

View file

@ -18,7 +18,7 @@ define [
scope.handleCommentReplyKeyPress = (ev) ->
if ev.keyCode == 13 and !ev.shiftKey and !ev.ctrlKey and !ev.metaKey
ev.preventDefault()
if scope.entry.length > 0
if scope.entry.replyContent.length > 0
ev.target.blur()
scope.onReply()