Commit 9da4d06a87a302f3f37ca95ba5b6e89cc66c0a82
1 parent
c66bc99f
Exists in
master
and in
4 other branches
per line comments display
Showing
7 changed files
with
78 additions
and
2 deletions
Show diff stats
app/assets/stylesheets/projects.css.scss
| ... | ... | @@ -693,3 +693,31 @@ a.project-update.titled { |
| 693 | 693 | top: 0; |
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | + | |
| 697 | +tr.line_notes_row { | |
| 698 | + &:hover { | |
| 699 | + background:none; | |
| 700 | + } | |
| 701 | + td { | |
| 702 | + margin:0px; | |
| 703 | + padding:0px; | |
| 704 | + border-bottom:1px solid #DEE2E3; | |
| 705 | + | |
| 706 | + | |
| 707 | + ul { | |
| 708 | + display:block; | |
| 709 | + list-style:none; | |
| 710 | + margin:0px; | |
| 711 | + padding:0px; | |
| 712 | + | |
| 713 | + li { | |
| 714 | + border-top:1px solid #DEE2E3; | |
| 715 | + padding:10px; | |
| 716 | + | |
| 717 | + .delete-note { | |
| 718 | + display:none; | |
| 719 | + } | |
| 720 | + } | |
| 721 | + } | |
| 722 | + } | |
| 723 | +} | ... | ... |
app/controllers/commits_controller.rb
| ... | ... | @@ -27,6 +27,8 @@ class CommitsController < ApplicationController |
| 27 | 27 | @notes = project.commit_notes(@commit).fresh.limit(20) |
| 28 | 28 | @note = @project.build_commit_note(@commit) |
| 29 | 29 | |
| 30 | + @line_notes = project.commit_line_notes(@commit) | |
| 31 | + | |
| 30 | 32 | respond_to do |format| |
| 31 | 33 | format.html |
| 32 | 34 | format.js { respond_with_notes } | ... | ... |
app/models/note.rb
| ... | ... | @@ -53,6 +53,23 @@ class Note < ActiveRecord::Base |
| 53 | 53 | noteable |
| 54 | 54 | end |
| 55 | 55 | end |
| 56 | + | |
| 57 | + def line_file_id | |
| 58 | + @line_file_id ||= line_code.split("_")[1].to_i if line_code | |
| 59 | + end | |
| 60 | + | |
| 61 | + def line_type_id | |
| 62 | + @line_type_id ||= line_code.split("_").first if line_code | |
| 63 | + end | |
| 64 | + | |
| 65 | + def line_number | |
| 66 | + @line_number ||= line_code.split("_").last.to_i if line_code | |
| 67 | + end | |
| 68 | + | |
| 69 | + def for_line?(file_id, old_line, new_line) | |
| 70 | + line_file_id == file_id && | |
| 71 | + ((line_type_id == "NEW" && line_number == new_line) || (line_type_id == "OLD" && line_number == old_line )) | |
| 72 | + end | |
| 56 | 73 | end |
| 57 | 74 | # == Schema Information |
| 58 | 75 | # | ... | ... |
app/models/project.rb
| ... | ... | @@ -166,7 +166,11 @@ class Project < ActiveRecord::Base |
| 166 | 166 | end |
| 167 | 167 | |
| 168 | 168 | def commit_notes(commit) |
| 169 | - notes.where(:noteable_id => commit.id, :noteable_type => "Commit") | |
| 169 | + notes.where(:noteable_id => commit.id, :noteable_type => "Commit", :line_code => nil) | |
| 170 | + end | |
| 171 | + | |
| 172 | + def commit_line_notes(commit) | |
| 173 | + notes.where(:noteable_id => commit.id, :noteable_type => "Commit").where("line_code not null") | |
| 170 | 174 | end |
| 171 | 175 | |
| 172 | 176 | def has_commits? | ... | ... |
app/views/commits/_text_file.html.haml
| ... | ... | @@ -19,6 +19,13 @@ |
| 19 | 19 | %td.new_line |
| 20 | 20 | = link_to raw(diff_line_class(line) == "old" ? " " : line_new) , "#NEW#{index}-#{line_new}", :id => "NEW#{index}-#{line_new}" |
| 21 | 21 | %td.line_content{:class => diff_line_class(full_line)}= raw "#{full_line} " |
| 22 | + - comments = @line_notes.select { |n| n.for_line?(index, line_old, line_new) }.sort_by(&:created_at).reverse | |
| 23 | + - unless comments.empty? | |
| 24 | + %tr.line_notes_row | |
| 25 | + %td{:colspan => 3} | |
| 26 | + %ul | |
| 27 | + - comments.each do |note| | |
| 28 | + = render :partial => "notes/show", :locals => {:note => note} | |
| 22 | 29 | - if line[0] == "+" |
| 23 | 30 | - line_new += 1 |
| 24 | 31 | - elsif line[0] == "-" | ... | ... |
db/schema.rb
| ... | ... | @@ -11,7 +11,19 @@ |
| 11 | 11 | # |
| 12 | 12 | # It's strongly recommended to check this file into your version control system. |
| 13 | 13 | |
| 14 | -ActiveRecord::Schema.define(:version => 20111220190817) do | |
| 14 | +ActiveRecord::Schema.define(:version => 20120110180749) do | |
| 15 | + | |
| 16 | + create_table "features", :force => true do |t| | |
| 17 | + t.string "name" | |
| 18 | + t.string "branch_name" | |
| 19 | + t.integer "assignee_id" | |
| 20 | + t.integer "author_id" | |
| 21 | + t.integer "project_id" | |
| 22 | + t.datetime "created_at" | |
| 23 | + t.datetime "updated_at" | |
| 24 | + t.string "version" | |
| 25 | + t.integer "status", :default => 0, :null => false | |
| 26 | + end | |
| 15 | 27 | |
| 16 | 28 | create_table "issues", :force => true do |t| |
| 17 | 29 | t.string "title" |
| ... | ... | @@ -56,6 +68,7 @@ ActiveRecord::Schema.define(:version => 20111220190817) do |
| 56 | 68 | t.datetime "updated_at" |
| 57 | 69 | t.integer "project_id" |
| 58 | 70 | t.string "attachment" |
| 71 | + t.string "line_code" | |
| 59 | 72 | end |
| 60 | 73 | |
| 61 | 74 | create_table "projects", :force => true do |t| | ... | ... |