完成issue和commit关联创建。去重,及相关局部刷新
This commit is contained in:
parent
66066e6899
commit
33a4186e69
|
@ -22,9 +22,9 @@ class IssuesController < ApplicationController
|
|||
before_filter :authorize1, :only => [:show]
|
||||
before_filter :find_issue, :only => [:show, :edit, :update,:add_journal, :add_journal_in_org]
|
||||
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
|
||||
before_filter :find_project, :only => [:new, :create, :update_form, :issue_commits]
|
||||
before_filter :find_project, :only => [:new, :create, :update_form, :issue_commits, :commit_for_issue]
|
||||
#before_filter :authorize, :except => [:index, :show]
|
||||
before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits]
|
||||
before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits, :commit_for_issue]
|
||||
|
||||
before_filter :find_optional_project, :only => [:index]
|
||||
before_filter :check_for_default_issue_status, :only => [:new, :create]
|
||||
|
@ -62,17 +62,28 @@ class IssuesController < ApplicationController
|
|||
def issue_commits
|
||||
begin
|
||||
return render_404 if @project.gpid.nil?
|
||||
@issue_commit_ids = params[:issue_commit_ids].split(",")
|
||||
search = params[:search].to_s.lstrip.rstrip
|
||||
@type = params[:type]
|
||||
limit = 20
|
||||
g = Gitlab.client
|
||||
g_project = g.project(@project.gpid)
|
||||
rev = params[:rev].nil? ? g_project.default_branch : params[:rev]
|
||||
@commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev)
|
||||
rev = params[:branch].nil? ? g_project.default_branch : params[:branch]
|
||||
@commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev).select{|commit| commit.title.include?("#{search}")}
|
||||
@project_branches = g.branches(@project.gpid)
|
||||
@branch_names = @project_branches.map{|b| b.name}
|
||||
@default_branch = g_project.default_branch
|
||||
@commits_count = g.user_static(@project.gpid, :rev => rev).count
|
||||
@commits_pages = Redmine::Pagination::Paginator.new @commits_count, limit, params[:page]
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
end
|
||||
|
||||
def commit_for_issue
|
||||
history_commit_ids = params[:issue_commit_ids]
|
||||
@issue_commit_ids = (history_commit_ids.blank? ? params[:checkbox1] : params[:checkbox1] | history_commit_ids).uniq
|
||||
end
|
||||
# over
|
||||
|
||||
def index
|
||||
|
@ -181,13 +192,13 @@ class IssuesController < ApplicationController
|
|||
def show
|
||||
# 顶部导航
|
||||
@project_menu_type = 2
|
||||
|
||||
# 打开编辑内容
|
||||
@is_edit = true unless params[:edit].nil?
|
||||
|
||||
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
|
||||
query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first
|
||||
query.update_attribute(:viewed, true) unless query.nil?
|
||||
# issue 关联的commit
|
||||
@commits = CommitIssues.where(:issue_id => @issue.id, :project_id => @issue.project_id)
|
||||
|
||||
# issue 新建的at消息
|
||||
User.current.at_messages.unviewed('Issue', @issue.id).each {|x| x.viewed!}
|
||||
|
@ -256,6 +267,13 @@ class IssuesController < ApplicationController
|
|||
@issue.fixed_version_id = nil if @issue.fixed_version_id == 0
|
||||
@issue.assigned_to_id = nil if @issue.assigned_to_id == 0
|
||||
if @issue.save
|
||||
# 关联commmit
|
||||
commits = params[:had_commits]
|
||||
if commits
|
||||
commits.each do |commit|
|
||||
CommitIssues.create(:commit_id => commit.id, :project_id => @issue.project_id, :issue_id => @issue.id)
|
||||
end
|
||||
end
|
||||
#params[:issue][:assigned_to_id] = nil if params[:issue][:assigned_to_id].to_i == 0
|
||||
senduser = User.find(params[:issue][:assigned_to_id])
|
||||
issue_id = @issue.id
|
||||
|
|
|
@ -110,8 +110,8 @@
|
|||
<label class="label02" ></label>
|
||||
<% if @issue.safe_attribute? 'due_date' %>
|
||||
<%= f.text_field :due_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
|
||||
:required => @issue.required_attribute?('due_date'), :onchange => "issue_end_date_change();",
|
||||
:class => "fl calendar_input",:style => "width: 170px;", :placeholder => "请选择结束日期" %>
|
||||
:required => @issue.required_attribute?('due_date'), :onchange => "issue_end_date_change();",
|
||||
:class => "fl calendar_input",:style => "width: 170px;", :placeholder => "请选择结束日期" %>
|
||||
<%= calendar_for('issue_due_date', 'start_date') if @issue.leaf? %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
@ -121,7 +121,7 @@
|
|||
<li class="clear">
|
||||
<% if @issue.safe_attribute? 'estimated_hours' %>
|
||||
<%= f.text_field :estimated_hours, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
|
||||
:required => @issue.required_attribute?('estimated_hours'), :placeholder => "请填写预计工时" %>
|
||||
:required => @issue.required_attribute?('estimated_hours'), :placeholder => "请填写预计工时" %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="clear"><%= l(:field_estimated_hours) %></li>
|
||||
|
@ -129,18 +129,45 @@
|
|||
<li class="clear">
|
||||
<% if @issue.safe_attribute?('done_ratio') && @issue.leaf? && Issue.use_field_for_done_ratio? %>
|
||||
<%= f.select :done_ratio, ((0..10).to_a.collect { |r| ["#{r*10} %", r*10] }),
|
||||
{:required => @issue.required_attribute?('done_ratio'), :no_label => true},
|
||||
:onchange => "PrecentChange(this.value)",
|
||||
:class => "w150" %>
|
||||
{:required => @issue.required_attribute?('done_ratio'), :no_label => true},
|
||||
:onchange => "PrecentChange(this.value)",
|
||||
:class => "w150" %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="clear">完成度</li>
|
||||
<% if @project.gpid %>
|
||||
<li class="clear"><span>关联Commit</span><%= link_to "<span class='btn-commit btn-blue mt-2 fr'>+</span>".html_safe, issue_commits_issues_path(:project_id => @project), :remote => true %></li>
|
||||
<!--<li class="clear"><span>关联Commit</span><%#= link_to "<span class='btn-commit btn-blue mt-2 fr'>+</span>".html_safe, issue_commits_issues_path(:project_id => @project), :remote => true %></li>-->
|
||||
<li class="clear"><span>关联Commit</span>
|
||||
<a href="javascript:void(0)" onclick="get_issue_commit_ids('issue_commit_ids','<%= @project.id %>');">
|
||||
<span class='btn-commit btn-blue mt-2 fr'>+</span>
|
||||
</a>
|
||||
</li>
|
||||
<div id="issue_commit_ids">
|
||||
<%= render :partial => "issues/issue_commit_ids" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<script>
|
||||
function get_issue_commit_ids(id, project_id){
|
||||
var issue_commit_ids = $("#issue_commit_ids .commit_id_value");
|
||||
var str = "";
|
||||
for(var i=0; i < issue_commit_ids.length; i++){
|
||||
str += $(issue_commit_ids[i]).html();
|
||||
if(i != issue_commit_ids.length -1){
|
||||
str += ",";
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'issues', :action => 'issue_commits') %>',
|
||||
type:'post',
|
||||
data:{
|
||||
project_id: project_id,
|
||||
issue_commit_ids: str
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function change_assigned_tip() {
|
||||
if( document.getElementById('issue_assigned_to_id').options[document.getElementById('issue_assigned_to_id').selectedIndex].value == 0 ){
|
||||
$('#assigned_to_tips').html("未指派");
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<% if @issue_commit_ids %>
|
||||
<% @issue_commit_ids.each do |commit_id| %>
|
||||
<div class="btn btn-blue mb5">
|
||||
<%= link_to commit_id[0,8], {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit_id}, :target => "_blank", :class => "commit_id_value" %>
|
||||
<a href="#" style="color:#fff;">×</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="c_grey">暂无</div>
|
||||
<% end %>
|
|
@ -11,64 +11,32 @@
|
|||
<% else %>
|
||||
<div class=" clear">
|
||||
<div class="cl"></div>
|
||||
<ul class="clear lightheight28 fl">
|
||||
<li class="mb10 clear fl">
|
||||
<span class=" fl"> 分支 : </span>
|
||||
<select class=" fl newupload_select" style="width:180px;">
|
||||
<option> 黄井泉</option>
|
||||
</select>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="hw_search_box fr mb10" >
|
||||
<input class="hw_search-input" style="width:300px;" placeholder="输入描述的关键词进行搜索" type="text">
|
||||
<a href="javascript:void(0);" class="hw_btn_search"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<table class="newupload_table " cellspacing="0" cellpadding="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="newupload_td01"> </th>
|
||||
<th class="newupload_td04">修订号</th>
|
||||
<th>描述</th>
|
||||
<th class="newupload_td04">提交者</th>
|
||||
<th class="newupload_td05">提交日期</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @commits.each do |commit| %>
|
||||
<tr>
|
||||
<td class="newupload_td01"><input type="checkbox"> </td>
|
||||
<td class="newupload_td04">
|
||||
<span class="newupload_table_name">
|
||||
<%= link_to commit.id[0,8], {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %>
|
||||
</span>
|
||||
</td>
|
||||
<td class="newupload_td02"><p><%= commit.message %></p></td>
|
||||
<td class="newupload_td04"><span class="newupload_table_name">
|
||||
<%= link_to_user_mail(commit.author_email) %></span></td>
|
||||
<td class="newupload_td05"><%= format_date(commit.created_at) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="clear">
|
||||
<div class="clear fl mt10">
|
||||
<button class=" btn btn-blue fr ">确定</button >
|
||||
<button class=" btn fr mr5">取消</button >
|
||||
</div>
|
||||
<div style="text-align:center;">
|
||||
<div class="pages" style="width:auto; display:inline-block;">
|
||||
<ul id="homework_pository_ref_pages">
|
||||
<%= pagination_links_full @commits_pages, @commits_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<%= form_tag(url_for(:controller => 'issues', :action => 'issue_commits', :project_id => @project.id, :type => "search"),
|
||||
:remote => true, :method => 'get', :id => 'issue_commit_form', :class => "fl") do %>
|
||||
<ul class="clear lightheight28 fl">
|
||||
<li class="mb10 clear fl">
|
||||
<span class=" fl"> 分支 : </span>
|
||||
<%= select_tag :branch, options_for_select(["#{@default_branch}"]+ @branch_names, @rev),
|
||||
:class => "fl newupload_select", :style => "width:180px;",
|
||||
:onchange => "$('#issue_commit_form').submit();" %>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="hw_search_box fr mb10" >
|
||||
<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="hw_search-input" style="width:300px;">
|
||||
<%= submit_tag '', :class => 'hw_btn_search', :onfocus => 'this.blur();', :style => 'border-style:none' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="issue_commit_list">
|
||||
<%= render :partial => "issues/issue_commits_list" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function remote_function(id) {
|
||||
$(id).submit();
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,41 @@
|
|||
<%= form_tag(url_for(:controller => 'issues', :action => 'commit_for_issue', :project_id => @project.id, :issue_commit_ids => @issue_commit_ids), :remote => true, :method => 'get', :id => 'commit_for_issue', :class => "fl") do %>
|
||||
<table class="newupload_table " cellspacing="0" cellpadding="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="newupload_td01"> </th>
|
||||
<th class="newupload_td04">修订号</th>
|
||||
<th>描述</th>
|
||||
<th class="newupload_td04">提交者</th>
|
||||
<th class="newupload_td05">提交日期</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @commits.each do |commit| %>
|
||||
<tr>
|
||||
<td class="newupload_td01"><input type="checkbox" value="<%= commit.short_id %>" name="checkbox1[]"> </td>
|
||||
<td class="newupload_td04"><span class="newupload_table_name">
|
||||
<%= link_to commit.id[0,8], {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %></span>
|
||||
</td>
|
||||
<td class="newupload_td02"><p><%= commit.title %></p></td>
|
||||
<td class="newupload_td04"><span class="newupload_table_name"><%= link_to_user_mail(commit.author_email) %></span></td>
|
||||
<td class="newupload_td05"><%= format_date(commit.created_at) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="clear">
|
||||
<div class="clear fl mt10">
|
||||
<a href="javascript:void(0);" class="sy_btn_blue fl" onclick="$('#commit_for_issue').submit();hideModal()">确 定</a>
|
||||
<a href="javascript:void(0);" class="sy_btn_grey fl ml10" onclick="hideModal()">取 消</a>
|
||||
</div>
|
||||
<div style="text-align:center;">
|
||||
<div class="pages" style="width:auto; display:inline-block;">
|
||||
<ul id="homework_pository_ref_pages">
|
||||
<%= pagination_links_full @commits_pages, @commits_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1 @@
|
|||
$("#issue_commit_ids").html('<%= escape_javascript(render :partial => 'issues/issue_commit_ids') %>');
|
|
@ -1,2 +1,7 @@
|
|||
<% if @type %>
|
||||
$("#issue_commit_list").html('<%= escape_javascript(render :partial => 'issues/issue_commits_list') %>');
|
||||
<% else %>
|
||||
var htmlvalue = "<%= escape_javascript(render :partial => 'issues/issue_commits') %>";
|
||||
pop_box_new(htmlvalue,760,860);
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -86,6 +86,15 @@
|
|||
<span class="pro_new_conbox_rightspan fl ml10"><%= @issue.done_ratio %>%</span>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="clear"><span class="pro_new_conbox_leftspan mb5">关联Commit</span>
|
||||
<div id="issue_commit_ids">
|
||||
<% if @commit_ids %>
|
||||
<% @commit_ids.each do |commit_id| %>
|
||||
<div class=" btn btn-blue mb5"><a class="commit_id_value" href="#" style="color: white"><%= commit_id %></a> <a href="#" style="color:#fff;">×</a></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -952,7 +952,8 @@ RedmineApp::Application.routes.draw do
|
|||
collection do
|
||||
match 'bulk_edit', :via => [:get, :post]
|
||||
post 'bulk_update'
|
||||
get 'issue_commits'
|
||||
post 'issue_commits'
|
||||
get 'commit_for_issue'
|
||||
end
|
||||
member do
|
||||
post 'add_journal'
|
||||
|
|
|
@ -788,6 +788,7 @@ a:hover.issues_list_title{color:#3b94d6;}
|
|||
.hw_search_box{ position:relative; }
|
||||
.hw_search_box input.hw_search-input{ width:293px; height:28px; border:none; border:1px solid #e7e7e7; background:#fff; padding-left:5px;padding-right: 25px;}
|
||||
.hw_search_box a.hw_btn_search{display:block; width:20px; height:20px; background:url(/images/hw/icons_hw.png) 0 -57px no-repeat; position:absolute; right:5px; top:5px; cursor:pointer;}
|
||||
.hw_search_box input.hw_btn_search{display:block; width:20px; height:20px; background:url(/images/hw/icons_hw.png) 0 -57px no-repeat; position:absolute; right:5px; top:5px; cursor:pointer;}
|
||||
.hw_search_box a:hover.hw_btn_search{background:url(/images/hw/icons_hw.png) -40px -57px no-repeat;}
|
||||
.hw_files_icon{display:block; width:17px; height:14px; background:url(../images/hw/icons_hw.png) 0 -135px no-repeat;}
|
||||
/* 编辑删除 与课程相同 */
|
||||
|
@ -1057,3 +1058,4 @@ table.text-file{}
|
|||
.old:hover{ background:#fffaf1; }
|
||||
.new{ background: #eaffea;}
|
||||
.new:hover{ background:#fffaf1; }
|
||||
.commit_id_value{color: white !important;}
|
Loading…
Reference in New Issue