PR添加评论 列表页面

This commit is contained in:
huang 2016-08-09 14:00:36 +08:00
parent e7f01e5363
commit b7bccc7d22
6 changed files with 33 additions and 23 deletions

View File

@ -1,7 +1,7 @@
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]
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments]
layout "base_projects"
include PullRequestsHelper
include ApplicationHelper
@ -87,6 +87,8 @@ class PullRequestsController < ApplicationController
@commits_count = @commits.count
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
@comments = @g.merge_request_comments(@project.gpid, params[:id])
@comments_count = @comments.count
end
# Accept a merge request.
@ -170,6 +172,7 @@ class PullRequestsController < ApplicationController
def pull_request_commits
begin
@commits = @g.merge_request_commits(@project.gpid, params[:id])
@commits_count = @commits.count
rescue Exception => e
@message = e.message
end

View File

@ -0,0 +1,19 @@
<!--<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" %>
<span class="fl fontGrey2"><%#= time_tag(comment.author.try(:created_at)) %>前</span>
<div class="cl"></div>
<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>

View File

@ -7,13 +7,13 @@
<span class="mr10 open-status"><%= get_state(@request.state) %></span><span class="mr10">合并请求</span> 由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %> 于 <%= time_tag(@request.created_at) %> 前提交 · 最后编辑时间 <%= time_tag(@request.updated_at) %> 前
<% unless @request.state == "merged" %>
<%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %>
<% end %>
<% end %>
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>
<div class="mt10 mb15">
请求将 <span class="fontGrey3 fb"><%= @request.source_branch %></span> 合并至 <span class="fontGrey3 fb"><%= @request.target_branch %></span>
<% if @commits_count == 0 && @changes_count == 0 %>
<div class="merge-commit-option mt15">
<span class="fontGrey3 fb" style="font-size:13px;"><img src="/images/warning.png" width="16" class="mr5 mt2 fl"><%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %></span><br />
@ -33,28 +33,15 @@
</div>
<% end %>
<% end %>
</div>
<ul class="merge-record" style="border-top:1px solid #ddd;">
<li><%= link_to "留言<span class='project-number-dot'>#{@commits_count}</span>".html_safe, :class => "active" %></li>
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
<li><%= link_to "留言<span class='project-number-dot'>#{@comments_count}</span>".html_safe, pull_request_comments_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "active" %></li>
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true %></li>
</ul>
<div id="merge_record_0">
<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>
<div class="merge-discussion-content merge-discussion-automatic">
<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>
<div class="merge-discussion-input">
<textarea></textarea>
<a href="javascript:void(0);" class="BlueCirBtn">提 交</a>
</div>
<%= render :partial => "pull_requests/pull_request_comments" %>
</div>
<div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_commits" %>

View File

@ -1 +1 @@
$("#merge_record_1").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", :locals => {:type => @type} ) %>');

View File

@ -0,0 +1 @@
$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_comments") %>');

View File

@ -1 +1 @@
$("#merge_record_0").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", :locals => {:type => @type} ) %>');