diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-01-16 14:36:39 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-01-16 14:36:39 +0100 |
commit | 310b36e6770cf3a08af198b7a475add0b35158fa (patch) | |
tree | e3274b47ed6c31aa6e248aa255cf22a6aeaa11f1 | |
parent | 95adfe92dec93a621f8960e02f99891ddc9f84a8 (diff) | |
download | sonarqube-310b36e6770cf3a08af198b7a475add0b35158fa.tar.gz sonarqube-310b36e6770cf3a08af198b7a475add0b35158fa.zip |
SONAR-2990 The category filter is lost when adding a widget to a dashboard
4 files changed, 13 insertions, 10 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 5514e6b808b..e73e418b279 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 @@ -51,7 +51,8 @@ class DashboardController < ApplicationController # TODO display error page if no dashboard or no resource load_resource() load_dashboard() - load_widget_definitions() + @category=params[:category] + load_widget_definitions(@category) unless @dashboard redirect_to home_path end @@ -121,7 +122,7 @@ class DashboardController < ApplicationController end end end - redirect_to :action => 'configure', :did => dashboard.id, :id => params[:id], :highlight => widget_id + redirect_to :action => 'configure', :did => dashboard.id, :id => params[:id], :highlight => widget_id, :category => params[:category] end @@ -146,8 +147,9 @@ class DashboardController < ApplicationController end def widget_definitions - load_widget_definitions(params[:category]) - render :partial => 'dashboard/widget_definitions', :locals => {:dashboard_id => params[:did], :resource_id => params[:id], :filter_on_category => params[:category]} + @category=params[:category] + load_widget_definitions(@category) + render :partial => 'dashboard/widget_definitions', :locals => {:dashboard_id => params[:did], :resource_id => params[:id], :category => @category} end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb index aa7a65bfd48..32c120b6917 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definition.html.erb @@ -4,6 +4,7 @@ <p><%= h message('widget.' + definition.getId() + '.description', :default => definition.getDescription()) -%></p> <%= form_tag :action => 'add_widget', :did => dashboard_id, :id => resource_id, :widget => definition.getId() %> + <input type="hidden" name="category" value="<%= category -%>"> <input type="submit" value="<%= message('dashboard.add_widget') -%>"> </form> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb index 7713ecf70e2..32f04c617e3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_definitions.html.erb @@ -1,9 +1,9 @@ <p> <ul class="horizontal widget_categs"> <li><%= message('filter_verb') -%>: </li> - <li class="<%= 'selected' if filter_on_category.blank? -%>"><a href="#" onClick="return filterWidgets('')"><%= message('none') -%></a></li> - <% @widget_categories.each do |category| %> - <li class="<%= 'selected' if filter_on_category==category -%>"><a href="#" onClick="return filterWidgets('<%= category -%>')"><%= h(category) -%></a></li> + <li class="<%= 'selected' if category.blank? -%>"><a href="#" onClick="return filterWidgets('')"><%= message('none') -%></a></li> + <% @widget_categories.each do |c| %> + <li class="<%= 'selected' if category==c -%>"><a href="#" onClick="return filterWidgets('<%= escape_javascript(c) -%>')"><%= h(c) -%></a></li> <% end %> </ul> <%= image_tag 'loading.gif', :style=>'vertical-align: top;display: none', :id => 'filter-widgets-loading' -%> @@ -11,7 +11,7 @@ <table width="100%"> <% @widget_definitions.each_with_index do |definition, index| %> <% if index%4==0 %><tr><% end %> - <%= render :partial => 'dashboard/widget_definition', :locals => {:definition => definition, :dashboard_id => dashboard_id, :resource_id => resource_id} %> + <%= render :partial => 'dashboard/widget_definition', :locals => {:definition => definition, :dashboard_id => dashboard_id, :resource_id => resource_id, :category => category} %> <% if index%4==3 %></tr><% end %> <% end %> <% for i in 0..(4-(@widget_definitions.size%4)) %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb index 0ee8b003770..12a599e1f3d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb @@ -28,7 +28,7 @@ function filterWidgets(category) { new Ajax.Updater( 'widget_defs', - '<%= url_for :controller => "dashboard", :action => "widget_definitions", :did => @dashboard.id, :id => @resource.id -%>&category=' + category, + '<%= url_for :controller => "dashboard", :action => "widget_definitions", :did => @dashboard.id, :id => @resource.id -%>&category=' + encodeURIComponent(category), {asynchronous:true, evalScripts:true}); $('filter-widgets-loading').show(); return false; @@ -41,7 +41,7 @@ <%= render :partial => 'dashboard/header', :locals => {:back => true} %> <div id="widget_defs"> - <%= render :partial => 'dashboard/widget_definitions', :locals => {:dashboard_id => @dashboard.id, :resource_id => @resource.id, :filter_on_category => nil} -%> + <%= render :partial => 'dashboard/widget_definitions', :locals => {:dashboard_id => @dashboard.id, :resource_id => @resource.id, :category => @category} -%> </div> |