完成changes数据获取及展示
This commit is contained in:
parent
8e329db4d8
commit
b8cccdffda
|
@ -48,6 +48,7 @@ class PullRequestsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@type = params[:type]
|
||||
@request = @g.merge_request(@project.gpid, params[:id])
|
||||
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
|
||||
end
|
||||
|
@ -72,12 +73,12 @@ class PullRequestsController < ApplicationController
|
|||
|
||||
# 获取某次请求的提交次数
|
||||
def pull_request_commits
|
||||
@type = parms[:type]
|
||||
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
|
||||
end
|
||||
|
||||
# 获取某次请求的改动
|
||||
def pull_request_changes
|
||||
@type = 2
|
||||
@changes = @g.merge_request_changes(@project.gpid, params[:id])
|
||||
end
|
||||
|
||||
|
|
|
@ -1,2 +1,13 @@
|
|||
module PullRequestsHelper
|
||||
|
||||
# 获取diff内容行号
|
||||
def diff_line_num content
|
||||
content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.nil? ? "" : content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i
|
||||
end
|
||||
|
||||
# 处理内容
|
||||
def diff_content content
|
||||
content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
<% @changes.each do |changes| %>
|
||||
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;">Showing <a href="javascript:void(0)" class="linkGrey3 fb" id="changed-files">3 changed files</a> with <span class="c_green fb">3 additions</span> and <span class="c_red fb">3 deletions</span>
|
||||
<ol class="mt10" id="changed-files-detail">
|
||||
<li><a href="javascript:void(0)" class="linkGrey3">app/views/organizations/_org_course_homework.html.erb</a> </li>
|
||||
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_course_homework.html.erb</a> </li>
|
||||
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_user_homework_detail.html.erb</a> </li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;"><a href="javascript:void(0)" class="linkGrey3"><img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" />app/views/organizations/_org_course_homework.html.erb</a></div>
|
||||
<div class="showing-changes-detail" style="width:750px; margin:0 -10px;">
|
||||
<table class="changes-detail-chart">
|
||||
<tr>
|
||||
<td class="diff-line-number fontGrey2">99</td>
|
||||
<td class="diff-line-number fontGrey2">99</td>
|
||||
<td class="fontGrey2 p10"><% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="diff-line-number fontGrey2">100</td>
|
||||
<td class="diff-line-number fontGrey2">100</td>
|
||||
<td class="fontGrey2 p10"><div class="mt10"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="diff-line-number fontGrey2 number-line-old">111</td>
|
||||
<td class="diff-line-number fontGrey2 number-line-old"></td>
|
||||
<td class="fontGrey2 p10 code-line-old">- <div class="fl mr5 fontGrey3"></td>
|
||||
</tr>
|
||||
<tr class="code-line-new">
|
||||
<td class="diff-line-number fontGrey2 number-line-new"></td>
|
||||
<td class="diff-line-number fontGrey2 number-line-new">111</td>
|
||||
<td class="fontGrey2 p10 code-line-new">+ <div class="fl mr20 fontGrey3 w80"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<% if @changes %>
|
||||
<% @changes.try(:changes).each do |cd| %>
|
||||
<div class="showing-changes-row fontGrey2">
|
||||
<a href="javascript:void()" class="linkGrey3" id="changed-files">
|
||||
<img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" /><%= cd['new_path'] %>
|
||||
</a>
|
||||
</div>
|
||||
<div class="autoscroll">
|
||||
<table class="filecontent syntaxhl" style="width:100%;" >
|
||||
<tbody>
|
||||
<% line_num = diff_line_num(cd['diff']) %>
|
||||
<% diff_content = diff_content(cd['diff']) %>
|
||||
<% syntax_highlight_lines('new_path', Redmine::CodesetUtil.to_utf8_by_setting(diff_content)).each do |line| %>
|
||||
<tr>
|
||||
<th class="line-num" id="L<%= line_num %>" style="vertical-align: top;">
|
||||
<a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a>
|
||||
</th>
|
||||
<% if line[0,1] == "-" %>
|
||||
<td class="line-code diff_out"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||
<% elsif line[0,1] == "+" %>
|
||||
<td class="line-code diff_in"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||
<% else%>
|
||||
<td class="line-code"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% line_num += 1 %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
$("#merge_record_1").html('<%= render :partial => "pull_requests/pull_request_changes" %>');
|
||||
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>');
|
|
@ -12,18 +12,16 @@
|
|||
</div>
|
||||
</div>
|
||||
<ul class="merge-record" style="border-top:1px solid #ddd;">
|
||||
<li><%= link_to "提交<span class='project-number-dot'>1</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "active" %></li>
|
||||
<li><%= link_to "改动<span class='project-number-dot'>1</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "active" %></li>
|
||||
<li><%= link_to "提交<span class='project-number-dot'>1</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
|
||||
<li><%= link_to "改动<span class='project-number-dot'>1</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
|
||||
</ul>
|
||||
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
|
||||
<div id="merge_record_0">
|
||||
<%= render :partial => "pull_requests/pull_request_commits" %>
|
||||
</div>
|
||||
<% if @type == 2 %>
|
||||
<div id="merge_record_1" class="undis">
|
||||
<%= render :partial => "pull_requests/pull_request_changes" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id="merge_record_1" class="undis">
|
||||
<%= render :partial => "pull_requests/pull_request_changes" %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#mergeShow").parent().css("width","730px");
|
||||
|
|
Loading…
Reference in New Issue