Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2016-06-09 02:38:29 +0300
committerJacob Schatz <jschatz@gitlab.com>2016-06-09 02:38:29 +0300
commite382f13068bc4301c5483ace92cfff266558670d (patch)
tree91362c219d2dde1bcfb14bcef3b3ec7738264071 /app/assets/javascripts
parentcc54b74a3cffc366ad67bd2c4d645f35d1b04e52 (diff)
parentae736d81e1f64fe9439ac0675538d359cfdb5be9 (diff)
Merge branch '17284-Edit-form-does-not-cancel-correctly' into 'master'
#17284 Edit form does not cancel correctly ## What does this MR do? Replaces the markdown textarea with the currently saved note text when the note edit is cancelled. ## Are there points in the code the reviewer needs to double check? No ## Why was this MR needed? Allows the user to revert back to the original note text, as expected, using cancel. ## What are the relevant issue numbers? Fixes #17284. ## Screenshots ![17284](/uploads/c3598de6f8e70d52275ef25907d92d42/17284.gif) See merge request !4175
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/notes.js.coffee13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index 8e33e915ba5..ad216910c8d 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -354,8 +354,7 @@ class @Notes
Called in response to clicking the edit note link
Replaces the note text with the note edit form
- Adds a hidden div with the original content of the note to fill the edit note form with
- if the user cancels
+ Adds a data attribute to the form with the original content of the note for cancellations
###
showEditForm: (e, scrollTo, myLastNote) ->
e.preventDefault()
@@ -371,6 +370,8 @@ class @Notes
done = ($noteText) ->
# Neat little trick to put the cursor at the end
noteTextVal = $noteText.val()
+ # Store the original note text in a data attribute to retrieve if a user cancels edit.
+ form.find('form.edit-note').data 'original-note', noteTextVal
$noteText.val('').val(noteTextVal);
new GLForm form
@@ -393,14 +394,16 @@ class @Notes
###
Called in response to clicking the edit note link
- Hides edit form
+ Hides edit form and restores the original note text to the editor textarea.
###
cancelEdit: (e) ->
e.preventDefault()
note = $(this).closest(".note")
+ form = note.find(".current-note-edit-form")
note.removeClass "is-editting"
- note.find(".current-note-edit-form")
- .removeClass("current-note-edit-form")
+ form.removeClass("current-note-edit-form")
+ # Replace markdown textarea text with original note text.
+ form.find(".js-note-text").val(form.find('form.edit-note').data('original-note'))
###
Called in response to deleting a note of any kind.