pull request列表及详情页面(详情未完)

This commit is contained in:
huang 2016-10-21 17:14:04 +08:00
parent d024bb1236
commit 5ebd829dbf
6 changed files with 245 additions and 79 deletions

View File

@ -47,9 +47,22 @@ module PullRequestsHelper
end
# 获取统计数
def request_commonts_count request_id, gpid
g = Gitlab.client
comments_count = g.merge_request_comments(gpid, request_id).count
end
# 通过状态获取样式
def pr_status_css status
case status
when "opened", "reopened"
"pullreques_blueicon"
when "merged"
"pullreques_greyicon"
when "closed"
"pullreques_greyicon02"
end
end
end

View File

@ -1,3 +1,29 @@
<div class="pd15box">
<div class="clear mb30">
<textarea class="pullreques_reply_textarea"></textarea>
<a href="javascript:void(0);" class="btn btn-blue fr">确定</a>
</div>
<ul class="pullreques_reply_list">
<% @comments.each do |comment| %>
<li>
<%= link_to image_tag(url_to_avatar(get_user_by_login_and(comment.author.try(:username))), :width => "43", :height => "43"), user_path(get_user_by_login_and(comment.author.try(:username))), :alt => "用户头像", :target => "_blank", :class => "fl" %>
<div class="sy_teachers_txt fl ">
<p class="clear mb5">
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "pullreques_reply_name fl", :target => "_blank" %>
<span class="fl ml15 c_grey"><%= time_tag(comment.created_at) %>前</span>
</p>
<p class="pullreques_reply_txt"><%= comment.note %></p>
</div>
<div class="cl"></div>
</li>
<% end %>
</ul>
</div>
<div class="merge-discussion-input">
<%= 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>

View File

@ -1,3 +1,96 @@
<div class="pullreques_pullbox">
<div class="pullreques_pull_top clear">
<p class="fl c_grey ml15">2016-09-12</p>
<p class="fr c_green mr15">2个提交</p>
</div>
<ul class="pullreques_pull_list">
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 姚虫虫姚虫虫姚虫虫 </a>
<p class="pullreques_pull_txt ml10 fl">项目导航栏数字错误</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 姚虫虫</a>
<p class="pullreques_pull_txt ml10 fl">项目导航栏数字错误</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 尹刚 </a>
<p class="pullreques_pull_txt ml10 fl">Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
</ul>
</div>
<div class="pullreques_pullbox">
<div class="pullreques_pull_top clear">
<p class="fl c_grey ml15">2016-09-12</p>
<p class="fr c_green mr15">2个提交</p>
</div>
<ul class="pullreques_pull_list">
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 姚虫虫姚虫虫姚虫虫 </a>
<p class="pullreques_pull_txt ml10 fl">项目导航栏数字错误</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 姚虫虫</a>
<p class="pullreques_pull_txt ml10 fl">项目导航栏数字错误</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 尹刚 </a>
<p class="pullreques_pull_txt ml10 fl">Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
</ul>
</div>
<div class="pullreques_pullbox">
<div class="pullreques_pull_top clear">
<p class="fl c_grey ml15">2016-09-12</p>
<p class="fr c_green mr15">2个提交</p>
</div>
<ul class="pullreques_pull_list">
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 姚虫虫姚虫虫姚虫虫 </a>
<p class="pullreques_pull_txt ml10 fl">项目导航栏数字错误</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 姚虫虫</a>
<p class="pullreques_pull_txt ml10 fl">项目导航栏数字错误</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
<li class="clear">
<span class="fl c_grey ml15 ">19分钟前</span>
<a href="javascript:void(0);" target="_blank" class="pullreques_pull_name fl ml10"> 尹刚 </a>
<p class="pullreques_pull_txt ml10 fl">Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop</p>
<span class="fr mr15 c_grey">acbc94af</span>
</li>
</ul>
</div>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<% if !@commits.blank? && @type == "2" %>
<% @commits.each do |commit| %>

View File

@ -19,12 +19,5 @@
</div>
<% end %>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %>

View File

@ -2,6 +2,90 @@
<%= render :partial => "pull_requests/error_message" %>
</div>
<!--PullReques开始-->
<div class="new_roadmap_conbox mb10" >
<div class="new_roadmap_info_top clear ">
<%= link_to "返回合并请求列表<span class='new_roadmap_icons_back mr5'></span>".html_safe, project_pull_requests_path(@project), :class => "fl linkBlue2 mt3" %>
<span class="ml5 mr5 fl f14">|</span><h4 class="fl new_roadmap_listtitle"><%= @request.title %> </h4><span class="fl <%= pr_status_css(@request.state) %> mt3 ml5"></span>
<% if User.current.login == @request.author.try(:username) || is_project_manager?(User.current.id, @project.id) %>
<% 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 => "fr c_grey" %>
<% end %>
<% end %>
<a href="javascript:void(0);" class=" fr c_grey mr10" >编辑</a>
</div>
<div class="clear new_roadmap_listbox">
<div class="c_grey02 mb10">
<p><%= @request.description %></p>
</div>
<div class="c_grey clear mt5">
<p class="fl">由 <a href="javascript:void(0);" class="linkBlue2 " ><%= @request.author.try(:username) %></a>于 <%= format_time(@request.created_at) %> 创建</p>
<span class="fl ml10">最近更新:<%= format_time(@request.updated_at) %></span>
<p class="fr"><%= @request.source_branch %><span class="c_grey02 ml10 mr10">合并到</span><%= @request.target_branch %></p>
</div>
</div>
</div>
<div class="alert alert-orange mb15 ">
在管理员接受后,将由系统自动合并。<%= link_to "接受", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "linkBlue2", :remote => true %>接受</a>
</div>
<div class="new_roadmap_conbox " >
<div class=" clear">
<ul class="new_roadmap_nav fl" >
<li class="new_roadmap_nav_hover ">
<%= link_to "评论<span class='new_roadmap_nav_taghover ml5'>#{@comments_count}</span>".html_safe, pull_request_comments_project_pull_request_path(@request.id, :project_id => @project.id, :type => "1"), :remote => true, :class => "new_roadmap_type_nomal" %>
<!--<a href="javascript:void(0);" id="new_roadmap_type_1" class="new_roadmap_type_nomal" >评论<span id="new_roadmap_num_1" class="new_roadmap_nav_taghover ml5">210</span></a>-->
</li>
<li>
<%= link_to "提交<span class='new_roadmap_nav_tagnomal ml5'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => "2"), :remote => true, :class => "new_roadmap_type_nomal" %></li>
<!--<a href="javascript:void(0);" id="new_roadmap_type_2" class="new_roadmap_type_nomal" >提交<span id="new_roadmap_num_2" class="new_roadmap_nav_tagnomal ml5">25</span></a>-->
</li>
<li>
<%= link_to "改动<span class='new_roadmap_nav_tagnomal ml5'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => "3"), :remote => true, :class => "new_roadmap_type_nomal" %></li>
<!--<a href="javascript:void(0);" id="new_roadmap_type_3" class="new_roadmap_type_nomal" >改动<span id="new_roadmap_num_3" class="new_roadmap_nav_tagnomal ml5">5</span></a>-->
</li>
</ul>
<% if @type == nil || @type == "1" %>
<div id="merge_record_0">
<%= render :partial => "pull_requests/pull_request_comments" %>
</div>
<% end %>
<div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_commits" %>
</div>
<div id="merge_record_2" class="undis">
<%= render :partial => "pull_requests/pull_request_changes" %>
</div>
</div>
<% if @type == nil || @type == "1" %>
<div id="merge_record_0">
<%= render :partial => "pull_requests/pull_request_comments" %>
</div>
<% end %>
<div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_commits" %>
</div>
<div id="merge_record_2" class="undis">
<%= render :partial => "pull_requests/pull_request_changes" %>
</div>
</div>
<!--PullReques结束-->
<div id="pull_request_show">
<div id="mergeShow" class="f14 fontGrey2 merge-show">
<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) %> 前
@ -43,7 +127,7 @@
</div>
<% end %>
<% end %>
</div>
</div>
<ul class="merge-record" style="border-top:1px solid #ddd;">
<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, :type => "1"), :remote => true, :class => "active" %></li>
@ -63,19 +147,17 @@
</div>
<% end %>
</div>
</div>
<script>
$("#pull_request_show").parent().css({"width":"730px","background-color":"#fff","padding":"10px","margin-left":"10px","margin-bottom":"10px"});
<script>
$(".new_roadmap_nav li").click(function(){
$(".new_roadmap_nav li").removeClass("new_roadmap_nav_hover");
$(this).addClass("new_roadmap_nav_hover");
$(".merge-record li a").click(function(){
$(".merge-record li a").removeClass("active");
$(this).addClass("active");
var index = $(".merge-record li a").index(this);
var index = $(".merge-record li a").index(this);
$("#merge_record_0, #merge_record_1, #merge_record_2").hide();
$("#merge_record_" + index).show();
});
</script>
$("#merge_record_0, #merge_record_1, #merge_record_2").hide();
$("#merge_record_" + index).show();
});
</script>

