Commit c4a7824a authored by Riyad Preukschas's avatar Riyad Preukschas

Fix wall notes

parent 140652e9
...@@ -267,6 +267,7 @@ var NoteList = { ...@@ -267,6 +267,7 @@ var NoteList = {
NoteList.bottom_id = newNoteIds.last(); NoteList.bottom_id = newNoteIds.last();
$("#notes-list").html(html); $("#notes-list").html(html);
// for the wall
if (NoteList.reversed) { if (NoteList.reversed) {
// init infinite scrolling // init infinite scrolling
NoteList.initLoadMore(); NoteList.initLoadMore();
...@@ -352,6 +353,8 @@ var NoteList = { ...@@ -352,6 +353,8 @@ var NoteList = {
/** /**
* Initializes getting new notes every n seconds. * Initializes getting new notes every n seconds.
*
* Note: only used on wall.
*/ */
initRefreshNew: function() { initRefreshNew: function() {
setInterval("NoteList.getNew()", 10000); setInterval("NoteList.getNew()", 10000);
...@@ -359,6 +362,8 @@ var NoteList = { ...@@ -359,6 +362,8 @@ var NoteList = {
/** /**
* Gets the new set of notes. * Gets the new set of notes.
*
* Note: only used on wall.
*/ */
getNew: function() { getNew: function() {
$.ajax({ $.ajax({
...@@ -371,6 +376,8 @@ var NoteList = { ...@@ -371,6 +376,8 @@ var NoteList = {
/** /**
* Called in response to getNew(). * Called in response to getNew().
* Replaces the content of #new-notes-list with the given html. * Replaces the content of #new-notes-list with the given html.
*
* Note: only used on wall.
*/ */
replaceNewNotes: function(newNoteIds, html) { replaceNewNotes: function(newNoteIds, html) {
$("#new-notes-list").html(html); $("#new-notes-list").html(html);
...@@ -378,7 +385,7 @@ var NoteList = { ...@@ -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) { appendNewNote: function(id, html) {
$("#notes-list").append(html); $("#notes-list").append(html);
...@@ -386,7 +393,7 @@ var NoteList = { ...@@ -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) { appendNewDiscussionNote: function(discussionId, diffRowHtml, noteHtml) {
// is this the first note of discussion? // is this the first note of discussion?
...@@ -402,6 +409,15 @@ var NoteList = { ...@@ -402,6 +409,15 @@ var NoteList = {
$(".notes[rel='"+discussionId+"']").append(noteHtml); $(".notes[rel='"+discussionId+"']").append(noteHtml);
}, },
/**
* 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). * Recalculates the votes and updates them (if they are displayed at all).
* *
......
...@@ -71,6 +71,7 @@ class NotesController < ProjectResourceController ...@@ -71,6 +71,7 @@ class NotesController < ProjectResourceController
# Helps to distinguish e.g. commit notes in mr notes list # Helps to distinguish e.g. commit notes in mr notes list
def note_for_main_target?(note) 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
end end
module NotesHelper module NotesHelper
# Helps to distinguish e.g. commit notes in mr notes list # Helps to distinguish e.g. commit notes in mr notes list
def note_for_main_target?(note) 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
def note_target_fields def note_target_fields
......
...@@ -115,6 +115,10 @@ class Note < ActiveRecord::Base ...@@ -115,6 +115,10 @@ class Note < ActiveRecord::Base
for_merge_request? && for_diff_line? for_merge_request? && for_diff_line?
end end
def for_wall?
noteable_type.blank?
end
# override to return commits, which are not active record # override to return commits, which are not active record
def noteable def noteable
if for_commit? if for_commit?
......
- if note.valid? - 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)}"); NoteList.appendNewNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}");
- else - else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment