From 4db7d8befe0c7c05580daa2da7e9e7cac030b434 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Mon, 14 May 2012 15:12:08 +0200 Subject: [PATCH] SONAR-2073 - Fix which filters are visible and group them by category. In a filter widget you shouldn't access to a filter created by another user but not shared by this user. Moreover, in the dropdown list to select a filter to be displayed it would be valuable to display to different sections : one for "my own filters" and the other one for the "shared filters". --- .../webapp/WEB-INF/app/controllers/filters_controller.rb | 2 +- .../webapp/WEB-INF/app/helpers/widget_properties_helper.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb index 32f1b4a0ae2..c8764755843 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb @@ -28,7 +28,7 @@ class FiltersController < ApplicationController before_filter :login_required, :except => ['index', 'treemap'] def manage - @filters = ::Filter.find(:all, :conditions => ['user_id=? or user_id is null', current_user.id]) + @filters = ::Filter.find(:all, :conditions => ['user_id=? or shared is true', current_user.id]) end def new diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb index 165b68b22c1..cdca2e2d282 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb @@ -37,7 +37,11 @@ module WidgetPropertiesHelper text_field_tag definition.key(), val, :size => 10 elsif definition.type.name()==WidgetProperty::TYPE_FILTER - select_tag definition.key(), ::Filter.all.sort_by(&:id).collect { |f| "" } + user_filters = ::Filter.find(:all, :conditions => ['user_id=?', current_user.id]).sort_by(&:id).collect { |f| "" } + shared_filters = ::Filter.find(:all, :conditions => ['(user_id<>? or user_id is null) and shared is true', current_user.id]).sort_by(&:id).collect { |f| "" } + all_filters = '' + user_filters.to_s + '' + '' + shared_filters.to_s + '' + + select_tag definition.key(), all_filters else hidden_field_tag definition.key() -- 2.39.5