View File

@ -1,6 +1,6 @@
<% if @allow_to_pull_request %>
<!--PullReques列表开始-->
<div class="new_roadmap_conbox " >
<div class="new_roadmap_conbox mb10" >
<div class="new_roadmap_navbox clear">
<ul class="new_roadmap_nav fl" >
<li class="new_roadmap_nav_hover"><%= link_to "待处理<span class='new_roadmap_nav_taghover ml5'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true, :class => "new_roadmap_type_nomal" %></li>
@ -12,69 +12,28 @@
<% end %>
</div>
<!--<div class="pullreques_category clear ">-->
<!--<a href="javascript:void(0);" class="sortdownbtn mt10 fr mr15"></a>-->
<!--<a href="javascript:void(0);" class="sy_cgrey fr">更新时间</a>-->
<!--<a href="javascript:void(0);" class="sortupbtn mt10 fr"></a>-->
<!--<a href="javascript:void(0);" class="sy_cgrey fr">创建时间 </a>-->
<!--<a href="javascript:void(0);" class="sortdownbtn mt10 fr mr15"></a>-->
<!--<a href="javascript:void(0);" class="sy_cgrey fr">更新时间</a>-->
<!--<a href="javascript:void(0);" class="sortupbtn mt10 fr"></a>-->
<!--<a href="javascript:void(0);" class="sy_cgrey fr">创建时间 </a>-->
<!--</div>-->
<div id="pull_requests_list">
<%= render "pull_requests/pull_requests_list" %>
<div class=" pages ">
<a href="javascript:void(0);" class="pages-big" >上一页</a>
<a href="javascript:void(0);" class="active " >1</a>
<a href="javascript:void(0);" >2</a>
<a href="javascript:void(0);" >3</a>
<a href="javascript:void(0);" >...</a>
<a href="javascript:void(0);" >31</a>
<a href="javascript:void(0);" class="pages-big" >下一页</a>
<div class="cl"></div>
</div><!--翻页 end-->
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<div class="cl"></div>
</div><!--new_roadmap_content_1 end-->
</div><!--new_roadmap end-->
<!--PullReques列表结束-->
<%#= render :partial => "pull_requests/pull_request_container" %>
<ul id="mergeBanner" class="project-merge-banner">
<li class="active"><%= link_to "待处理<span class='project-number-dot'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true %></li>
<li><%= link_to "已处理<span class='project-number-dot'>#{@requests_merged_count}</span>".html_safe, project_pull_requests_path(:type => "2"), :remote => true %></li>
<li><%= link_to "已关闭<span class='project-number-dot'>#{@requests_closed_count}</span>".html_safe, project_pull_requests_path(:type => "3"), :remote => true %></li>
<% if allow_pull_request(@project) && User.current.member_of?(@project) %>
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
<% end %>
<div class="cl"></div>
</ul>
<div class="cl"></div>
<ul class="project-merge-content" id="pull_requests_list">
<%= render "pull_requests/pull_requests_list" %>
</ul>
</div>
</div>
<script>
// $("#mergeBanner").parent().css({"width":"730px","background-color":"#fff","padding":"10px","margin-left":"10px","margin-bottom":"10px"});
// $("#mergeBanner").parent().before("<div class='homepageRightBanner mb10'><span class='f16 fontGrey3'>Pull Request</span></div>");
// $("#mergeBanner").parent().css({"width":"730px","background-color":"#fff","padding":"10px","margin-left":"10px","margin-bottom":"10px"});
// $("#mergeBanner").parent().before("<div class='homepageRightBanner mb10'><span class='f16 fontGrey3'>Pull Request</span></div>");
$(".new_roadmap_nav li").click(function(){
$(".new_roadmap_nav li").removeClass("new_roadmap_nav_hover");