Commit d41d8ffb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Reply button, Comments for Merge Request diff

parent 215a01f6
...@@ -374,3 +374,10 @@ table a code { ...@@ -374,3 +374,10 @@ table a code {
.btn.padded { .btn.padded {
margin-right:3px; margin-right:3px;
} }
.loading {
margin:20px auto;
background: url(ajax-loader-facebook.gif) no-repeat center center;
width:40px;
height:40px;
}
...@@ -30,7 +30,10 @@ ...@@ -30,7 +30,10 @@
} }
} }
.note .delete-note { display:none; } .note .delete-note {
display:none;
float:right;
}
.note:hover .delete-note { display:block; } .note:hover .delete-note { display:block; }
.note {padding: 10px 0; border-bottom: 1px solid #eee; overflow: hidden; display: block;} .note {padding: 10px 0; border-bottom: 1px solid #eee; overflow: hidden; display: block;}
.note img{float: left; margin-right: 10px;} .note img{float: left; margin-right: 10px;}
...@@ -53,6 +56,20 @@ p.notify_controls span{ ...@@ -53,6 +56,20 @@ p.notify_controls span{
tr.line_notes_row { tr.line_notes_row {
border-bottom:1px solid #DDD; border-bottom:1px solid #DDD;
&.reply {
background:#eee;
td {
padding:7px 10px;
}
a.line_note_reply_link {
@include round-borders-all(4px);
border-color:#aaa;
background: #bbb;
padding: 3px 20px;
color: white;
}
}
ul { ul {
margin:0; margin:0;
li { li {
......
...@@ -58,7 +58,9 @@ class MergeRequestsController < ApplicationController ...@@ -58,7 +58,9 @@ class MergeRequestsController < ApplicationController
def diffs def diffs
@diffs = @merge_request.diffs @diffs = @merge_request.diffs
@commit = @merge_request.last_commit @commit = @merge_request.last_commit
@line_notes = []
@comments_allowed = true
@line_notes = @merge_request.notes.where("line_code is not null")
end end
def new def new
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
- if @comments_allowed - if @comments_allowed
- comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse
- unless comments.empty? - unless comments.empty?
- comments.each do |note| - comments.each_with_index do |note, i|
= render "notes/reply_button", :line_code => line_code if i.zero?
= render "notes/per_line_show", :note => note = render "notes/per_line_show", :note => note
- @line_notes.reject!{ |n| n == note } - @line_notes.reject!{ |n| n == note }
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
:javascript :javascript
$(document).ready(function(){ $(document).ready(function(){
$(".line_note_link").live("click", function(e) { $(".line_note_link, .line_note_reply_link").live("click", function(e) {
var form = $(".per_line_form"); var form = $(".per_line_form");
$(this).parent().parent().after(form); $(this).parent().parent().after(form);
form.find("#note_line_code").val($(this).attr("line_code")); form.find("#note_line_code").val($(this).attr("line_code"));
......
...@@ -42,4 +42,3 @@ ...@@ -42,4 +42,3 @@
.issue_notes= render "notes/notes", :tid => @issue.id, :tt => "issue" .issue_notes= render "notes/notes", :tid => @issue.id, :tt => "issue"
...@@ -64,9 +64,6 @@ ...@@ -64,9 +64,6 @@
.merge-request-notes .merge-request-notes
.merge_request_notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request" .merge_request_notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request"
.loading{ :style => "display:none;"}
%center= image_tag "ajax-loader.gif"
.clear
.merge-request-diffs .merge-request-diffs
...@@ -75,3 +72,15 @@ ...@@ -75,3 +72,15 @@
$(function(){ $(function(){
MergeRequest.init(); MergeRequest.init();
}) })
= render "notes/per_line_form"
:javascript
$(document).ready(function(){
$(".line_note_link, .line_note_reply_link").live("click", function(e) {
var form = $(".per_line_form");
$(this).parent().parent().after(form);
form.find("#note_line_code").val($(this).attr("line_code"));
form.show();
return false;
});
});
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
.clear .clear
%hr %hr
%ul#notes-list %ul#notes-list
.loading
:javascript :javascript
$('.delete-note').live('ajax:success', function() { $('.delete-note').live('ajax:success', function() {
......
%tr.line_notes_row.reply
%td{:colspan => 3}
= link_to "Reply", "#", :class => "line_note_reply_link", "line_code" => line_code, :title => "Add note for this line"
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
= time_ago_in_words(note.updated_at) = time_ago_in_words(note.updated_at)
ago ago
- if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
= link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note right" %strong= link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note btn small"
%div.note-title %div.note-title
= markdown(note.note) = markdown(note.note)
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
:plain :plain
$(".per_line_form").hide(); $(".per_line_form").hide();
$('#new_note textarea').val(""); $('#new_note textarea').val("");
$(".#{@note.line_code}").parent().after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}"); $("a.line_note_reply_link[line_code='#{@note.line_code}']").closest("tr").remove();
var trEl = $(".#{@note.line_code}").parent();
trEl.after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}");
trEl.after("#{escape_javascript(render :partial => "notes/reply_button", :locals => {:line_code => @note.line_code})}");
- else - else
:plain :plain
$("#new_note .errors").remove(); $("#new_note .errors").remove();
......
%div.wall_page %div.wall_page
= render "notes/notes", :tid => nil, :tt => "wall" = render "notes/notes", :tid => nil, :tt => "wall"
.loading{ :style => "display:none;"}
%center= image_tag "ajax-loader.gif"
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