[refs #579] fixed many errors

This commit is contained in:
Alexander Machehin 2012-10-05 17:02:25 +06:00
parent afa6dd0706
commit 2360a25a42
8 changed files with 20 additions and 23 deletions

View File

@ -23,12 +23,12 @@ module DiffHelper
#include Git::Diff::InlineCallback
def render_diff(diff, diff_counter)
diff_display ||= Diff::Display::Unified.new(diff.diff)
path = if @pull
url = if @pull
@pull.id ? polymorphic_path([@project, @pull]) : ''
elsif @commit
commit_path @project, @commit
end
prepare(diff, path)
prepare(diff, url, diff_counter)
res = "<table class='diff inline' cellspacing='0' cellpadding='0'>"
res += "<tbody>"
@ -41,9 +41,9 @@ module DiffHelper
########################################################
# FIXME: Just to dev, remove to lib
########################################################
def prepare(diff, comments, url, diff_counter)
@num_line, @url, @diff_counter = -1, url, diff_counter
@line_comments = @comments.select{|c| c.data.try('[]', :path) == @path}
def prepare(diff, url, diff_counter)
@num_line, @filepath, @url, @diff_counter = -1, diff.a_path, url, diff_counter
@line_comments = @comments.select{|c| c.data.try('[]', :path) == @filepath}
end
def headerline(line)
@ -212,7 +212,7 @@ module DiffHelper
end
def line_comment
link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @diff.a_path, :line => @num_line), :class => 'add_line-comment'
link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @filepath, :line => @num_line), :class => 'add_line-comment'
end
def render_line_comments

View File

@ -132,9 +132,7 @@ class Ability
can([:create, :new_line], Comment) {|comment| can? :read, comment.project}
can([:update, :destroy], Comment) {|comment| comment.user == user or comment.project.owner == user or local_admin?(comment.project)}
cannot :manage, Comment do |c|
c.commentable_type == 'Issue' && !c.project.has_issues && !c.commentable.pull_request # when switch off issues
end
cannot :manage, Comment, :commentable_type => 'Issue', :project => {:has_issues => false}
end
# Shared cannot rights for all users (registered, admin)

View File

@ -1,6 +1,5 @@
#open-comment.comment.view
=render 'projects/comments/button_md_help'
=link_to t('layout.comments.md_cheatsheet_header'), '#md_help', 'data-toggle' => 'modal', :style => 'float:right;'
%h3.tmargin0= t("layout.comments.new_header")
- if Comment.issue_comment?(commentable.class)
- new_path = project_issue_comments_path(project, commentable)

View File

@ -0,0 +1,2 @@
=link_to t('layout.comments.md_cheatsheet_header'), '#md_help', 'data-toggle' => 'modal', :style => 'float:right;'

View File

@ -1,11 +1,3 @@
- list.each do |comment|
.inline-comments
- CommentPresenter.present(comment, :project => project, :commentable => commentable) do |presenter|
= render 'shared/feed_message', :presenter => presenter
#open-comment.comment.hidden{:class => "comment-#{comment.id}"}
%h3.tmargin0= t("layout.comments.edit_header")
= form_for comment, :url => project_commentable_comment_path(project, commentable, comment), :html => { :class => 'form edit_comment' } do |f|
= render "projects/comments/form", :f => f, :id => "edit_#{comment.id}"
.comment-left
=link_to t('layout.cancel'), '#', :id => "comment-#{comment.id}", :class => 'cancel_edit_comment button'
.both
= render 'projects/comments/comment', :comment => comment, :project => project, :commentable => commentable

View File

@ -0,0 +1,5 @@
class AddDataToComments < ActiveRecord::Migration
def change
add_column :comments, :data, :text
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20121003154246) do
ActiveRecord::Schema.define(:version => 20121005100158) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@ -146,6 +146,7 @@ ActiveRecord::Schema.define(:version => 20121003154246) do
t.datetime "updated_at", :null => false
t.decimal "commentable_id", :precision => 50, :scale => 0
t.integer "project_id"
t.text "data"
end
create_table "event_logs", :force => true do |t|

View File

@ -2,8 +2,8 @@
module Git
module Diff
class InlineCallback < ::Diff::Renderer::Base
def initialize diff, comments, url, diff_counter
@num_line, @url, @diff_counter = -1, url, diff_counter
def initialize diff, url, diff_counter
@num_line, @filepath, @url, @diff_counter = -1, diff.a_path, url, diff_counter
@line_comments = @comments.select{|c| c.data.try('[]', :path) == @path}
end
@ -173,7 +173,7 @@ module Git
end
def line_comment
link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @diff.a_path, :line => @num_line), :class => 'add_line-comment'
link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @filepath, :line => @num_line), :class => 'add_line-comment'
end
def render_line_comments