diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index 6501cf38a89fb9da9f241ec7a3303c48e7dafb6a..69e9e67f71216b07fc338281736f84aff2646fd8 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -37,6 +37,9 @@ class Notes # attachment button $(document).on "click", ".js-choose-note-attachment-button", @chooseNoteAttachment + # update the file name when an attachment is selected + $(document).on "change", ".js-note-attachment-input", @updateFormAttachment + # reply to diff/discussion notes $(document).on "click", ".js-discussion-reply-button", @replyToDiscussionNote @@ -429,4 +432,16 @@ class Notes updateVotes: -> (new NotesVotes).updateVotes() + ### + Called after an attachment file has been selected. + + Updates the file name for the selected attachment. + ### + updateFormAttachment: -> + form = $(this).closest("form") + + # get only the basename + filename = $(this).val().replace(/^.*[\\\/]/, "") + form.find(".js-attachment-filename").text filename + @Notes = Notes