Commit 9c7d821cf752a98f8c7a40056816f6629ca1f734

Authored by Dmitriy Zaporozhets
1 parent 8fc9b5c0

Show selected attachment in comment form

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing 1 changed file with 15 additions and 0 deletions   Show diff stats
app/assets/javascripts/notes.js.coffee
... ... @@ -37,6 +37,9 @@ class Notes
37 37 # attachment button
38 38 $(document).on "click", ".js-choose-note-attachment-button", @chooseNoteAttachment
39 39  
  40 + # update the file name when an attachment is selected
  41 + $(document).on "change", ".js-note-attachment-input", @updateFormAttachment
  42 +
40 43 # reply to diff/discussion notes
41 44 $(document).on "click", ".js-discussion-reply-button", @replyToDiscussionNote
42 45  
... ... @@ -429,4 +432,16 @@ class Notes
429 432 updateVotes: ->
430 433 (new NotesVotes).updateVotes()
431 434  
  435 + ###
  436 + Called after an attachment file has been selected.
  437 +
  438 + Updates the file name for the selected attachment.
  439 + ###
  440 + updateFormAttachment: ->
  441 + form = $(this).closest("form")
  442 +
  443 + # get only the basename
  444 + filename = $(this).val().replace(/^.*[\\\/]/, "")
  445 + form.find(".js-attachment-filename").text filename
  446 +
432 447 @Notes = Notes
... ...