From: Julien Lancelot Date: Thu, 18 Jul 2013 13:55:39 +0000 (+0200) Subject: When submitting measures filter modal form, only errors are now returned to the form... X-Git-Tag: 3.7~54 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9f013dffb0bac6016739cd87b6ff16f232cb29e3;p=sonarqube.git When submitting measures filter modal form, only errors are now returned to the form, not the whole form --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb index 76c587377bc..5b0ee79b592 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb @@ -91,7 +91,7 @@ class MeasuresController < ApplicationController current_user.favourited_measure_filters<<@filter if add_to_favourites render :text => @filter.id.to_s, :status => 200 else - render :partial => 'measures/save_as_form', :status => 400 + render_measures_error(@filter) end end @@ -150,7 +150,7 @@ class MeasuresController < ApplicationController render :text => @filter.id.to_s, :status => 200 else - render :partial => 'measures/edit_form', :status => 400 + render_measures_error(@filter) end end @@ -179,10 +179,7 @@ class MeasuresController < ApplicationController current_user.favourited_measure_filters << target render :text => target.id.to_s, :status => 200 else - # keep the id (from source) and errors (from target) in the copy form - target.id= source.id - @filter = target - render :partial => 'measures/copy_form', :status => 400 + render_measures_error(target) end end @@ -239,4 +236,10 @@ class MeasuresController < ApplicationController def criteria_params params.merge({:controller => nil, :action => nil, :search => nil, :widget_id => nil, :edit => nil}) end + + def render_measures_error(filter) + errors = [] + filter.errors.full_messages.each{|msg| errors<'} + render :text => errors, :status => 400 + end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_shared_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_shared_form.html.erb index 6b551d48a38..b670d2655fd 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_shared_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_shared_form.html.erb @@ -2,9 +2,7 @@ display_owner = false end %>