summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-11-22 02:57:22 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-12-03 22:51:56 +0100
commitc4a7824a8c6487b24379f7f85c26f182bbc1dee9 (patch)
treec23fdbf95bbcd8b3a46e2eaae6021e62a0bc3ff3
parent140652e9b019addaf7022e18b6816ecb36eee80c (diff)
downloadgitlab-ce-c4a7824a8c6487b24379f7f85c26f182bbc1dee9.tar.gz
Fix wall notes
-rw-r--r--app/assets/javascripts/notes.js20
-rw-r--r--app/controllers/notes_controller.rb3
-rw-r--r--app/helpers/notes_helper.rb3
-rw-r--r--app/models/note.rb4
-rw-r--r--app/views/notes/_create_common_note.js.haml3
5 files changed, 29 insertions, 4 deletions
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js
index 3952ee292c3..da356b2ef04 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -267,6 +267,7 @@ var NoteList = {
NoteList.bottom_id = newNoteIds.last();
$("#notes-list").html(html);
+ // for the wall
if (NoteList.reversed) {
// init infinite scrolling
NoteList.initLoadMore();
@@ -352,6 +353,8 @@ var NoteList = {
/**
* Initializes getting new notes every n seconds.
+ *
+ * Note: only used on wall.
*/
initRefreshNew: function() {
setInterval("NoteList.getNew()", 10000);
@@ -359,6 +362,8 @@ var NoteList = {
/**
* Gets the new set of notes.
+ *
+ * Note: only used on wall.
*/
getNew: function() {
$.ajax({
@@ -371,6 +376,8 @@ var NoteList = {
/**
* Called in response to getNew().
* Replaces the content of #new-notes-list with the given html.
+ *
+ * Note: only used on wall.
*/
replaceNewNotes: function(newNoteIds, html) {
$("#new-notes-list").html(html);
@@ -378,7 +385,7 @@ var NoteList = {
},
/**
- * Adds a single common note to #(new-)notes-list.
+ * Adds a single common note to #notes-list.
*/
appendNewNote: function(id, html) {
$("#notes-list").append(html);
@@ -386,7 +393,7 @@ var NoteList = {
},
/**
- * Adds a single discussion note to #(new-)notes-list.
+ * Adds a single discussion note to #notes-list.
*/
appendNewDiscussionNote: function(discussionId, diffRowHtml, noteHtml) {
// is this the first note of discussion?
@@ -403,6 +410,15 @@ var NoteList = {
},
/**
+ * Adds a single wall note to #new-notes-list.
+ *
+ * Note: only used on wall.
+ */
+ appendNewWallNote: function(id, html) {
+ $("#new-notes-list").prepend(html);
+ },
+
+ /**
* Recalculates the votes and updates them (if they are displayed at all).
*
* Assumes all relevant notes are displayed (i.e. there are no more notes to
diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb
index e04a61b2905..000c7bbb641 100644
--- a/app/controllers/notes_controller.rb
+++ b/app/controllers/notes_controller.rb
@@ -71,6 +71,7 @@ class NotesController < ProjectResourceController
# Helps to distinguish e.g. commit notes in mr notes list
def note_for_main_target?(note)
- @target_type.camelize == note.noteable_type && !note.for_diff_line?
+ note.for_wall? ||
+ (@target_type.camelize == note.noteable_type && !note.for_diff_line?)
end
end
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb
index e82537a336f..fd920e23c19 100644
--- a/app/helpers/notes_helper.rb
+++ b/app/helpers/notes_helper.rb
@@ -1,7 +1,8 @@
module NotesHelper
# Helps to distinguish e.g. commit notes in mr notes list
def note_for_main_target?(note)
- @target_type.camelize == note.noteable_type && !note.for_diff_line?
+ note.for_wall? ||
+ (@target_type.camelize == note.noteable_type && !note.for_diff_line?)
end
def note_target_fields
diff --git a/app/models/note.rb b/app/models/note.rb
index 48916951e3b..0027c57b63b 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -115,6 +115,10 @@ class Note < ActiveRecord::Base
for_merge_request? && for_diff_line?
end
+ def for_wall?
+ noteable_type.blank?
+ end
+
# override to return commits, which are not active record
def noteable
if for_commit?
diff --git a/app/views/notes/_create_common_note.js.haml b/app/views/notes/_create_common_note.js.haml
index 57c768b8088..20bc07568a0 100644
--- a/app/views/notes/_create_common_note.js.haml
+++ b/app/views/notes/_create_common_note.js.haml
@@ -1,4 +1,7 @@
- if note.valid?
+ - if note.for_wall?
+ NoteList.appendNewWallNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}");
+ - else
NoteList.appendNewNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}");
- else