fork分支选择 js

dev_blankdatabase
huang 9 years ago
parent b297446778
commit b86b2299a7

@ -60,7 +60,7 @@ class PullRequestsController < ApplicationController
target_branch = params[:target_branch] target_branch = params[:target_branch]
begin begin
# 如果传送了目标项目ID则PR请求发至目标项目 # 如果传送了目标项目ID则PR请求发至目标项目
if params[:target_project_id] if params[:forked_project_id]
target_project_id = params[:target_project_id] target_project_id = params[:target_project_id]
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) 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)
else else

@ -14,16 +14,18 @@
<div class="cl mb10"></div> <div class="cl mb10"></div>
<div class="merge-option-name fl" style="padding:5px 0">目标分支</div> <div class="merge-option-name fl" style="padding:5px 0">目标分支</div>
<% if @forked_project.nil? %> <% if @forked_project.nil? %>
<%= select_tag :branch, options_for_select(@source_project_name), :name => "target_project", :value => "target_project",
:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetProject" %>\
<%= select_tag :branch, options_for_select(@source_rev), :name => "target_branch", :value => "target_branch", <%= select_tag :branch, options_for_select(@source_rev), :name => "target_branch", :value => "target_branch",
:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetBranch" %> :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetBranch" %>
<% else %> <% else %>
<select onchange="choice_branch(this.value, document.getElementById('branch'), <%= @source_rev %>, <%= @forked_rev %>);" name="source_branch" value="source_branch" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;"> <select onchange="choice_branch(this.value, document.getElementById('pull_request_branch'), <%= @source_rev %>, <%= @forked_rev %>);" name="source_branch" value="source_branch" class="ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;">
<option value="source_project_name"><%= @source_project_name %></option> <option value="source_project_name"><%= @source_project_name %></option>
<option value="forked_project_name"><%= @forked_project_name %></option> <option value="forked_project_name"><%= @forked_project_name %></option>
</select> </select>
<select name="branch" id="branch" class = "ml30 fontGrey3 fb fl" style = "padding:5px 0 5px 5px;"></select> <select name="branch" id="pull_request_branch" class = "ml30 fontGrey3 fb fl" style = "width:140px; padding:5px 0 5px 5px;">
<% @source_rev.each do |rev| %>
<option value="source_project_name"><%= rev %></option>
<% end %>
</select>
<%#= select_tag :branch, options_for_select([@source_project_name, @forked_project_name]), :name => "target_project", :value => "target_project", <%#= select_tag :branch, options_for_select([@source_project_name, @forked_project_name]), :name => "target_project", :value => "target_project",
:class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetProject" %> :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetProject" %>
<%#= select_tag :branch, options_for_select(@source_rev), :name => "target_branch", :value => "target_branch", <%#= select_tag :branch, options_for_select(@source_rev), :name => "target_branch", :value => "target_branch",

@ -663,20 +663,18 @@ function search_tag_attachment(url,tag_name,q,course_id,sort)
function choice_branch(name, branch, source_rev, forked_rev) { function choice_branch(name, branch, source_rev, forked_rev) {
switch (name) { switch (name) {
case "source_project_name" : case "source_project_name" :
alert(source_rev);
var branchOptions = source_rev; var branchOptions = source_rev;
break; break;
case "forked_project_name" : case "forked_project_name" :
alert(forked_rev);
var branchOptions = forked_rev; var branchOptions = forked_rev;
break; break;
default: default:
var branchOptions = new Array(""); var branchOptions = source_rev;
break; break;
} }
branch.options.length = 0; branch.options.length = 0;
for (var i = 0; i < branchOptions.length; i++) { for (var i = 0; i < branchOptions.length; i++) {
branch.options[i] = new Option(branchOptions[i], branchOptions[i]); branch.options[i] = new Option(branchOptions[i]);
} }
} }
Loading…
Cancel
Save