summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/notes.js.coffee15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index 6501cf38a89..69e9e67f712 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