Commit 6cf000ff authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'per_line_comment'

Conflicts:
	app/assets/stylesheets/projects.css.scss
parents c8b955a4 7f92534f
.bundle
.rbx/
db/*.sqlite3
db/*.sqlite3-journal
log/*.log
tmp/
.sass-cache/
......@@ -9,3 +10,4 @@ coverage/*
public/uploads/
.rvmrc
.directory
nohup.out
......@@ -16,7 +16,7 @@ gem "six"
gem "therubyracer"
gem "faker"
gem "seed-fu", "~> 2.1.0"
gem "pygments.rb", "0.2.3"
gem "pygments.rb", "0.2.4"
gem "thin"
gem "git"
gem "acts_as_list"
......
......@@ -145,8 +145,8 @@ GEM
orm_adapter (0.0.5)
polyglot (0.3.3)
posix-spawn (0.3.6)
pygments.rb (0.2.3)
rubypython (>= 0.5.1)
pygments.rb (0.2.4)
rubypython (~> 0.5.3)
rack (1.3.5)
rack-cache (1.1)
rack (>= 0.4)
......@@ -306,7 +306,7 @@ DEPENDENCIES
kaminari
launchy
letter_opener
pygments.rb (= 0.2.3)
pygments.rb (= 0.2.4)
rails (= 3.1.1)
rails-footnotes (~> 3.7.5)
rdiscount
......
......@@ -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;
}
}
}
......@@ -726,3 +726,31 @@ a.project-update.titled {
float:left;
}
}
tr.line_notes_row {
&:hover {
background:none;
}
td {
margin:0px;
padding:0px;
border-bottom:1px solid #DEE2E3;
ul {
display:block;
list-style:none;
margin:0px;
padding:0px;
li {
border-top:1px solid #DEE2E3;
padding:10px;
.delete-note {
display:none;
}
}
}
}
}
......@@ -27,6 +27,8 @@ class CommitsController < ApplicationController
@notes = project.commit_notes(@commit).fresh.limit(20)
@note = @project.build_commit_note(@commit)
@line_notes = project.commit_line_notes(@commit)
respond_to do |format|
format.html
format.js { respond_with_notes }
......
......@@ -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
......@@ -53,6 +53,23 @@ class Note < ActiveRecord::Base
noteable
end
end
def line_file_id
@line_file_id ||= line_code.split("_")[1].to_i if line_code
end
def line_type_id
@line_type_id ||= line_code.split("_").first if line_code
end
def line_number
@line_number ||= line_code.split("_").last.to_i if line_code
end
def for_line?(file_id, old_line, new_line)
line_file_id == file_id &&
((line_type_id == "NEW" && line_number == new_line) || (line_type_id == "OLD" && line_number == old_line ))
end
end
# == Schema Information
#
......
......@@ -166,7 +166,11 @@ class Project < ActiveRecord::Base
end
def commit_notes(commit)
notes.where(:noteable_id => commit.id, :noteable_type => "Commit")
notes.where(:noteable_id => commit.id, :noteable_type => "Commit", :line_code => nil)
end
def commit_line_notes(commit)
notes.where(:noteable_id => commit.id, :noteable_type => "Commit").where("line_code not null")
end
def has_commits?
......
......@@ -18,7 +18,11 @@
= link_to raw(diff_line_class(line) == "new" ? "&nbsp;" : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}"
%td.new_line
= link_to raw(diff_line_class(line) == "old" ? "&nbsp;" : line_new) , "#NEW#{index}-#{line_new}", :id => "NEW#{index}-#{line_new}"
%td.line_content{:class => diff_line_class(full_line)}= raw "#{full_line} &nbsp;"
%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} &nbsp;"
- comments = @line_notes.select { |n| n.for_line?(index, line_old, line_new) }.sort_by(&:created_at).reverse
- unless comments.empty?
- 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("dblclick", 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?
: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");
class AddLineNumberToNote < ActiveRecord::Migration
def change
add_column :notes, :line_code, :string, :null => true
end
end
......@@ -11,7 +11,19 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111220190817) do
ActiveRecord::Schema.define(:version => 20120110180749) do
create_table "features", :force => true do |t|
t.string "name"
t.string "branch_name"
t.integer "assignee_id"
t.integer "author_id"
t.integer "project_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "version"
t.integer "status", :default => 0, :null => false
end
create_table "issues", :force => true do |t|
t.string "title"
......@@ -56,6 +68,7 @@ ActiveRecord::Schema.define(:version => 20111220190817) do
t.datetime "updated_at"
t.integer "project_id"
t.string "attachment"
t.string "line_code"
end
create_table "projects", :force => true do |t|
......
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