pull request 选择项目的时候JS控制分支
This commit is contained in:
parent
0fd6ca1969
commit
45bbd7b293
|
@ -92,7 +92,7 @@ class PullRequestsController < ApplicationController
|
|||
if compare_pull_request(source_branch, target_project_id, target_branch)
|
||||
# 如果传送了目标项目ID即向fork源项目发送请求
|
||||
# if params[:forked_project_id] && params[:source_project] == "forked_project_name"
|
||||
if params[:target_project_id]
|
||||
if params[:target_project_id].to_i != @project.id
|
||||
target_project_id = params[:forked_project_id].to_i
|
||||
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id)
|
||||
@fork_project_name = Project.find(params[:target_project_id]).try(:name)
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
<% if @forked_project.nil? %>
|
||||
<%= select_tag :branch, options_for_select(@source_rev), :id => "pull_request_branch", :name => "target_branch", :value => "target_branch",:class => "fl PullReques_minselect ml5" %>
|
||||
<% else %>
|
||||
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" id="target_project_id" name="target_project_id" value="target_project_id" class="fl PullReques_minselect">
|
||||
<option id="source_project_name" name="<%= @project.id %>" value="<%= @project.id %>" ><%= @source_project_name %></option>
|
||||
<option id="target_project_name" name="<%= @forked_project.id %>" value="<%= @forked_project.id %>" ><%= @forked_project_name %></option>
|
||||
<select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>, <%= @project.id %>, <%= @project.forked_from_project_id %>);" id="target_project_id" name="target_project_id" value="target_project_id" class="fl PullReques_minselect">
|
||||
<option id="source_project_name" name="source_project_name" value="<%= @project.id %>" ><%= @source_project_name %></option>
|
||||
<option id="target_project_name" name="forked_project_name" value="<%= @forked_project.id %>" ><%= @forked_project_name %></option>
|
||||
</select>
|
||||
<select name="target_branch" id="pull_request_branch" class = "fl PullReques_minselect ml5" >
|
||||
<% @source_rev.each do |rev| %>
|
||||
|
|
|
@ -665,18 +665,30 @@ function search_tag_attachment(url,tag_name,q,course_id,sort)
|
|||
}
|
||||
|
||||
|
||||
function choice_branch(name, branch, source_rev, forked_rev) {
|
||||
switch (name) {
|
||||
case "source_project_name" :
|
||||
var branchOptions = source_rev;
|
||||
break;
|
||||
case "forked_project_name" :
|
||||
var branchOptions = forked_rev;
|
||||
break;
|
||||
default:
|
||||
var branchOptions = source_rev;
|
||||
break;
|
||||
function choice_branch(name, branch, source_rev, forked_rev, project_id, project_forked_from_id) {
|
||||
if (name==project_id){
|
||||
var branchOptions = source_rev;
|
||||
}
|
||||
else if (name == project_forked_from_id){
|
||||
var branchOptions = forked_rev;
|
||||
}
|
||||
else{
|
||||
var branchOptions = source_rev;
|
||||
}
|
||||
|
||||
// switch (name) {
|
||||
// case project_id :
|
||||
// alert("project_id" + project_id);
|
||||
// var branchOptions = source_rev;
|
||||
// break;
|
||||
// case project_forked_from_id :
|
||||
// alert("project_forked_from_id"+project_forked_from_id);
|
||||
// var branchOptions = forked_rev;
|
||||
// break;
|
||||
// default:
|
||||
// var branchOptions = source_rev;
|
||||
// break;
|
||||
// }
|
||||
|
||||
branch.options.length = 0;
|
||||
for (var i = 0; i < branchOptions.length; i++) {
|
||||
|
|
Loading…
Reference in New Issue