From a62ede1a33b2dbe3d0d3e8498652b30c5757ab70 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 4 Aug 2016 10:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=88=E5=BB=BApull=20request=E5=8F=8A?= =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 7 +------ app/views/pull_requests/_error_message.html.erb | 5 +++++ app/views/pull_requests/_form.html.erb | 4 ++-- app/views/pull_requests/_new.html.erb | 8 +++----- app/views/pull_requests/create.js.erb | 1 + 5 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 app/views/pull_requests/_error_message.html.erb create mode 100644 app/views/pull_requests/create.js.erb diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 214bfc2dd..efa060434 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -47,17 +47,12 @@ class PullRequestsController < ApplicationController target_branch = params[:target_branch] begin request = @g.create_merge_request(@project.gpid, title, :description => description, :source_branch => source_branch, :target_branch => target_branch) - e.message respond_to do |format| - format.html{redirect_to project_pull_requests_path(request.id, :source_branch => source_branch, :target_branch => target_branch)} + format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} end rescue Exception => e @message = e.message - respond_to do |format| - format.html - end end - @message end def show diff --git a/app/views/pull_requests/_error_message.html.erb b/app/views/pull_requests/_error_message.html.erb new file mode 100644 index 000000000..6081f07c4 --- /dev/null +++ b/app/views/pull_requests/_error_message.html.erb @@ -0,0 +1,5 @@ +<% if @message %> +
+ <%= @message %> +
+<% end %> \ No newline at end of file diff --git a/app/views/pull_requests/_form.html.erb b/app/views/pull_requests/_form.html.erb index ff840c800..5cd684ca2 100644 --- a/app/views/pull_requests/_form.html.erb +++ b/app/views/pull_requests/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id), :id => 'pull_request_form', :method => "post") do %> +<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id), :id => 'pull_request_form', :method => "post", :remote => true) do %>
标题
@@ -13,7 +13,7 @@
目标分支
- <%= select_tag :branch, options_for_select(@rev), :name => "source_branch", :value => "source_branch", :class => "ml30 fontGrey3 fb fl" %> + <%= select_tag :branch, options_for_select(@rev), :name => "target_branch", :value => "target_branch", :class => "ml30 fontGrey3 fb fl" %>

修改分支

diff --git a/app/views/pull_requests/_new.html.erb b/app/views/pull_requests/_new.html.erb index 6ca978ed5..16f299ca5 100644 --- a/app/views/pull_requests/_new.html.erb +++ b/app/views/pull_requests/_new.html.erb @@ -1,8 +1,6 @@ -<% if @message %> -
- <%= @message %> -
-<% end %> +
+ <%= render :partial => "pull_requests/error_message" %> +
新的合并请求
diff --git a/app/views/pull_requests/create.js.erb b/app/views/pull_requests/create.js.erb new file mode 100644 index 000000000..36c9368af --- /dev/null +++ b/app/views/pull_requests/create.js.erb @@ -0,0 +1 @@ +$("#create_pull_request_error").html('<%= escape_javascript(render :partial => "pull_requests/error_message") %>'); \ No newline at end of file