Commit 6cf000ff52f34d0dd1afc823985adbe072c23515
Exists in
master
and in
4 other branches
Merge branch 'per_line_comment'
Conflicts: app/assets/stylesheets/projects.css.scss
Showing
18 changed files
with
165 additions
and
13 deletions
Show diff stats
.gitignore
Gemfile
Gemfile.lock
... | ... | @@ -145,8 +145,8 @@ GEM |
145 | 145 | orm_adapter (0.0.5) |
146 | 146 | polyglot (0.3.3) |
147 | 147 | posix-spawn (0.3.6) |
148 | - pygments.rb (0.2.3) | |
149 | - rubypython (>= 0.5.1) | |
148 | + pygments.rb (0.2.4) | |
149 | + rubypython (~> 0.5.3) | |
150 | 150 | rack (1.3.5) |
151 | 151 | rack-cache (1.1) |
152 | 152 | rack (>= 0.4) |
... | ... | @@ -306,7 +306,7 @@ DEPENDENCIES |
306 | 306 | kaminari |
307 | 307 | launchy |
308 | 308 | letter_opener |
309 | - pygments.rb (= 0.2.3) | |
309 | + pygments.rb (= 0.2.4) | |
310 | 310 | rails (= 3.1.1) |
311 | 311 | rails-footnotes (~> 3.7.5) |
312 | 312 | rdiscount | ... | ... |
823 Bytes
app/assets/javascripts/application.js
app/assets/stylesheets/commits.css.scss
app/assets/stylesheets/projects.css.scss
... | ... | @@ -726,3 +726,31 @@ a.project-update.titled { |
726 | 726 | float:left; |
727 | 727 | } |
728 | 728 | } |
729 | + | |
730 | +tr.line_notes_row { | |
731 | + &:hover { | |
732 | + background:none; | |
733 | + } | |
734 | + td { | |
735 | + margin:0px; | |
736 | + padding:0px; | |
737 | + border-bottom:1px solid #DEE2E3; | |
738 | + | |
739 | + | |
740 | + ul { | |
741 | + display:block; | |
742 | + list-style:none; | |
743 | + margin:0px; | |
744 | + padding:0px; | |
745 | + | |
746 | + li { | |
747 | + border-top:1px solid #DEE2E3; | |
748 | + padding:10px; | |
749 | + | |
750 | + .delete-note { | |
751 | + display:none; | |
752 | + } | |
753 | + } | |
754 | + } | |
755 | + } | |
756 | +} | ... | ... |
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/helpers/commits_helper.rb
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
... | ... | @@ -18,7 +18,11 @@ |
18 | 18 | = link_to raw(diff_line_class(line) == "new" ? " " : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}" |
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 | - %td.line_content{:class => diff_line_class(full_line)}= raw "#{full_line} " | |
21 | + %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} " | |
22 | + - comments = @line_notes.select { |n| n.for_line?(index, line_old, line_new) }.sort_by(&:created_at).reverse | |
23 | + - unless comments.empty? | |
24 | + - comments.each do |note| | |
25 | + = render "notes/per_line_show", :note => note | |
22 | 26 | - if line[0] == "+" |
23 | 27 | - line_new += 1 |
24 | 28 | - elsif line[0] == "-" | ... | ... |
app/views/commits/show.html.haml
... | ... | @@ -24,3 +24,15 @@ |
24 | 24 | |
25 | 25 | = render "commits/diff" |
26 | 26 | = render "notes/notes" |
27 | += render "notes/per_line_form" | |
28 | + | |
29 | + | |
30 | +:javascript | |
31 | + $(document).ready(function(){ | |
32 | + $(".line_content").live("dblclick", function(e) { | |
33 | + var form = $(".per_line_form"); | |
34 | + $(this).parent().after(form); | |
35 | + form.find("#note_line_code").val($(this).attr("line_code")); | |
36 | + form.show(); | |
37 | + }); | |
38 | + }); | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +%table{:style => "display:none;"} | |
2 | + %tr.per_line_form | |
3 | + %td{:colspan => 3 } | |
4 | + %div | |
5 | + = form_for [@project, @note], :remote => "true", :multipart => true do |f| | |
6 | + -if @note.errors.any? | |
7 | + .errors.error | |
8 | + - @note.errors.full_messages.each do |msg| | |
9 | + %div= msg | |
10 | + | |
11 | + = f.hidden_field :noteable_id | |
12 | + = f.hidden_field :noteable_type | |
13 | + = f.hidden_field :line_code | |
14 | + | |
15 | + %div | |
16 | + = f.label :note | |
17 | + %cite.cgray markdown supported | |
18 | + %br | |
19 | + %br | |
20 | + = f.text_area :note, :size => 255 | |
21 | + | |
22 | + %p.notify_controls | |
23 | + %span Notify: | |
24 | + = check_box_tag :notify, 1, @note.noteable_type != "Commit" | |
25 | + = label_tag :notify, "Project team" | |
26 | + | |
27 | + -if @note.noteable_type == "Commit" | |
28 | + = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit" | |
29 | + = label_tag :notify_author, "Commit author" | |
30 | + | |
31 | + .clear | |
32 | + %br | |
33 | + = f.submit 'Add note', :class => "grey-button", :id => "submit_note" | |
34 | + | ... | ... |
app/views/notes/create.js.haml
1 | 1 | - if @note.valid? |
2 | - :plain | |
3 | - $("#new_note .errors").remove(); | |
4 | - $('#note_note').val(""); | |
5 | - NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}"); | |
2 | + - if @note.line_code | |
3 | + :plain | |
4 | + $(".per_line_form").hide(); | |
5 | + $('#new_note textarea').val(""); | |
6 | + $(".#{@note.line_code}").parent().after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}"); | |
7 | + - else | |
8 | + :plain | |
9 | + $("#new_note .errors").remove(); | |
10 | + $('#new_note textarea').val(""); | |
11 | + NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}"); | |
6 | 12 | - else |
7 | - :plain | |
8 | - $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); | |
13 | + - unless @note.line_code | |
14 | + :plain | |
15 | + $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); | |
9 | 16 | |
10 | 17 | :plain |
11 | 18 | $("#submit_note").removeAttr("disabled"); | ... | ... |
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| | ... | ... |