diff options
author | David Gageot <david@gageot.net> | 2012-05-07 16:27:59 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-05-07 16:29:40 +0200 |
commit | 8550a90562c5cbf517bb68010d4b5d616cb01aa4 (patch) | |
tree | 65c44747c9a44cd5468beb8cac3c556af4bd6e79 | |
parent | 81d81bfcaffb1f738a830a7ef007bd1347cd5317 (diff) | |
download | sonarqube-8550a90562c5cbf517bb68010d4b5d616cb01aa4.tar.gz sonarqube-8550a90562c5cbf517bb68010d4b5d616cb01aa4.zip |
In the Widget Filter, we should be able to select filter by name
4 files changed, 12 insertions, 6 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java index 95d71e71d81..36784a0f081 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/FilterWidget.java @@ -31,7 +31,7 @@ import org.sonar.api.web.WidgetGlobal; @WidgetCategory("Beta") @WidgetGlobal @WidgetProperties({ - @WidgetProperty(key = "filter", type = WidgetPropertyType.INTEGER, defaultValue = "1") + @WidgetProperty(key = "filter", type = WidgetPropertyType.FILTER, defaultValue = "1") }) public class FilterWidget extends AbstractRubyTemplate implements RubyRailsWidget { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java index 409120aab66..7be2caf8b2c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertyType.java @@ -24,5 +24,6 @@ public enum WidgetPropertyType { BOOLEAN, FLOAT, STRING, - METRIC // @since 2.10 + METRIC, // @since 2.10 + FILTER // @since 3.1 } 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 d280359c6f5..277209e5b87 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 @@ -23,7 +23,7 @@ module WidgetPropertiesHelper val=value || definition.defaultValue() if definition.type.name()==WidgetProperty::TYPE_INTEGER text_field_tag definition.key(), val, :size => 10 - + elsif definition.type.name()==WidgetProperty::TYPE_FLOAT text_field_tag definition.key(), val, :size => 10 @@ -36,9 +36,12 @@ module WidgetPropertiesHelper elsif definition.type.name()==WidgetProperty::TYPE_STRING 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| "<option value='#{f.id}'>#{f.name}</option>" } + else hidden_field_tag definition.key() end end - -end
\ No newline at end of file + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb index 719b1db005a..44eb59445a2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/widget_property.rb @@ -81,6 +81,8 @@ class WidgetProperty < ActiveRecord::Base text=='true' when TYPE_METRIC Metric.by_key(text) + when TYPE_FILTER + text.to_i else text end @@ -99,4 +101,4 @@ class WidgetProperty < ActiveRecord::Base end end -end
\ No newline at end of file +end |