PULL request 评论创建及局部刷新
This commit is contained in:
parent
b7bccc7d22
commit
87c5f50545
|
@ -1,7 +1,8 @@
|
|||
|
||||
class PullRequestsController < ApplicationController
|
||||
before_filter :find_project_and_repository
|
||||
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments]
|
||||
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new,
|
||||
:update_pull_request, :pull_request_comments, :create_pull_request_comment]
|
||||
layout "base_projects"
|
||||
include PullRequestsHelper
|
||||
include ApplicationHelper
|
||||
|
@ -145,9 +146,12 @@ class PullRequestsController < ApplicationController
|
|||
# Gitlab.create_merge_request(5, 'New merge request',
|
||||
# :source_branch => 'source_branch', :target_branch => 'target_branch', :assignee_id => 42)
|
||||
def create_pull_request_comment
|
||||
content = params[:content]
|
||||
content = params[:pull_request_comment]
|
||||
begin
|
||||
@comments = @g.create_merge_request_comment(@project.gpid, params[:id], content)
|
||||
respond_to do |format|
|
||||
format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)}
|
||||
end
|
||||
rescue Exception => e
|
||||
@message = e.message
|
||||
end
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
<!--<div class="merge-discussion-content">-->
|
||||
<!--<a href="javascript:void(0);" class="link-blue mr15 fl">Hjqreturn</a><span class="fl fontGrey2">20小时前</span>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--<div class="merge-discussion-detail">回复内容</div>-->
|
||||
<!--</div>-->
|
||||
<% @comments.each do |comment| %>
|
||||
<div class="merge-discussion-content merge-discussion-automatic">
|
||||
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %>
|
||||
|
@ -11,9 +6,36 @@
|
|||
<div class="merge-discussion-detail"><%= comment.note %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="merge-discussion-input">
|
||||
|
||||
<textarea></textarea>
|
||||
<a href="javascript:void(0);" class="BlueCirBtn">提 交</a>
|
||||
</div>
|
||||
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create_pull_request_comment', :project_id => @project.id), :id => 'pull_request_comment_form', :method => "post", :remote => true) do %>
|
||||
<textarea id="pull_request_comment" name="pull_request_comment"></textarea>
|
||||
<span id ="pr_comment_tip" class="fontGrey2 c_red" style="display: none">内容不能为空</span>
|
||||
<a href="javascript:void(0);" class="BlueCirBtn mt10" onclick="pull_request_commit()">提交请求</a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function regex_pr_comment()
|
||||
{
|
||||
var comment = $.trim($("#pull_request_comment").val());
|
||||
if(comment.length == 0)
|
||||
{
|
||||
$("#pr_comment_tip").show();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#pr_comment_tip").hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//提交pull request_comment
|
||||
function pull_request_commit()
|
||||
{
|
||||
if(regex_pr_comment())
|
||||
{
|
||||
$("#pull_request_comment_form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1 +1 @@
|
|||
$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>');
|
||||
$("#merge_record_2").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes") %>');
|
|
@ -1 +1 @@
|
|||
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>');
|
||||
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits") %>');
|
|
@ -818,6 +818,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'pull_request_changes'
|
||||
get 'update_pull_request'
|
||||
get 'pull_request_comments'
|
||||
post 'create_pull_request_comment'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -545,4 +545,4 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
|
|||
.merge-discussion-detail {font-size:13px; line-height:1.5em; color:#484848; margin-top:10px;}
|
||||
.merge-discussion-automatic {background-color:#fdfdfd;}
|
||||
.merge-discussion-input {margin:0 -10px; padding:10px; background-color:#f8f8f8;}
|
||||
.merge-discussion-input textarea {width:720px; height:80px; font-size:13px; line-height:16px; color:#484848; margin-bottom:10px; padding:5px;}
|
||||
.merge-discussion-input textarea {width:720px; height:80px; font-size:13px; line-height:16px; color:#484848; padding:5px;}
|
Loading…
Reference in New Issue