Commit d41d8ffb02fa74fd4571603548bd7e401ec99e0c

Authored by Dmitriy Zaporozhets
1 parent 215a01f6

Reply button, Comments for Merge Request diff

app/assets/stylesheets/common.scss
@@ -374,3 +374,10 @@ table a code { @@ -374,3 +374,10 @@ table a code {
374 .btn.padded { 374 .btn.padded {
375 margin-right:3px; 375 margin-right:3px;
376 } 376 }
  377 +
  378 +.loading {
  379 + margin:20px auto;
  380 + background: url(ajax-loader-facebook.gif) no-repeat center center;
  381 + width:40px;
  382 + height:40px;
  383 +}
app/assets/stylesheets/notes.css.scss
@@ -30,7 +30,10 @@ @@ -30,7 +30,10 @@
30 } 30 }
31 } 31 }
32 32
33 -.note .delete-note { display:none; } 33 +.note .delete-note {
  34 + display:none;
  35 + float:right;
  36 +}
34 .note:hover .delete-note { display:block; } 37 .note:hover .delete-note { display:block; }
35 .note {padding: 10px 0; border-bottom: 1px solid #eee; overflow: hidden; display: block;} 38 .note {padding: 10px 0; border-bottom: 1px solid #eee; overflow: hidden; display: block;}
36 .note img{float: left; margin-right: 10px;} 39 .note img{float: left; margin-right: 10px;}
@@ -53,6 +56,20 @@ p.notify_controls span{ @@ -53,6 +56,20 @@ p.notify_controls span{
53 56
54 tr.line_notes_row { 57 tr.line_notes_row {
55 border-bottom:1px solid #DDD; 58 border-bottom:1px solid #DDD;
  59 + &.reply {
  60 + background:#eee;
  61 +
  62 + td {
  63 + padding:7px 10px;
  64 + }
  65 + a.line_note_reply_link {
  66 + @include round-borders-all(4px);
  67 + border-color:#aaa;
  68 + background: #bbb;
  69 + padding: 3px 20px;
  70 + color: white;
  71 + }
  72 + }
56 ul { 73 ul {
57 margin:0; 74 margin:0;
58 li { 75 li {
app/controllers/merge_requests_controller.rb
@@ -58,7 +58,9 @@ class MergeRequestsController < ApplicationController @@ -58,7 +58,9 @@ class MergeRequestsController < ApplicationController
58 def diffs 58 def diffs
59 @diffs = @merge_request.diffs 59 @diffs = @merge_request.diffs
60 @commit = @merge_request.last_commit 60 @commit = @merge_request.last_commit
61 - @line_notes = [] 61 +
  62 + @comments_allowed = true
  63 + @line_notes = @merge_request.notes.where("line_code is not null")
62 end 64 end
63 65
64 def new 66 def new
app/views/commits/_text_file.html.haml
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 - if @comments_allowed 16 - if @comments_allowed
17 - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse 17 - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse
18 - unless comments.empty? 18 - unless comments.empty?
19 - - comments.each do |note| 19 + - comments.each_with_index do |note, i|
  20 + = render "notes/reply_button", :line_code => line_code if i.zero?
20 = render "notes/per_line_show", :note => note 21 = render "notes/per_line_show", :note => note
21 - @line_notes.reject!{ |n| n == note } 22 - @line_notes.reject!{ |n| n == note }
app/views/commits/show.html.haml
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 27
28 :javascript 28 :javascript
29 $(document).ready(function(){ 29 $(document).ready(function(){
30 - $(".line_note_link").live("click", function(e) { 30 + $(".line_note_link, .line_note_reply_link").live("click", function(e) {
31 var form = $(".per_line_form"); 31 var form = $(".per_line_form");
32 $(this).parent().parent().after(form); 32 $(this).parent().parent().after(form);
33 form.find("#note_line_code").val($(this).attr("line_code")); 33 form.find("#note_line_code").val($(this).attr("line_code"));
app/views/commits/show.js.haml
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -= render "notes/load"  
app/views/issues/show.html.haml
@@ -42,4 +42,3 @@ @@ -42,4 +42,3 @@
42 42
43 43
44 .issue_notes= render "notes/notes", :tid => @issue.id, :tt => "issue" 44 .issue_notes= render "notes/notes", :tid => @issue.id, :tt => "issue"
45 -  
app/views/merge_requests/show.html.haml
@@ -64,9 +64,6 @@ @@ -64,9 +64,6 @@
64 64
65 .merge-request-notes 65 .merge-request-notes
66 .merge_request_notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request" 66 .merge_request_notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request"
67 - .loading{ :style => "display:none;"}  
68 - %center= image_tag "ajax-loader.gif"  
69 - .clear  
70 67
71 .merge-request-diffs 68 .merge-request-diffs
72 69
@@ -75,3 +72,15 @@ @@ -75,3 +72,15 @@
75 $(function(){ 72 $(function(){
76 MergeRequest.init(); 73 MergeRequest.init();
77 }) 74 })
  75 +
  76 += render "notes/per_line_form"
  77 +:javascript
  78 + $(document).ready(function(){
  79 + $(".line_note_link, .line_note_reply_link").live("click", function(e) {
  80 + var form = $(".per_line_form");
  81 + $(this).parent().parent().after(form);
  82 + form.find("#note_line_code").val($(this).attr("line_code"));
  83 + form.show();
  84 + return false;
  85 + });
  86 + });
app/views/notes/_notes.html.haml
@@ -3,6 +3,8 @@ @@ -3,6 +3,8 @@
3 .clear 3 .clear
4 %hr 4 %hr
5 %ul#notes-list 5 %ul#notes-list
  6 +.loading
  7 +
6 8
7 :javascript 9 :javascript
8 $('.delete-note').live('ajax:success', function() { 10 $('.delete-note').live('ajax:success', function() {
app/views/notes/_reply_button.html.haml 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +%tr.line_notes_row.reply
  2 + %td{:colspan => 3}
  3 + = link_to "Reply", "#", :class => "line_note_reply_link", "line_code" => line_code, :title => "Add note for this line"
app/views/notes/_show.html.haml
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 = time_ago_in_words(note.updated_at) 6 = time_ago_in_words(note.updated_at)
7 ago 7 ago
8 - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) 8 - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
9 - = link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note right" 9 + %strong= link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note btn small"
10 10
11 %div.note-title 11 %div.note-title
12 = markdown(note.note) 12 = markdown(note.note)
app/views/notes/create.js.haml
@@ -3,7 +3,10 @@ @@ -3,7 +3,10 @@
3 :plain 3 :plain
4 $(".per_line_form").hide(); 4 $(".per_line_form").hide();
5 $('#new_note textarea').val(""); 5 $('#new_note textarea').val("");
6 - $(".#{@note.line_code}").parent().after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}"); 6 + $("a.line_note_reply_link[line_code='#{@note.line_code}']").closest("tr").remove();
  7 + var trEl = $(".#{@note.line_code}").parent();
  8 + trEl.after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}");
  9 + trEl.after("#{escape_javascript(render :partial => "notes/reply_button", :locals => {:line_code => @note.line_code})}");
7 - else 10 - else
8 :plain 11 :plain
9 $("#new_note .errors").remove(); 12 $("#new_note .errors").remove();
app/views/projects/wall.html.haml
1 %div.wall_page 1 %div.wall_page
2 = render "notes/notes", :tid => nil, :tt => "wall" 2 = render "notes/notes", :tid => nil, :tt => "wall"
3 -  
4 -.loading{ :style => "display:none;"}  
5 - %center= image_tag "ajax-loader.gif"  
6 -