From f505d27019e7c666de484e657dc3c98eb64a1dfd Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 5 Jul 2013 18:33:25 +0200 Subject: [PATCH] SONAR-4418 Refactor the bulk change redirection to fix bug when displaying resource from search box --- .../app/controllers/dashboard_controller.rb | 8 ++++---- .../app/controllers/issues_controller.rb | 9 ++++----- .../app/views/dashboard/no_dashboard.html.erb | 5 +++++ .../app/views/drilldown/_header.html.erb | 6 ++++++ .../app/views/issues/_bulk_change_form.html.erb | 17 +++-------------- .../WEB-INF/app/views/issues/search.html.erb | 8 +++++++- .../WEB-INF/app/views/resource/_tabs.html.erb | 3 +-- 7 files changed, 30 insertions(+), 26 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index 8e9232a1e39..7d096f9931a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -148,9 +148,9 @@ class DashboardController < ApplicationController if logged_in? if params[:did] - @dashboard=Dashboard.find(:first, :conditions => ['id=? AND user_id=?', params[:did].to_i, current_user.id]) + @dashboard=Dashboard.first(:conditions => ['id=? AND user_id=?', params[:did].to_i, current_user.id]) elsif params[:name] - @dashboard=Dashboard.find(:first, :conditions => ['name=? AND user_id=?', params[:name], current_user.id]) + @dashboard=Dashboard.first(:conditions => ['name=? AND user_id=?', params[:name], current_user.id]) elsif params[:id] active=ActiveDashboard.user_dashboards(current_user, false).first else @@ -161,9 +161,9 @@ class DashboardController < ApplicationController unless active or @dashboard # anonymous or not found in user dashboards if params[:did] - @dashboard=Dashboard.find(:first, :conditions => ['id=? AND shared=?', params[:did].to_i, true]) + @dashboard=Dashboard.first(:conditions => ['id=? AND shared=?', params[:did].to_i, true]) elsif params[:name] - @dashboard=Dashboard.find(:first, :conditions => ['name=? AND shared=?', params[:name], true]) + @dashboard=Dashboard.first(:conditions => ['name=? AND shared=?', params[:name], true]) elsif params[:id] active=ActiveDashboard.user_dashboards(nil, false).first else diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb index dc520aaa140..b30592b268d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb @@ -144,12 +144,11 @@ class IssuesController < ApplicationController # GET /issues/bulk_change_form?[&criteria] def bulk_change_form - params[:from] ||= 'issue_filters' - params_for_query = params.clone.merge({'pageSize' => -1}) + issues_query_params = params.clone.merge({'pageSize' => -1}) if params[:id] - @issue_filter_result = Internal.issues.execute(params[:id].to_i, params_for_query) + @issue_filter_result = Internal.issues.execute(params[:id].to_i, issues_query_params) else - @issue_filter_result = Internal.issues.execute(params_for_query) + @issue_filter_result = Internal.issues.execute(issues_query_params) end render :partial => 'issues/bulk_change_form' end @@ -158,7 +157,7 @@ class IssuesController < ApplicationController def bulk_change verify_post_request Internal.issues.bulkChange(params, params[:comment]) - render :text => params[:criteria_params], :status => 200 + render :text => params[:issues_query_params], :status => 200 end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb index e125579a9e4..097babb7f52 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb @@ -12,6 +12,11 @@ anchor = stripped_url[1]; } + // refresh page after issues bulk change + function onBulkIssues(issues_query_params, component_key){ + window.location.reload(); + } + openAccordionItem('<%= url_for(params.merge({:controller => 'resource', :action => :index, :id => @file.id, :display_title => 'false', :popup => 'false'})) -%>', this, false) .done(function () { if (anchor != null) { diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb index 41ce9d5d988..f076a1c8d58 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb @@ -11,4 +11,10 @@ openAccordionItem(url, this); return false; } + + // refresh page after issues bulk change + function onBulkIssues(issues_query_params, component_key){ + d(component_key); + closeModalWindow(); + } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb index 8dafa130e39..43d066db14f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb @@ -24,7 +24,7 @@ %>
- +
- <% end %> -- 2.39.5