summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-01-23 09:54:19 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2013-01-23 09:54:31 +0100
commitd622654adeb4c657e426732b8d4d24aa6b62d9c6 (patch)
tree01c3818c5fe14478f9225a8eee7f92b4e9d10c1e /sonar-server
parentce1e7b754c6c08ba1696f9ec70c3ab62bfb5690b (diff)
downloadsonarqube-d622654adeb4c657e426732b8d4d24aa6b62d9c6.tar.gz
sonarqube-d622654adeb4c657e426732b8d4d24aa6b62d9c6.zip
SONAR-3692 Fix issue with name generation and improve widget property i18n
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/properties_helper.rb27
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb5
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb2
11 files changed, 33 insertions, 20 deletions
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 9a3a2ff7a34..fd19bacb372 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
@@ -52,8 +52,8 @@ module PropertiesHelper
password_field_tag name, value, {:size => options[:size] || 25}.update(html_options)
when PropertyType::TYPE_BOOLEAN
- if options[:default]
- select_options = "<option value='' #{ 'selected' if value.blank? }>#{ options[:default] }</option>"
+ if !options[:default].blank?
+ select_options = "<option value='' #{ 'selected' if value.blank? }>#{ message('default') }</option>"
select_options += "<option value='true' #{ 'selected' if value=='true' }>#{ message('true') }</option>"
select_options += "<option value='false' #{ 'selected' if value=='false' }>#{ message('false') }</option>"
select_tag name, select_options, html_options
@@ -90,11 +90,8 @@ module PropertiesHelper
default_value = options[:default].blank? ? '' : message('default')
select_options = "<option value=''>#{ default_value }</option>"
options[:values].each do |option|
- if screen == SCREEN_WIDGET
- message = message("widget.#{options[:extra_values][:key]}.option.#{name}.#{option}.name", :default => option)
- else
- message = option_name(options[:extra_values][:property], options[:extra_values][:field], option)
- end
+ message = screen == SCREEN_WIDGET ? option_name_with_key(options[:extra_values][:key], nil, option, 'widget') :
+ option_name(options[:extra_values][:property], options[:extra_values][:field], option)
select_options += "<option value='#{ html_escape option }' #{ 'selected' if value && value==option }>#{ message }</option>"
end
select_tag name, select_options, html_options
@@ -135,4 +132,20 @@ module PropertiesHelper
end
end
+ def option_name_with_key(property_key, field_key, option, key_prefix = '')
+ prefix = ''
+ prefix = key_prefix + "." if !key_prefix.blank?
+ if field_key
+ # Old key used for retro-compatibility
+ message = message(prefix +"option.#{property_key}.#{field_key}.#{option}.name", :default => '')
+ message = message(prefix +"property.#{property_key}.#{field_key}.option.#{option}.name", :default => option) unless message != ''
+ message
+ else
+ # Old key used for retro-compatibility
+ message = message(prefix +"option.#{property_key}.#{option}.name", :default => '')
+ message = message(prefix +"property.#{property_key}.option.#{option}.name", :default => option) unless message != ''
+ message
+ end
+ end
+
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb
index f019fdc4ff1..e61180f519c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb
@@ -45,11 +45,7 @@ module SettingsHelper
end
def option_name(property, field, option)
- if field
- message("option.#{property.key}.#{field.key}.#{option}.name", :default => option)
- else
- message("option.#{property.key}.#{option}.name", :default => option)
- end
+ option_name_with_key(property.key, field ? field.key : nil, option, nil)
end
def category_help(category)
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 93fcc8f30ab..df14ac28ff4 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
@@ -29,6 +29,7 @@
<%= property_value_field(property_def, widget.property_text_value(property_def.key()), widget) -%>
<div class="form-val-note">
<%
+ # Old key used for retro-compatibility
property_description = message("widget." + widget.key + ".param." + property_def.key(), :default => '')
property_description = message("widget." + widget.key + ".property." + property_def.key() + ".desc", :default => property_def.description()) unless property_description != ''
-%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb
index f465d0577e5..e1e809eb2b2 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_BOOLEAN.html.erb
@@ -1 +1 @@
-<%= property_input_field(id, PropertyType::TYPE_BOOLEAN, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :default => message('default')}) %> \ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_BOOLEAN, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :default => (defined? defaultValue) ? property.defaultValue : nil }) %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb
index 01ea42e3c20..d9e9399908d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_FLOAT.html.erb
@@ -2,4 +2,4 @@
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_FLOAT, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_FLOAT, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb
index 077ff457a3b..79f4a1f6efa 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_INTEGER.html.erb
@@ -2,4 +2,4 @@
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_INTEGER, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_INTEGER, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb
index 2ac1183619b..4f121917ca4 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_METRIC.html.erb
@@ -1,5 +1,8 @@
+<%
+ defaultValue = (defined? defaultValue) ? property.defaultValue : nil
+%>
<select name="<%= name -%>" id="<%= id -%>">
- <option value=""><%= !property.defaultValue.blank? ? message('default') : nil -%></option>
+ <option value=""><%= !defaultValue.blank? ? message('default') : nil -%></option>
<%
metrics_per_domain={}
metrics_filtered_by(property.options).each do |metric|
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb
index f7a94ebda2d..ee7ca50b73a 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PASSWORD.html.erb
@@ -2,4 +2,4 @@
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_PASSWORD, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_PASSWORD, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb
index 26ef0412fa8..7dececf6629 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_REGULAR_EXPRESSION.html.erb
@@ -2,4 +2,4 @@
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_REGULAR_EXPRESSION, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_REGULAR_EXPRESSION, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
index 903eb0b119f..3df9028bebe 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_STRING.html.erb
@@ -2,4 +2,4 @@
options = {:id => id}
options[:size] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_STRING, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
+<%= property_input_field(name, PropertyType::TYPE_STRING, value, PropertiesHelper::SCREEN_SETTINGS, options) %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb
index d3e59483f86..ac671bf6915 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_TEXT.html.erb
@@ -2,4 +2,4 @@
options = {:id => id}
options[:cols] = (defined? size) ? size : 50
%>
-<%= property_input_field(id, PropertyType::TYPE_TEXT, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :cols => (defined? size) ? size : nil}) %>
+<%= property_input_field(name, PropertyType::TYPE_TEXT, value, PropertiesHelper::SCREEN_SETTINGS, {:id => id, :cols => (defined? size) ? size : nil}) %>