98 lines
4.7 KiB
Plaintext
98 lines
4.7 KiB
Plaintext
<div class="new_roadmap_conbox mb10" >
|
|
<div class="new_roadmap_info_top clear ">
|
|
<h4 class=" new_roadmap_listtitle"> 新建Pull Request </h4>
|
|
</div>
|
|
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id, :forked_project_id => @forked_project.try(:gpid)), :id => 'pull_request_form', :method => "post", :remote => true) do %>
|
|
<div class="clear new_roadmap_listbox">
|
|
<ul class="PullReques_new_box ">
|
|
<li class="mb10 clear">
|
|
<label class=" fl PullReques_label"> 源分支 : </label>
|
|
<%= select_tag :branch, options_for_select(@source_rev), :id => "source_branch", :name => "source_branch", :value => "source_branch", :class => "fl PullReques_minselect" %>
|
|
<label class=" fl ml10 "> 合并到目标分支 : </label>
|
|
<% 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="pull_request_project" name="source_project" value="source_project" class="fl PullReques_minselect">
|
|
<option name="<%= @project.id %>" value="source_project_name" ><%= @source_project_name %></option>
|
|
<option name="<%= @forked_project.id %>" value="forked_project_name" ><%= @forked_project_name %></option>
|
|
</select>
|
|
<select name="target_branch" id="pull_request_branch" class = "fl PullReques_minselect ml5" >
|
|
<% @source_rev.each do |rev| %>
|
|
<option value="<%= rev %>"><%= rev %></option>
|
|
<% end %>
|
|
</select>
|
|
<% end %>
|
|
<p id="pull_request_project_hidden" style="display: none"><%= @forked_project.nil? ? "" : @project.id %></p>
|
|
</li>
|
|
<div class="alert alert-blue mb10" id ="pull_request_branch_error" style="display: none">
|
|
<span class="c_orange">您选择的源分支和目标分支为似乎没有差异,请将新改动提交至源分支或者切换到其它目标分支</span>
|
|
</div>
|
|
<li class="mb10 clear">
|
|
<label class=" fl PullReques_label"><span class="c_red f12">*</span> 标题 : </label>
|
|
<input type="text" id="pr_name" name="title" class="fl PullReques_maxinput" placeholder="请输入合并请求的标题" />
|
|
</li>
|
|
<div class="c_orange pl62 mb4" id ="pull_request_title" style="display: none">
|
|
标题不能为空
|
|
</div>
|
|
<li class=" clear">
|
|
<label class=" fl PullReques_label"> 描述 : </label>
|
|
<textarea type="text" name="description" class="PullReques_textarea fl mb10" placeholder="在此输入合并请求的描述"></textarea>
|
|
</li>
|
|
<li class="mb10 clear">
|
|
<%= link_to "返回", project_pull_requests_path(:project_id => @project.id), :class => "btn btn-grey fr" %>
|
|
<a href="javascript:void(0);" class="btn btn-blue fr mr5" onclick="pull_request_commit()">确定</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<script>
|
|
function regex_pr_name()
|
|
{
|
|
var name = $.trim($("#pr_name").val());
|
|
if(name.length == 0)
|
|
{
|
|
$("#pull_request_title").show();
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
$("#pull_request_title").hide();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function regex_branch()
|
|
{
|
|
var source_branch = $.trim($("#source_branch").val());
|
|
var target_branch = $.trim($("#pull_request_branch").val());
|
|
var target_project = $.trim($("#pull_request_project").children().attr("name"));
|
|
var target_forked_project = $.trim($("#pull_request_project_hidden").text());
|
|
if(target_project == target_forked_project && source_branch == target_branch)
|
|
{
|
|
$("#pull_request_branch_error").show();
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
$("#pull_request_branch_error").hide();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
//提交pull request
|
|
function pull_request_commit()
|
|
{
|
|
if(regex_branch() && regex_pr_name())
|
|
{
|
|
$("#pull_request_form").submit();
|
|
}
|
|
}
|
|
|
|
//切换项目时,替换分支
|
|
$("#targetProject").change(function(){
|
|
var defaultBranch = $("#targetBranch option:first-child").val();
|
|
$("#targetBranch").val(defaultBranch);
|
|
});
|
|
</script> |