项目issue关联commit(未完成)
This commit is contained in:
parent
890b0e80fd
commit
bbc8d11f80
|
@ -55,7 +55,7 @@ class ApplicationController < ActionController::Base
|
|||
include Redmine::Search::Controller
|
||||
include Redmine::MenuManager::MenuController
|
||||
helper Redmine::MenuManager::MenuHelper
|
||||
|
||||
|
||||
def user_agent
|
||||
logger.info "HTTP_USER_AGENT #{request.env["HTTP_USER_AGENT"]}"
|
||||
end
|
||||
|
|
|
@ -57,6 +57,21 @@ class IssuesController < ApplicationController
|
|||
helper :project_score
|
||||
include ApplicationHelper
|
||||
|
||||
# issue和代码提交id关联模块 --> over
|
||||
# 获取某个项目的commit_ids
|
||||
def issue_commits
|
||||
project = Project.find(@issue.project_id)
|
||||
begin
|
||||
g = Gitlab.commits(project.gpid)
|
||||
g_project = g.project(project.gpid)
|
||||
@rev = params[:rev].nil? ? g_project.default_branch : params[:rev]
|
||||
@commits = g.g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev)
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
end
|
||||
# over
|
||||
|
||||
def index
|
||||
# 顶部导航
|
||||
@project_menu_type = 2
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class CommitIssues < ActiveRecord::Base
|
||||
attr_accessible :commit_id, :issue_id, :project_id
|
||||
# 之所以没建立关联表,主要是应为commit_id是直接通过api获取的,不存在trustie端
|
||||
has_many :issues
|
||||
end
|
|
@ -74,28 +74,28 @@
|
|||
<label class="fl ml5" for="issue_is_private" id="issue_is_private_tips"><%= l(:field_set_private_tips)%></label>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class=" clear" id="versions_assigned_id">
|
||||
<li class="clear" id="versions_assigned_id">
|
||||
<% if @issue.safe_attribute? 'assigned_to_id' %>
|
||||
<%= f.select :assigned_to_id, assigned_options_for_select(@issue.assignable_users, @issue.assigned_to),
|
||||
{:required => @issue.required_attribute?('assigned_to_id'), :no_label => true},
|
||||
{:onchange => "change_assigned_tip();",:class => "w150"} %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class=" clear" id="assigned_to_tips">
|
||||
<li class="clear" id="assigned_to_tips">
|
||||
<%= @issue.assigned_to.nil? ? "未指派" : "已指派" %>
|
||||
</li>
|
||||
<li class=" clear" >
|
||||
<li class="clear" >
|
||||
<%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version),
|
||||
{:include_blank => true, :required => @issue.required_attribute?('fixed_version_id'), :no_label => true},
|
||||
{:onchange => "change_milestone_tip();", :class => "w150"} %>
|
||||
</li>
|
||||
<li class=" clear" id="milestone_option_tips">
|
||||
<li class="clear" id="milestone_option_tips">
|
||||
<%= @issue.fixed_version.nil? ? "未选择里程碑" : "已选择里程碑" %>
|
||||
<% if params[:action] == "new" %>
|
||||
<%= link_to "", new_project_version_path(@project, :is_issue => true, :issue_project_id => @project.id), :class => "pic_add mt5 ml5 fr", :remote => true %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class=" clear" style="border:1px solid #c8c8c8;">
|
||||
<li class="clear" style="border:1px solid #c8c8c8;">
|
||||
<% if @issue.safe_attribute? 'start_date' %>
|
||||
<%= f.text_field :start_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
|
||||
:required => @issue.required_attribute?('start_date'), :onchange => "issue_start_date_change();",
|
||||
|
@ -103,10 +103,10 @@
|
|||
<%= calendar_for('issue_start_date', 'start_date') if @issue.leaf? %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class=" clear" id="option_start_date_tips">
|
||||
<li class="clear" id="option_start_date_tips">
|
||||
<%= @issue.start_date.nil? ? "未选择开始日期" : "已选择开始日期" %>
|
||||
</li>
|
||||
<li class=" clear" style="border:1px solid #c8c8c8;">
|
||||
<li class="clear" style="border:1px solid #c8c8c8;">
|
||||
<label class="label02" ></label>
|
||||
<% if @issue.safe_attribute? 'due_date' %>
|
||||
<%= f.text_field :due_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
|
||||
|
@ -115,26 +115,27 @@
|
|||
<%= calendar_for('issue_due_date', 'start_date') if @issue.leaf? %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class=" clear " id="option_end_date_tips">
|
||||
<li class="clear " id="option_end_date_tips">
|
||||
<%= @issue.due_date.nil? ? "未选择结束日期" : "已选择结束日期" %>
|
||||
</li>
|
||||
<li class=" clear">
|
||||
<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 => "请填写预计工时" %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class=" clear"><%= l(:field_estimated_hours) %></li>
|
||||
<li class="clear"><%= l(:field_estimated_hours) %></li>
|
||||
|
||||
<li class=" clear">
|
||||
<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" %>
|
||||
<% end %>
|
||||
<li class=" clear">完成度</li>
|
||||
</li>
|
||||
<li class="clear">完成度</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 %></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<script>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
var htmlvalue = "<%= escape_javascript(render :partial => 'issues/issue_commits') %>";
|
||||
pop_box_new(htmlvalue,460,190);
|
|
@ -950,6 +950,7 @@ RedmineApp::Application.routes.draw do
|
|||
collection do
|
||||
match 'bulk_edit', :via => [:get, :post]
|
||||
post 'bulk_update'
|
||||
get 'issue_commits'
|
||||
end
|
||||
member do
|
||||
post 'add_journal'
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class CreateCommitIssues < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :commit_issues do |t|
|
||||
t.string :commit_id
|
||||
t.integer :issue_id
|
||||
t.integer :project_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -20,6 +20,7 @@ input.radio-width90{ width: 90px; }
|
|||
.muban_icons_blue{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #3b94d6;border: 1px solid #3b94d6;}
|
||||
/*模板buttons 20161013byLB*/
|
||||
.btn{display: inline-block;border:none; padding:0 10px;color: #333;background: #e1e1e1; text-align:center;font-size: 12px; height: 30px;line-height: 30px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; }
|
||||
.btn-commit{display: inline-block;border:none; padding:0 10px;color: #333;background: #e1e1e1; text-align:center;font-size: 12px; height: 20px;line-height: 20px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; }
|
||||
.btn:hover{background: #c3c3c3; color: #333;}
|
||||
.btn-grey{background: #d9d9d9; color: #656565;}
|
||||
.btn-grey:hover{background: #717171; color: #fff;}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :commit_issue, :class => 'CommitIssues' do
|
||||
commit_id "MyString"
|
||||
issue_id 1
|
||||
project_id 1
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CommitIssues, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue