Notify user when award-emoji comment is invalid

This commit is contained in:
Grzegorz Bizon 2015-12-02 10:51:46 +01:00
parent bfce5d7168
commit a527f5c27f
2 changed files with 10 additions and 1 deletions

View File

@ -111,6 +111,10 @@ class @Notes
Note: for rendering inline notes use renderDiscussionNote
###
renderNote: (note) ->
unless note.valid
alert('You have already used this award emoji !') if note.award
return
# render note if it not present in loaded list
# or skip if rendered
if @isNewNote(note) && !note.award

View File

@ -133,6 +133,7 @@ class Projects::NotesController < Projects::ApplicationController
def render_note_json(note)
if note.valid?
render json: {
valid: true,
id: note.id,
discussion_id: note.discussion_id,
html: note_to_html(note),
@ -143,7 +144,11 @@ class Projects::NotesController < Projects::ApplicationController
discussion_with_diff_html: note_to_discussion_with_diff_html(note)
}
else
render json: { invalid: true, errors: note.errors }
render json: {
valid: false,
award: note.is_award,
errors: note.errors
}
end
end