Commit 99bb4a15 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

per line comments w/o tests & with dirty code

parent 9da4d06a
...@@ -82,3 +82,5 @@ function showMenu() { ...@@ -82,3 +82,5 @@ function showMenu() {
function resetMenu() { function resetMenu() {
$(this).removeClass("hover"); $(this).removeClass("hover");
} }
...@@ -96,3 +96,13 @@ ul.bordered-list { ...@@ -96,3 +96,13 @@ ul.bordered-list {
} }
ul.bordered-list li:last-child { border:none } ul.bordered-list li:last-child { border:none }
.line_holder {
cursor:pointer;
&:hover {
td {
background: #FFFFCF !important;
}
}
}
...@@ -42,4 +42,11 @@ module CommitsHelper ...@@ -42,4 +42,11 @@ module CommitsHelper
preserve out preserve out
end 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 end
...@@ -18,14 +18,11 @@ ...@@ -18,14 +18,11 @@
= link_to raw(diff_line_class(line) == "new" ? " " : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}" = link_to raw(diff_line_class(line) == "new" ? " " : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}"
%td.new_line %td.new_line
= link_to raw(diff_line_class(line) == "old" ? " " : line_new) , "#NEW#{index}-#{line_new}", :id => "NEW#{index}-#{line_new}" = 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 - comments = @line_notes.select { |n| n.for_line?(index, line_old, line_new) }.sort_by(&:created_at).reverse
- unless comments.empty? - unless comments.empty?
%tr.line_notes_row - comments.each do |note|
%td{:colspan => 3} = render "notes/per_line_show", :note => note
%ul
- comments.each do |note|
= render :partial => "notes/show", :locals => {:note => note}
- if line[0] == "+" - if line[0] == "+"
- line_new += 1 - line_new += 1
- elsif line[0] == "-" - elsif line[0] == "-"
......
...@@ -24,3 +24,15 @@ ...@@ -24,3 +24,15 @@
= render "commits/diff" = render "commits/diff"
= render "notes/notes" = 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();
});
});
%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"
%tr.line_notes_row
%td{:colspan => 3}
%ul
= render :partial => "notes/show", :locals => {:note => note}
- if @note.valid? - if @note.valid?
:plain - if @note.line_code
$("#new_note .errors").remove(); :plain
$('#note_note').val(""); $(".per_line_form").hide();
NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}"); $('#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 - else
:plain - unless @note.line_code
$("#new_note").replaceWith("#{escape_javascript(render('form'))}"); :plain
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
:plain :plain
$("#submit_note").removeAttr("disabled"); $("#submit_note").removeAttr("disabled");
This diff is collapsed.
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