socialforge/app/views/pull_requests/_form.html.erb

74 lines
4.2 KiB
Plaintext
Raw Normal View History

2016-08-04 19:32:44 +08:00
<%= 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 %>
2016-08-03 11:07:49 +08:00
<div class="new-merge-wrap">
<div class="merge-option-name fl mt8">标题</div><input type="text" id="pr_name" name="title" class="merge-title-input fl ml30" />
<p id ="pull_request_title" class="fl ml100 fontGrey2 mt5 c_red" style="display: none">标题不能为空</p>
2016-08-03 11:07:49 +08:00
<div class="cl mb10"></div>
<div class="merge-option-name fl">描述</div><textarea type="text" name="description" class="merge-description-input fl ml30"></textarea>
<!--<p class="fl ml100 f12 mt5"><a href="javascript:void(0);" class="AnnexBtn fl mr10">上传附件</a></p>-->
<div class="cl"></div>
</div>
<div class="new-merge-wrap borderBottomNone">
<div class="merge-option-name fl" style="padding:5px 0">源分支</div>
2016-08-05 10:42:06 +08:00
<%= select_tag :branch, options_for_select(@source_rev), :name => "source_branch", :value => "source_branch", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;" %>
2016-08-03 17:37:37 +08:00
<!--<select name="source_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>develop</option><option>rep_quality</option></select>-->
2016-08-03 11:07:49 +08:00
<div class="cl mb10"></div>
<div class="merge-option-name fl" style="padding:5px 0">目标分支</div>
2016-08-05 10:42:06 +08:00
<% if @forked_project.nil? %>
<%= 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" %>
<% else %>
2016-08-05 11:10:39 +08:00
<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;">
2016-08-05 10:42:06 +08:00
<option value="source_project_name"><%= @source_project_name %></option>
<option value="forked_project_name"><%= @forked_project_name %></option>
</select>
2016-08-05 11:10:39 +08:00
<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>
2016-08-05 10:42:06 +08:00
<%#= 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" %>
<%#= 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" %>
2016-08-04 18:30:04 +08:00
<% end %>
2016-08-03 17:37:37 +08:00
<!--<select name="target_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>hjq_course</option><option>hjq_beidou</option><option>develop</option><option>dev_huang</option></select>-->
2016-08-03 11:07:49 +08:00
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
<a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="pull_request_commit()">提交请求</a>
2016-08-03 11:07:49 +08:00
<%= link_to "返回", project_pull_requests_path(:project_id => @project.id), :class => "fr linkGrey2 mt5 mr10" %>
<div class="cl"></div>
</div>
<% end %>
<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;
}
}
//提交pull request
function pull_request_commit()
{
if(regex_pr_name())
{
$("#pull_request_form").submit();
}
}
//切换项目时,替换分支
$("#targetProject").change(function(){
var defaultBranch = $("#targetBranch option:first-child").val();
$("#targetBranch").val(defaultBranch);
});
</script>