per line comments w/o tests & with dirty code
This commit is contained in:
parent
9da4d06a87
commit
99bb4a153d
11 changed files with 55391 additions and 12 deletions
BIN
app/assets/images/add_comment.png
Normal file
BIN
app/assets/images/add_comment.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 823 B |
|
@ -82,3 +82,5 @@ function showMenu() {
|
|||
function resetMenu() {
|
||||
$(this).removeClass("hover");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -96,3 +96,13 @@ ul.bordered-list {
|
|||
}
|
||||
|
||||
ul.bordered-list li:last-child { border:none }
|
||||
|
||||
.line_holder {
|
||||
cursor:pointer;
|
||||
|
||||
&:hover {
|
||||
td {
|
||||
background: #FFFFCF !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,4 +42,11 @@ module CommitsHelper
|
|||
preserve out
|
||||
end
|
||||
|
||||
def build_line_code(line, index, line_new, line_old)
|
||||
if diff_line_class(line) == "new"
|
||||
"NEW_#{index}_#{line_new}"
|
||||
else
|
||||
"OLD_#{index}_#{line_old}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,14 +18,11 @@
|
|||
= link_to raw(diff_line_class(line) == "new" ? " " : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}"
|
||||
%td.new_line
|
||||
= link_to raw(diff_line_class(line) == "old" ? " " : line_new) , "#NEW#{index}-#{line_new}", :id => "NEW#{index}-#{line_new}"
|
||||
%td.line_content{:class => diff_line_class(full_line)}= raw "#{full_line} "
|
||||
%td.line_content{:class => "#{diff_line_class(full_line)} #{build_line_code(line, index, line_new, line_old)}", "line_code" => build_line_code(line, index, line_new, line_old)}= raw "#{full_line} "
|
||||
- comments = @line_notes.select { |n| n.for_line?(index, line_old, line_new) }.sort_by(&:created_at).reverse
|
||||
- unless comments.empty?
|
||||
%tr.line_notes_row
|
||||
%td{:colspan => 3}
|
||||
%ul
|
||||
- comments.each do |note|
|
||||
= render :partial => "notes/show", :locals => {:note => note}
|
||||
- comments.each do |note|
|
||||
= render "notes/per_line_show", :note => note
|
||||
- if line[0] == "+"
|
||||
- line_new += 1
|
||||
- elsif line[0] == "-"
|
||||
|
|
|
@ -24,3 +24,15 @@
|
|||
|
||||
= render "commits/diff"
|
||||
= render "notes/notes"
|
||||
= render "notes/per_line_form"
|
||||
|
||||
|
||||
:javascript
|
||||
$(document).ready(function(){
|
||||
$(".line_content").live("click", function(e) {
|
||||
var form = $(".per_line_form");
|
||||
$(this).parent().after(form);
|
||||
form.find("#note_line_code").val($(this).attr("line_code"));
|
||||
form.show();
|
||||
});
|
||||
});
|
||||
|
|
34
app/views/notes/_per_line_form.html.haml
Normal file
34
app/views/notes/_per_line_form.html.haml
Normal file
|
@ -0,0 +1,34 @@
|
|||
%table{:style => "display:none;"}
|
||||
%tr.per_line_form
|
||||
%td{:colspan => 3 }
|
||||
%div
|
||||
= form_for [@project, @note], :remote => "true", :multipart => true do |f|
|
||||
-if @note.errors.any?
|
||||
.errors.error
|
||||
- @note.errors.full_messages.each do |msg|
|
||||
%div= msg
|
||||
|
||||
= f.hidden_field :noteable_id
|
||||
= f.hidden_field :noteable_type
|
||||
= f.hidden_field :line_code
|
||||
|
||||
%div
|
||||
= f.label :note
|
||||
%cite.cgray markdown supported
|
||||
%br
|
||||
%br
|
||||
= f.text_area :note, :size => 255
|
||||
|
||||
%p.notify_controls
|
||||
%span Notify:
|
||||
= check_box_tag :notify, 1, @note.noteable_type != "Commit"
|
||||
= label_tag :notify, "Project team"
|
||||
|
||||
-if @note.noteable_type == "Commit"
|
||||
= check_box_tag :notify_author, 1 , @note.noteable_type == "Commit"
|
||||
= label_tag :notify_author, "Commit author"
|
||||
|
||||
.clear
|
||||
%br
|
||||
= f.submit 'Add note', :class => "grey-button", :id => "submit_note"
|
||||
|
5
app/views/notes/_per_line_show.html.haml
Normal file
5
app/views/notes/_per_line_show.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
%tr.line_notes_row
|
||||
%td{:colspan => 3}
|
||||
%ul
|
||||
= render :partial => "notes/show", :locals => {:note => note}
|
||||
|
|
@ -1,11 +1,18 @@
|
|||
- if @note.valid?
|
||||
:plain
|
||||
$("#new_note .errors").remove();
|
||||
$('#note_note').val("");
|
||||
NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}");
|
||||
- if @note.line_code
|
||||
:plain
|
||||
$(".per_line_form").hide();
|
||||
$('#new_note textarea').val("");
|
||||
$(".#{@note.line_code}").parent().after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}");
|
||||
- else
|
||||
:plain
|
||||
$("#new_note .errors").remove();
|
||||
$('#new_note textarea').val("");
|
||||
NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}");
|
||||
- else
|
||||
:plain
|
||||
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
|
||||
- unless @note.line_code
|
||||
:plain
|
||||
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
|
||||
|
||||
:plain
|
||||
$("#submit_note").removeAttr("disabled");
|
||||
|
|
BIN
db/test.sqlite3-journal
Normal file
BIN
db/test.sqlite3-journal
Normal file
Binary file not shown.
Loading…
Reference in a new issue