Commit a527f5c2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Notify user when award-emoji comment is invalid

parent bfce5d71
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment