aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-10-08 16:12:12 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-10-08 16:34:10 +0200
commit465e65d9212dd8b749bbe4eebc0777c0468b44f9 (patch)
treea41275d990d9968750ddb9ac618e8526df7f80cd /sonar-server/src
parenta4ac34cfc3057e74095b688065950ba7684765f7 (diff)
downloadsonarqube-465e65d9212dd8b749bbe4eebc0777c0468b44f9.tar.gz
sonarqube-465e65d9212dd8b749bbe4eebc0777c0468b44f9.zip
Fix widget properties with type METRIC
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb5
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb25
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/widget_properties_helper.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb2
4 files changed, 21 insertions, 15 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
index 465d2ada0b4..f5c9a89d69c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
@@ -715,7 +715,10 @@ module ApplicationHelper
metrics_by_domain=metrics.sort_by(&:short_name).inject({}) { |h, metric| h[metric.domain]||=[]; h[metric.domain]<<[metric.short_name, metric.key]; h }
- html = select_tag(name, grouped_options_for_select(metrics_by_domain, options[:selected_key], select_tag_prompt), :multiple => options[:multiple], :disabled => options[:disabled])
+ html = select_tag(name, grouped_options_for_select(metrics_by_domain, options[:selected_key], select_tag_prompt),
+ :multiple => options[:multiple],
+ :disabled => options[:disabled],
+ :id => html_id)
js = "$j('##{html_id}').select2({#{js_options.map{|k,v| "#{k}:#{v}"}.join(',')}});"
"#{html}<script>#{js}</script>"
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb
index f2809b086bf..ea98146eabb 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb
@@ -19,42 +19,45 @@
#
module PropertiesHelper
- def property_input_field(key, type, value, options, additionalOptions = {})
+ # html_options support :
+ # :html_id - the id of the generated HTML element
+ #
+ def property_input_field(key, type, value, options, html_options = {})
if type==PropertyType::TYPE_STRING
- text_field_tag key, value, {:size => 25}.update(additionalOptions)
+ text_field_tag key, value, {:size => 25}.update(html_options)
elsif type==PropertyType::TYPE_TEXT
- text_area_tag key, value, {:rows => '6', :style => 'width: 100%'}.update(additionalOptions)
+ text_area_tag key, value, {:rows => '6', :style => 'width: 100%'}.update(html_options)
elsif type==PropertyType::TYPE_PASSWORD
- password_field_tag key, value, {:size => 25}.update(additionalOptions)
+ password_field_tag key, value, {:size => 25}.update(html_options)
elsif type==PropertyType::TYPE_BOOLEAN
- (hidden_field_tag key, 'false', additionalOptions) + (check_box_tag key, 'true', value=='true', additionalOptions)
+ (hidden_field_tag key, 'false', html_options) + (check_box_tag key, 'true', value=='true', html_options)
elsif type==PropertyType::TYPE_INTEGER
- text_field_tag key, value, {:size => 10}.update(additionalOptions)
+ text_field_tag key, value, {:size => 10}.update(html_options)
elsif type==PropertyType::TYPE_FLOAT
- text_field_tag key, value, {:size => 10}.update(additionalOptions)
+ text_field_tag key, value, {:size => 10}.update(html_options)
elsif type==PropertyType::TYPE_METRIC
- metric_select_tag key, metrics_filtered_by(options), :selected_key => value, :allow_empty => true
+ metric_select_tag key, metrics_filtered_by(options), {:selected_key => value, :allow_empty => true}.update(html_options)
elsif type==PropertyType::TYPE_REGULAR_EXPRESSION
- text_field_tag key, value, {:size => 25}.update(additionalOptions)
+ text_field_tag key, value, {:size => 25}.update(html_options)
elsif type==PropertyType::TYPE_FILTER
user_filters = options_key(value, ::Filter.find(:all, :conditions => ['user_id=?', current_user.id]).sort_by(&:id))
shared_filters = options_key(value, ::Filter.find(:all, :conditions => ['(user_id<>? or user_id is null) and shared=?', current_user.id, true]).sort_by(&:id))
- filters_combo = select_tag key, option_group('My Filters', user_filters) + option_group('Shared Filters', shared_filters), additionalOptions
+ filters_combo = select_tag key, option_group('My Filters', user_filters) + option_group('Shared Filters', shared_filters), html_options
filter_link = link_to message('widget.filter.edit'), {:controller => :filters, :action => :manage}, :class => 'link-action'
"#{filters_combo} #{filter_link}"
else
- hidden_field_tag key, additionalOptions
+ hidden_field_tag key, html_options
end
end
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 00de6bec37c..1766c94faff 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
@@ -20,8 +20,8 @@
module WidgetPropertiesHelper
include PropertiesHelper
- def property_value_field(definition, value)
- property_input_field definition.key, definition.type.name, value.nil? ? definition.defaultValue : value, definition.options
+ def property_value_field(definition, value, widget)
+ property_input_field definition.key, definition.type.name, value.nil? ? definition.defaultValue : value, definition.options, {:html_id => "prop-#{widget.key.parameterize}-#{definition.key.parameterize}"}
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb
index bcac687922d..4cd3b99551f 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb
@@ -24,7 +24,7 @@
<tr>
<td class="form-key-cell"><%= property_def.key() -%><%= " *" unless property_def.optional() -%></td>
<td class="form-val-cell" id="row_<%= property_def.key() -%>">
- <%= property_value_field(property_def, widget.property_text_value(property_def.key())) -%>
+ <%= property_value_field(property_def, widget.property_text_value(property_def.key()), widget) -%>
<div class="form-val-note">
<%= message("widget." + widget.key + ".param." + property_def.key(), :default => property_def.description()) -%>
</div>