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
path: root/app
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-10-02 00:10:01 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-10-02 00:10:52 +0300
commit8366ce364c3c777474adfdd3721976cb4c963030 (patch)
tree011dc497006c463c4fa0e5531dd09ff898e15346 /app
parent529cf138a18b33aea35aab5a7b72f705df5e2982 (diff)
parentb35dd6b908c790d2724f0147d3af28dbae0a4a52 (diff)
Merge branch 'rs-update-note' into 'master'
Ensure updated notes are syntax highlighted See merge request !1444
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/notes.js.coffee16
-rw-r--r--app/models/note.rb2
-rw-r--r--app/views/projects/notes/_note.html.haml4
3 files changed, 13 insertions, 9 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index ce638c2641b..4b9f0d68912 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -277,13 +277,15 @@ class @Notes
Updates the current note field.
###
- updateNote: (xhr, note, status) =>
- note_li = $(".note-row-" + note.id)
- note_li.replaceWith(note.html)
- note_li.find('.note-edit-form').hide()
- note_li.find('.note-body > .note-text').show()
- note_li.find('js-task-list-container').taskList('enable')
- @enableTaskList()
+ updateNote: (_xhr, note, _status) =>
+ # Convert returned HTML to a jQuery object so we can modify it further
+ $html = $(note.html)
+ $html.syntaxHighlight()
+ $html.find('.js-task-list-container').taskList('enable')
+
+ # Find the note's `li` element by ID and replace it with the updated HTML
+ $note_li = $("#note_#{note.id}")
+ $note_li.replaceWith($html)
###
Called in response to clicking the edit note link
diff --git a/app/models/note.rb b/app/models/note.rb
index 89d81ab1de2..de3b6df88f7 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -366,6 +366,6 @@ class Note < ActiveRecord::Base
end
def editable?
- !read_attribute(:system)
+ !system?
end
end
diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml
index 9bfbde02ca2..cf5d5d6d8ba 100644
--- a/app/views/projects/notes/_note.html.haml
+++ b/app/views/projects/notes/_note.html.haml
@@ -59,7 +59,9 @@
.note-text
= preserve do
= markdown(note.note, {no_header_anchors: true})
- = render 'projects/notes/edit_form', note: note
+ - unless note.system?
+ -# System notes can't be edited
+ = render 'projects/notes/edit_form', note: note
- if note.attachment.url
.note-attachment